Dynamo python Export polyline to AutoCAD

Hello @gabdelmo
here is the corrected python code
the argument of AddPolyline function must be a Array not a list of multiple Array (note the extend function instead of append)
https://help.autodesk.com/view/OARX/2018/ENU/?guid=GUID-ED02917C-D1D6-46B8-95C6-736163C31362

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
from math import *
import System
from System import Array

# The inputs to this node will be stored as a list in the IN variables.
#rtn = None
MyVar = IN[1]
rtn = None

# Place your code below this line
def _VLOPoint(pt):
	return Array[float]([pt.X, pt.Y, pt.Z])

def _Core(abc):
	if isinstance(abc, Polygon):
		MyList = []
		for i in abc.Points:
			MyList.extend([i.X, i.Y, i.Z])
		lstvertex = Array[float](MyList)	
		poly = SPACE.AddPolyline(lstvertex)
		poly.Closed = True
	return poly

if IN[0] == True:
	try:
		CAD = System.Runtime.InteropServices.Marshal.GetActiveObject("Autocad.Application").ActiveDocument
		
		if CAD.ActiveSpace == 1:
			SPACE = CAD.ModelSpace
		else:
			SPACE = CAD.PaperSpace
			
		rtn = _Core(MyVar)
	except Exception, e:
		rtn = e
# Assign your output to the OUT variable.
OUT = rtn
1 Like