View Crop Region with break - Total width

When we break a View we get only one of the Crops.

Is there a way to get the total width.
So both crops included the white space in the middel?

This is the Python code in the node.
Maybe something there can be changed?

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

I found this, but no solution there :point_down:.

have you tried ootb view.cropbox…it should give a boundingbox for all i guess…try it and see if it work…cant test right now

That gives me a Bounding.Box and some other issues…

Also good to know is that we need this for Section.
So what if the Section isn’t orthogonal. I guess a Bounding.Bos isn’t the
best solution?

what kind of issues ?

See above post (3/5). Trouble getting the curves of the Bounding Box.

Don’t know what the difference is to this

im not at dyn in the moment but try spring boundingbox rectangle…but not sure, i will give it a try in the weekend …if you dont have find a way

I also keep on digging / trying.

Would be much appreciated :green_heart:.

Though i hope for a solution without the need of a Bounding.Box
and a node like this :point_down: would just give the total width.

But i guess that is wishful thinking and this is just how the nodes works.

1 Like

yeah not sure…but guess when we split cropboxes, its a kind of a void/mask…i think :wink: :wink:

For context.

We want to check if a tag is outside a Crop Region in a Section.

So if you have any other bright idea how to do that :laughing:.

My collegue has a working script, but it just doesn’t work when
a View has a Crop with a Break.

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 :wink: so its stable and works in all situation :wink: :wink:

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.

1 Like

Not at the PC so pardon any typos (in particular with indentation, but try changing this:

To:

for loop in region:
	lines = [y.ToProtoType() for y in loop]
	listout.append(lines)
1 Like

I guess your code was what @Nick_Boyts
was saying. Will try Monday.
Weekend first now.
Really need that (weekend that is).

1 Like

if you just want the total width, i think something here maybe

@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.

This seems to work.

1 Like