I'm testing a "static" method to assign a scope box to an
existing 3D view via a Python node in Dynamo.
I want the SectionBox to start right at a Level and stop at the Level above.
The problem I encounter is that in order to get the Min/Max of the Box at the Level.Elevation, I need
subtract from that a value of 14.5.
Not sure where the issue is.
Below the code I generated and the test Revit file.
Thanks for your help.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI', 'RevitAPIUI', 'System', 'ProtoGeometry', 'RevitServices', 'RevitNodes')
import Revit
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB import Family
import Autodesk
from Autodesk.Revit.UI import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Autodesk.Revit.UI import TaskDialog
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInCategory, ElementId, ScheduleDefinition
from System.Collections.Generic import List
clr.ImportExtensions(Revit.Elements)
import System
from System.Collections.Generic import *
from System import Guid
# DEFINE CURRENT/ACTIVE DOCUMENT
doc = DocumentManager.Instance.CurrentDBDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
#get ViewFamilyType for a 3D View
VIEW_3D_FAMILY_TYPE = [i for i in FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements() if i.ViewFamily == ViewFamily.ThreeDimensional][0]
LEVELS = [i for i in FilteredElementCollector(doc).OfClass(Level).ToElements()]
# SELECT MY ISOMETRIC VIEW
MY_3D_VIEW_1 = [i for i in FilteredElementCollector(doc).OfClass(View3D).ToElements() if i.IsTemplate is False and i.IsPerspective is False and i.Name == 'MY_3D_1'][0]
# SELECT LEVELS
LEVEL_1 = [i for i in FilteredElementCollector(doc).OfClass(Level).ToElements() if i.Name == 'Level 1'][0]
LEVEL_2 = [i for i in FilteredElementCollector(doc).OfClass(Level).ToElements() if i.Name == 'Level 2'][0]
# START TRANSACTION TO SET SECTION BOX
t2 = Transaction(doc, 'SET SECTION BOX FOR 3D VIEW')
t2.Start()
sectionBox = app.Create.NewBoundingBoxXYZ()
MY_3D_VIEW_1.IsSectionBoxActive = True
sectionBox = MY_3D_VIEW_1.GetSectionBox()
sectionBox.Min = XYZ(-100, -100, LEVEL_1.Elevation-14.5)
sectionBox.Max = XYZ(100, 100, LEVEL_2.Elevation-14.5)
MY_3D_VIEW_1.SetSectionBox(sectionBox)
bx = MY_3D_VIEW_1.GetSectionBox()
doc.Regenerate()
t2.Commit()
OUT = bx
Solved! Go to Solution.