Get list of points from DWG selection

#1

I have selected an imported DWG, it returns a list with Points and PolyCurves as following:

Now I want to retrieve only the Points, I achieved the following:

The Code Block warning says "Asked to convert non-convertible types’ which is understandable because there PolyCurves in my list, but it works and returns the values for the point. With Python I can filter out the null values. Only this seems like a very tedious and long-winded solution.

Instead I want to enter my Element.Geometry list straight into Python and filter out the PolyCurves there. Something like this:

python

But what I can’t find/understand is how to get the type values from the list. I just want to compare if every Nth item in the list is a PolyCurve or Point.

#2

Hi @Claus,

You can do like this in python :

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

items = UnwrapElement(IN[0])
points=[]
for item in items:
	if isinstance(item, geom.Point):
		points.append(item)

OUT = points

Or with the List.RemoveIfNot node :

3 Likes