Create Lines in Python (.ByStartPointDirectionLength)

Hi, I’m trying to create lines in python, recreating the node:
image

however it’s returning this error message,

image

when i checked in the documentation it doesn’t have a .ByStartPointDirectionLength method…

is it actually possible to create lines in python?

Works for me in 2024

I mean in a python script :smile:

I was directing towards the error you were getting.

Here are your options with designscript and python

import clr

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

stpt = IN[0]
drct = IN[1]
lnth = IN[2]

OUT = Line.ByStartPointDirectionLength(stpt,drct,lnth)

Note that Revit and Dynamo both have Line class, and so if you’ve loaded both of them into the Python environment it’s likely that you’re confusing the computer which is preventing it from knowing what to do (Revit Line doesn’t have that method, but you didn’t say to use Dynamo Line and so I’m trying the ‘first in mind’ which happens to be Revit due to the complexity of that library).

If not that it’s likely an imports error.

You need to share the simplest reproducible code sample here for more direct support (i.e. if the option which @staylor shared doesn’t work).

1 Like

Yes, this works, thank you! :smiley:

1 Like