I am writing a script that finds all area schedules, get the first area in them, and find its Area Scheme name. Then the area scheme name is saved into a schedule’s text parameter.
This is because the Area Schedules do not seem to save the information about what area scheme they are using. (it is saved in the schedule names when created but users rename them and the information is lost).
First question: is there any way to directly extract the Area Scheme from an Area schedule without need to inspect the areas it lists?
Second question: what is the best way to obtain the areas listed in an Area Schedule IF the Areas are in a linked model? I am using “All Elements of Category in View” node, to see all the areas in the schedule, but it does not work if the areas are in a linked model (they show in the schedule, but are not found by the node.)
You are not changing the schedule, you are changing what the schedule is showing, and that is areas. So, you are dealing with areas, not schedule. You could group all areas by the scheme they belong to. I attached an image. To get elements from links, use bimorphNodes and Springs packages.
I am not sure what you mean by “you are changing what the schedule is showing”.
Working directly with areas is great, but the main point of the script is to figure out the Area Scheme used by an Area schedule.
If Areas can be queried to find their Area Scheme, is that possible with an Area Schedule? I could not find a node that retrieves that information, maybe its an API feature?
If Areas can be queried to find their Area Scheme, is that possible with an Area Schedule? I could not find a node that retrieves that information, maybe its an API feature?
positive. doc.GetElement(sched.Definition.AreaSchemeId) # sched being a schedule input
Second question: what is the best way to obtain the areas listed in an Area Schedule IF the Areas are in a linked model? … (they show in the schedule, but are not found by the node.)
don’t know about the “best” way but i’ve seen people had some success by retrieving elements at document level then applying filtering logic identical to what’s being used in schedule filters. the result are exactly the same as those rows displayed in the schedule. haven’t test it myself but this might be easier by now.
btw it’d be better to post some sample files here. that makes it easier for everyone to test and increase the chances of getting a solution.
the attribute “Definition” does not exist for ScheduleViews… Is this because a ScheduleView is differnt from a Schedule definition?
I am also working with ChatGTP, but it is constantly making-up code that does not exist in the revit API.
Any chance you could show a working sample of this method?
This is what I tried:
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import BuiltInCategory
from RevitServices.Persistence import DocumentManager
# Get the current Revit document
doc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Document
area_scheme_id = []
# Input: A single area schedule (or a list of schedules)
area_schedule = IN[0]
# Get the AreaSchemeId from the schedule's definition
for schedule in area_schedule:
area_scheme_id = doc.GetElement(schedule.Definition.AreaSchemeId)
area_scheme_ids.append(area_scheme_id)
# Output the AreaSchemeId
OUT = area_scheme_ids
Assuming you have a schedule definition, it should just be x.AreaSchemeId.
You can find this in Python by typing OUT = dir(x) where x is an instance of the class. When you see something you want to learn more about, OUT = x.Something.__doc__() should tell you what it is looking for in terms of inputs.
Yes. You have a thing, what options do you see on that when you use OUT = dir(yourThing)? One of those should help you reach the definition, and from there you can get the scheme.
The final trick was to actually unwrap the ScheduleView.
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
# Get the active document
doc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument.Document
# Assuming IN[0] is a list of ScheduleView elements
schedule_views = UnwrapElement(IN[0])
areaschemeid = []
areaschemeids = []
if isinstance(schedule_views, list):
for schedule in schedule_views:
# Get the schedule definition from the ScheduleView
schedule_definition = schedule.Definition
areaschemeid = schedule_definition.AreaSchemeId
areaschemeids.append(areaschemeid)
else:
schedule_definition = schedule_views.Definition
areaschemeids = schedule_definition.AreaSchemeId
OUT = areaschemeids