Importing Curve methods to Python Script

Hello all,

I’m new in Dynamo and I already searched a lot on internet to find an answer to my question but unsuccessfully…
I’m working on a Python Script and I want to use the “Curves” methods (Curve.StartPoint, Curve.Length, etc) that we can find in dynamo nodes. I added all the possible and inimaginable “import …” at the beginning of my Python Script and I can use other Design Script Methods but not the ones I need. Does someone have a solution for that ?

Thank you for your time !

1 Like

Hi @ansobr ,
you just need :
import clr
from Autodesk.DesignScript.Geometry import *


Hello @Mostafa_El_Ayoubi, thank you for your answer !
But it’s already what I’m doing and in fact it works for a lot of methods (like Line.ByStartPointEndPoint) but it doesn’t work for curves methods like Curve.Length, Curve.StartPoint, Curve.EndPoint, … :confused:

It is possible that there are other functions called Length , StartPoint etc. in the other libraries you imported, resulting in the interpreter being incapable of knowing which function you’re calling (I may have not phrased that correctly, but I think it’s the general idea)

Ok maybe… But even if I specify Curve.Length(mycurve) ?
The error I get when I try to compile is “TypeError: getset_descriptor is not callable”

@Mostafa_El_Ayoubi is right, so in these cases you have to specify the reference assembly, namespace, class then the method. A good example is Plane.ByOriginNormal. To use in Python you have to declare the following otherwise it throws an exception:

pln = Autodesk.DesignScript.Geometry.Plane.ByOriginNormal( centreXYZ, Vector.ZAxis() )

Ok thank you !
I tried this but now I get an other error : NameError: name ‘Autodesk’ is not defined

If you’re importing ProtoGeometry then it should work. Post your code

Here is the beginning of my code, I take as input argument the curves representing the bases of my walls and I try to get the StartPoints in my Python Script

@Thomas_Mahon or @Mostafa_El_Ayoubi any ideas ? :slight_smile:

You cant replicate in a python script. You’ll need to loop through your list of curves item by item and perform your action:

startpoints = []
for crv in curves:
OUT = startpoints
1 Like

Ok thanks, it works ! Thank you for your time !