Get Part Plan View Boundary

Hii everyone, Is there a way to get each part plan view boundary since each part plan is created using scope boxes not crop region ??
I’ve tried many times but with no luck
Any solution would be appreciated

Hi @abdallahzakaria,

This should do the trick…Just paste into a python node with one port IN[0].

import clr

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as geom

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

v = tolist(UnwrapElement(IN[0]))[0]

if v == None:
	v = doc.ActiveView

shpMan = v.GetCropRegionShapeManager()

OUT = geom.PolyCurve.ByJoinedCurves([x.ToProtoType() for x in shpMan.GetCropShape()[0]]) 

This only operates on a single view, but could be modified to loop through many (if you are uncomfortable doing adding a loop yourself, then let me know and I will update). I have tested with Scope Boxes and works just fine.

Hope this helps. :wink:

1 Like

Dear Daniel_Woodcock1,
Thanks a lot for your reply, It works like a charm and I have edited the script to work for many views as shown hereunder, thanks a lot for your great effort :partying_face: :partying_face:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript import Geometry as geom

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc =  DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

def tolist(obj1):
	if hasattr(obj1,"__iter__"): return obj1
	else: return [obj1]

v = tolist(UnwrapElement(IN[0]))

outline=[]
for i in v:
	CropShape = i.GetCropRegionShapeManager().GetCropShape()
	if len(CropShape) > 0 :
		lines = [x.ToProtoType() for x in CropShape[0]]
		outline.append(lines)
	else: outline.append([])

Boundary = []
for y in outline:
	Boundary.append(geom.PolyCurve.ByJoinedCurves(y))

OUT = Boundary, outline
1 Like