I’ve created a graph that places Area boundaries at Room.Center Boundary curves. Then it creates Areas within those boundaries and names/numbers the Areas according to their corresponding Rooms. (Special thanks to @GavinCrump for the python code from his Crumple nodes.)
Everything works flawlessly, however, when Area Boundaries are created in this manner they are not bound to the walls. My Architect wants the Area Boundaries to be bound to the walls so if the walls move they don’t have to move the boundaries manually.
When Area Boundaries are created manually there’s an option called “Apply Area Rules”.
This option seems to bind the created Area Boundaries to the walls, but only if you use PickLines to create the boundary and then select the wall.
I dove into the API docs and could not find anything about “Apply Area Rules” or binding Area Boundaries.
I’ve been learning Python and the calls, classes, & methods in the Revit API docs. I have not found a way to bind Area Boundaries to the closest wall centerlines.
A handful of similar discussions out there, and deafening silence from the developers:
If the API did support this it would typically be in one of two ways:
The new area boundary line would have a bool argument for this
The " " would have a related options class and argument for this (more likely)
Given neither exist in the API that I can see I suspect it is unsupported. Ideally the API created lines would just remember the setting given it’s an ini thing, but it looks like they don’t.
I believe this is doable, but you have to think about the problem differently.
The constraint isn’t between the wall and the area, but between the wall and the area separation line.
Since you’re drawing an area separation line from each wall, take the wall, the the curve, generate the area separation line, get a reference to the wall’s curve, get a reference to the area separation line, and create a new alignment using the method here: NewAlignment Method
Ohhh! That makes sense. Haha, It’s funny because I’ve made hundreds of families, so align and lock is not a foreign concept. Thanks for the fresh perspective. I’ll try it tomorrow.
I tried “Dimension” and received an error that said dimension doesn’t have the NewAlignment method. Which is confusing because we see it in the API docs.
So I tried doc.Create and received this error:
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
area_plan_view = IN[0]
area_separation_refs = UnwrapElement(IN[1])
wall_refs = UnwrapElement(IN[2])
doc = DocumentManager.Instance.CurrentDBDocument
area_plan = doc.GetElement(area_plan_view.UniqueId)
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(area_separation_refs)):
area_ref = area_separation_refs[i]
wall_ref = wall_refs[i]
doc.Create.NewAlignment(area_plan, area_ref, wall_ref)
TransactionManager.Instance.TransactionTaskDone()
OUT = "Alignments created successfully"
I’m not sure what you are asking.
The text from the error message is:
TypeError : No method matches given arguments for NewAlignment: (<class’Autodesk.Revit.DB.ViewPlan’>, <class’Revit.GeometryReferences.ElementCurveReference’>, <class’Revit.GeometryReferences.ElementCurveReference’>)
Comment out everything after the imports (wrap it in triple quotes), and then append the line I posted above so we can confirm what the pythonic version is expecting for inputs.
I gather that I have some rewriting and converting of inputs to do, correct?
Because Revit.GeometryReferences.ElementCurveReference is not the same as Autodesk.Revit.DB.Reference.
No, sadly those classes should inherit the parent class (view plan inherits view, element curve reference inherits reference)… I’ll try to look into this tomorrow - might be a Python limitation though so you can try IronPython 3 or 2 (in that order) if you’re in CPython.
Also check to see if unwrapping the view input helps.
I figured it out!
Code is below.
Instead of getting the Element Curve Reference from the walls and area separation lines, I used the GeniusLoci node called Element Reference to get the Autodesk.Revit.DB.References.
The odd thing is, the Python node still throws this error:
But when I nudged one of the walls the Area separation line was in fact locked to the wall. So the error will tell you that it didn’t work, but it actually does work.