I’m trying to use the crop region of certain views to create detail lines for Key Plans. I was able to modify this code to process multiple views at once and return their boundaries:
However, the output is a list of "Autodesk.Revit.DB.Line"s as shown below:
I’ve tried to get the lines’ start points, end points, etc. but the output list of lines is the makeup of a CurveLoop, and I can’t discern how to call upon the lines composing the CurveLoop within the Python script. Here is the code:
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument
views = UnwrapElement(IN[0])
curveloops = []
TransactionManager.Instance.EnsureInTransaction(doc)
for view in views:
crsms = view.GetCropRegionShapeManager()
crshapes = crsms.GetCropShape()
curveloops.append(crshapes)
TransactionManager.Instance.TransactionTaskDone()
OUT = curveloops
Maybe I am overlooking something obvious but I’m stumped! Would appreciate any ideas that may point me in the direction of retrieving these Lines’ geometry.
There is some Python script from the MEPover package that should do the trick.
Its a cool package with a few neat features
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import clr
clr.AddReference("RevitNodes")
import Revit
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
#The inputs to this node will be stored as a list in the IN variables.
if isinstance(IN[0], list):
view = UnwrapElement(IN[0])
toggle = 0
else:
view = [UnwrapElement(IN[0])]
toggle = 1
listout = []
for x in view:
region = x.GetCropRegionShapeManager().GetCropShape()
if len(region) > 0:
lines = [y.ToProtoType() for y in region[0]]
listout.append(lines)
else:
listout.append([])
#Assign your output to the OUT variable.
if toggle == 0:
OUT = listout
else:
OUT = lines