Hi everyone,
I got this python script posted by Dimitar Venkov and Konrad Sobon which basically creates a 3D view by bounding box.
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
bboxs = tolist(IN[0])
viewNames = tolist(IN[1])
views=[]
#get ViewFamilyType for a 3D View
collector = FilteredElementCollector(doc)
viewTypeColl = collector.OfClass(ViewFamilyType)
for i in viewTypeColl:
if i.ViewFamily == ViewFamily.ThreeDimensional:
viewType = i
else:
continue
for bbox,viewName in zip(bboxs,viewNames):
newmax = UnwrapElement(bbox.MaxPoint).ToRevitType()
newmin = UnwrapElement(bbox.MinPoint).ToRevitType()
newbox = BoundingBoxXYZ()
newbox.Max = newmax
newbox.Min = newmin
TransactionManager.Instance.EnsureInTransaction(doc)
view = View3D.CreateIsometric(doc, viewType.Id)
view.Name = viewName
view.SetSectionBox(newbox)
views.append(view)
TransactionManager.Instance.TransactionTaskDone()
OUT = views
I am not familiar with Python or Revit API (learning it ATM) so need some help figuring this out.
Is there anyway someone can modify the script to have it create a floor plan view instead of a 3D view from the bounding box or something similar to a box?
For example, I want the user to go to an already existing floor plan view, create a scope box around an area and finally crop out everything else that is not inside the box.
You can also help me by pointing me to the right direction. I will appreciate all the help I can get.