Is there a way to get a bounding box from a section box in a 3D view?
I know that it is possible to go the other way around but I am having difficulty getting a bounding box. I want to be able to take an existing 3D view, duplicate it, and change the scope box of the new view.
The only way I can think do do this is to get a bounding box from an existing 3D view, modify it, and use View3D.SetSectionBox with a duplicated new view.
I’m really stuck here DynaFam, any help is appreciated.
Edit: I’ll be looking further into this, looks like it could have what I’m looking for.
The problem is I haven’t gotten anywhere. I’ve been trying to use existing nodes to accomplish this task but none seem to exist. The next step is to start looking into the API to see if I can come up with a python script to put in. I figured I’d see if the community knows about a node before I go down that road.
If you go the API route, the command on a 3d view is called .GetSectionBox() and returns a bounding box. This should be what you are asking for.
Keep in mind though that bounding boxes do not save orientation, they are always the same orientation. So if your scope box or sectionbox has been rotated, it won’t be kept over. If that is important, .GetCropRegionShapeManager() might work, but I haven’t tested it.
The python code only takes in a list so single views will not work. What I did is create a list of the same view and pull out one of the boundary boxes from the output. Its kinda jerry-rigged but it works. If I have extra time I will try to change it to single input, I could definitely could use the python practice.
To make it work for list and single items, you just need a simple if statement that turns single objects into a list containing only the single object. Something like this:
if isinstance(IN[0], list):
views = UnwrapElement(IN[0])
else:
views = [UnwrapElement(IN[0])]
This python code doesn’t work for me. Can you show me how it works? I am not familiar with scripting in dynamo. I want to make a geometry of bounding box from the 3D section box.
Hey @parvir.mundi I think your question is a good question but a little off topic. Maybe make a new post?
Anyway, the method I would use to solve your question would be to first get the bounding boxes of each element. Then create a new bounding box using the largest max bound and the smallest min bound of the two bounding boxes. Not sure if it can be done with just nodes.