Hi guys… I’m trying to get the line direction through Python… But it doesn’t seem to work.
Any Tips?
Hello Ramoon,
Try this code out. It uses a List Comprehension to achieve the results in one line 
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
if not isinstance(IN[0], list):
IN[0] = [IN[0]]
direction = [ ln.Direction for ln in IN[0] ]
OUT = direction
The error message you were getting is due to the Direction being a property. As such, you cannot call it - i.e use parenthesis. Simply use the instance call on each line, which I called ln, and get the Direction property from that instance.
Using a loop, it would look like so:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
if not isinstance(IN[0], list):
IN[0] = [IN[0]]
direction = [ ]
for line in IN[0]:
ln = line.Direction
direction.append(ln)
OUT = direction
Thanks for your answer @solamour solved my problem.
Is there something i can use to get all properties associated to a given object?
thank you!
Hello Ramoon,
You can find all of the methods, actions and properties associated with a thing inside of python using the dir function.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
if not isinstance(IN[0], list):
IN[0] = [IN[0]]
# Note the double indexing here - because we make all items a list above
OUT = dir(IN[0][0])
In order to see the syntax associated with something, you can also call the ._ doc _ property.
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
if not isinstance(IN[0], list):
IN[0] = [IN[0]]
# Note the double indexing here - because we make all items a list above
OUT = IN[0][0].Trim.__doc__
THANK YOU!!! 


Here is a bookmark
You are most welcome 
Hello @Luiscko -
It depends on the kind of data you are putting into your Python node. As you can see in the screenshot below, if you simply put in a single surface (Note: Not in a list) it will work correcty:
If I wrap this surface in a list, you’ll notice that the Python node will Error out, albeit with a different error than you have 
So can you please take a screenshot showcasing the output of the data that is being fed into this node?
Is something like the second one, thank you very much, Now I understand why is not working before, is because of the complexity of the list even if was one element was inside in a list, so I need to be careful in the way how to feed the code.
I check with your consideration and now I am aware about that,
Inside of Python you need to handle Lists manually - Dynamo does this for you automagically 
So, you would be doing the following:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN #This 'IN' variable refers to ALL input ports of Python node
inputOne = IN[0] #This is all the data coming into the port of 'IN[0]' on the Python node
singleItem = Surface.PerimeterCurves(inputOne)
OUT = singleItem
If we have a single object coming in to that IN[0] input, then we need to index into it to remove the list and pull our chosen element out:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN #This 'IN' variable refers to ALL input ports of Python node
inputOne = IN[0] #This is all the data coming into the port of 'IN[0]' on the Python node
listItem = Surface.PerimeterCurves(inputOne[0])
OUT = listItem
This is achieved using the square brace notation [number] to pull out the object. In our case, it’s a single object, so we pull from the first (And only) index of zero (written as [0] in Python).
If we had multiple surfaces we wanted to pull the perimeter curves from, then we need to iterate over them, which takes the full list, then specifically runs a sequence of events over each item in that list:
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
dataEnteringNode = IN #This 'IN' variable refers to ALL input ports of Python node
inputOne = IN[0] #This is all the data coming into the port of 'IN[0]' on the Python node
results = [] #We create an empty list to catch our results
for element in inputOne: #Looping in a 'For Loop' over all things inside the inputOne list
crvs = Surface.PerimeterCurves(element) #For each thing, get their perimter curves
results.append(crvs) #Append (add to) the empty list called 'results' the curves
OUT = results #Push out the result
Thank you very much for your detail explanation I really appreciate so much your time to write this useful information
You are most welcome @Luiscko! Always happy to help where I can 