'Line' object has no attribute 'ToProtoType'

The Primer says this should work:

What am I doing wrong?

It works fine without the ProtoType thing, but I cannot make any sense of it in Dynamo:

Believe you are missing the geometry conversion part of the boilerplate code.

1 Like

Hi Danail,

To use ToProtoType add above :

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

Because you only imported the Element wrapper extension methods and not the geometry conversion extension methods.

2 Likes

Thank you both, Alban and Jacob!

Here’s the final code, to whom it may be useful in the future:


import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

areas = UnwrapElement(IN[0])
curveslist = []

Options = SpatialElementBoundaryOptions()
Options.SpatialElementBoundaryLocation = SpatialElementBoundaryLocation.Center

for area in areas:
	curvesSublist = []
	for curve in area.GetBoundarySegments(Options)[0]:
		curvesSublist.append(curve.GetCurve().ToProtoType())
	curveslist.append(curvesSublist)

OUT = curveslist