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
yeah if that should be result…there probably could be a better workflow, i will try play with it…when time…but no guarantee for i can hack it so its stable and works in all situation
This part of the code is assuming that there’s a singular unbroken crop region. The region variable is holding the boundary loops as a sublist of curves per loop. The code is taking just the first loop (region[0]) rather than iterating through each sublist. Just add an additional for loop to step through each sublist and add all curves to your output.
@bvs1982 Why not prepare an aabb test? You can get the individual bbox from CropRegionShapeManager, at least the metadata for constructing such boxes are there (2d is enough, you can condense the depth but do it in section space). Then you can cancel leaders at runtime then move annotation straight to its host and get the bbox of the annotation then restore the annotation and its bbox you’ve just got back to original position (I think you need to rollback the transaction. Cached position and turning leaders back on won’t work, I think it will mess up the leaders). Now you are ready for aabb test against all crop regions. All false would be “outside”, “inside” with a one true at least. And don’t forget doc regeneration.