Get Viewport Outline (Python)

Hello Dynamo Friends :slight_smile:

I created a python script to get the outlines of a viewport.
It “kind of” works, but as I´m getting these two different results for the same viewport there might be something wrong.

image

Any thoughts about the method I use?

outlist=[]

# If Input is an item wrap it in a list:
if isinstance(IN[0],list):
	viewports = UnwrapElement(IN[0])
else:
	viewports = [UnwrapElement(IN[0])]

for viewport in viewports:
	lines=[]
	outline = viewport.GetBoxOutline()
	min = outline.MinimumPoint
	max = outline.MaximumPoint
	pt3=XYZ(max.X, min.Y, min.Z)
	pt4=XYZ(min.X, max.Y, max.Z)
	
	line1=Line.CreateBound(min,pt3).ToProtoType()
	line2=Line.CreateBound(pt3,max).ToProtoType()
	line3=Line.CreateBound(max,pt4).ToProtoType()
	line4=Line.CreateBound(pt4,min).ToProtoType()
	
	lines.append(line1)
	lines.append(line2)
	lines.append(line3)
	lines.append(line4)
	outlist.append(lines)
	
OUT = outlist

Thankful for any advice :slight_smile: