Python - Get Line From List (Line,Arc,...)

Hi guys. I just started learning Python scripts. May I ask is there a way to get the ine in the list using python script ? Hope everyone can help. Thanks for support…!

Help me

I’ve just start to learn python as well, but yes, you can do that using the ‘isinstance’ function to check if the input values are Lines or not.

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

result = []

for item in IN[0]:
	if isinstance(item,Line):
		result.append(item)
OUT = result

#You can check out the instance funcion here:
#https://www.w3schools.com/python/ref_func_isinstance.asp

3 Likes

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

# The inputs to this node will be stored as a list in the IN variables.
listA = IN[0]
if isinstance(listA, list):
	listA = UnwrapElement(listA)
else:
	listA = UnwrapElement([listA])
curve = []
for i in listA:
	if i.GetType().ToString() == "Autodesk.DesignScript.Geometry.Line":
		curve.append(i)	
OUT = curve 

Thanks You…! :heart_eyes: :heart_eyes: