Python Script not running

Hello! I am trying a For-Loop in Python in Dynamo for Civil 3D and I get an error which I can not solve.
Warnung:AttributeError : type object ‘Polyline’ has no attribute ‘ByPoints’ [’ File “”, line 44, in \n’]
What am I doing wrong?

Hi @bano35R3K,

Is you end goal just to create polylines in model space?

No, it is just a simple example to show the error

Hi
This is example, look it

Basically you’re trying to create an AutoCAD.DatabaseServices.Polyline. This type can be constructed e.g. with Polyline() constructor and then given points with for example the AddVertexAt() method.

p1 = Point2d(0,0)
p2 = Point2d(0,1)

pl = Polyline()
pl.AddVertexAt(0,p1,0,0,0)
pl.AddVertexAt(0,p2,0,0,0)

This Class must not be mistaken for the Polycurve type wich is a Dynamo Class. Not standard in the Python Script node so you must add the library (I use DS as a sub because some classes such as Point are ambiguous):

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

p1 = DS.Point.ByCoordinates(0,0,0)
p2 = DS.Point.ByCoordinates(0,1,0)
dspoly = DS.PolyCurve.ByPoints([p1,p2])

I hope this clarifies the issue.

2 Likes