Get geometry of section box

Hi

Is there a way to get the geometry (or bounding box) from a section box? Most of the usual OOTB nodes fail with section boxes.

Also, even with only one section box possible per view, Dynamo is returning all section boxes in the project. Is this expected behaviour? I’m just after the single section box (and its geometry) of the active view.

Section box geometry.dyn (16.6 KB)

I know for a fact there is, but I’m lying in bed.

I use sections to figure out, for example, which views my technical openings are in.

I’m not sure about the section box, what about selecting a section with the model element and getting the box?

The more complicated way would be to get the view deep, the view direction and the crop region, but I don’t think I had to do this…

If you wrote a response, and it hasn’t already been solved, I’ll get an email when I get in tomorrow and can have a quick look to see how I did it…in about eight hours…

I’m not sure why the Dynamo nodes don’t implement this, but the GetSectionBox method works.

Below code mostly works except if the view doesn’t have a section box enabled as it gets retured anyway. I guess it need a try/except condition so that in this case, a null is retured instead???

# Load the Python Standard and DesignScript Libraries
import clr
import sys
import System
from System.Collections.Generic import List
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
from Revit import GeometryConversion as gp

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager


# The inputs to this node will be stored as a list in the IN variables.
view = UnwrapElement(IN[0])
secBox = []
bbox = []

# Get section box
for v in view:
	secBox = v.GetSectionBox().ToProtoType()
	bbox.append(secBox)

# Assign your output to the OUT variable.
OUT = bbox

You could run a dry transaction (roll it back vs commiting) to temporarily turn on the section box if it’s off, then get it. I’ve been using this trick a lot when a geometry query involves a model change that I don’t need to commit.

In my own RLS toolkit I achieve this step without using Dynamo API by using the min/max bounding box points to generate a curveloop, then extrude them upwards to a cuboid using this method:

GeometryCreationUtilities.CreateExtrusionGeometry

Looks like you’re going through similar steps I had to when I put mine together, hang in there - lots of hacky stuff needed, especially for the 3d views (I suffered with bounding box crops also, never quite got it cropping 100% perfectly). Elevating rooms on an angle was also… interesting.

I used this step to deal with finding the elevating frames of the room at an angle (get BB, make cuboid, rotate by room aspect, bb the cuboid, rotate back, voila you get the elevating frames). Wonder if it might be the same case for you.

Thanks Gavin. It’s less to do with transactions, and more to do with dealing with a list of inputs (views) that may or may not have a section box enabled.

I have the cropping 3D views working accurately but I realised that when section boxes are enabled, the logic needs to change. Hence why I am trying to gets its geometry.

1 Like

Ah yes in this case I mean you can use a transaction to change the section box on property so you can temporarily be sure they all have an active section box to support your method, then rollback the transaction to undo its change vs committing it. Anything you collect in a transaction like geometry is maintained beyond transactions even if they don’t get committed.

On second reading I assume you want to catch views without a section box intentionally as None/null though, so yes that checks out. Nevermind…

I guess you could check the view’s section box property. Sneaky property as it’s hiding in the View3D class as opposed to inherited from the View class:

Yeah - checking that property is likely best. I think there is a parameter too.

Best to use this in a if statement (i.e.: if property is true, get section box, else get none), as try statements shouldn’t be used for flow control since they mask issues.

So it looks like this is what I was doing:

  1. Get the view outline (crop region)
  2. get the view direction
  3. extrude

I was using the view depth (“Versat hinter dre Grenze”) but it didn’t work for what i was imiplementing it for; colliding technical openings with the view, which would often return openings which were in walls behind the view.

You can of course use your view depth to get the true geometry.