pyautocad
pyautocad copied to clipboard
AddRegion - problem with array
Hi....first I'd like to thanks. This Python connection with AutoCAD is very usefull!!!
My goal is to create a solid.....but before the AddExtrudedSolid I need to create a Region (AddRegion).
The problem is to bulid the array correctly. The examle below is to draw a "L" shape....user must inform the width and tickness.
Thanks again,
Luciano
from pyautocad import * from array import * from math import radians
acad = Autocad() desenho = acad.model documento = acad.doc
aba = acad.doc.Utility.GetString(1,'Digite ABA da cantoneira: ') espessura = acad.doc.Utility.GetString(1,'Digite ESPESSURA da cantoneira: ')
insersao = acad.doc.Utility.GetPoint(APoint(0,0,0),'Pto de insercao: ') p1 = array('d', insersao)
p2 = acad.doc.Utility.PolarPoint(p1, radians(0), float(aba)) p3 = acad.doc.Utility.PolarPoint(array('d', p2), radians(90), float(espessura)) p4 = acad.doc.Utility.PolarPoint(array('d', p3), radians(180), float(aba)-float(espessura)) p5 = acad.doc.Utility.PolarPoint(array('d', p4), radians(90), float(aba)-float(espessura)) p6 = acad.doc.Utility.PolarPoint(array('d', p5), radians(180), float(espessura))
pontos = [p1[0] , p1[1], p2[0] , p2[1], p3[0] , p3[1], p4[0] , p4[1] ,p5[0] , p5[1] ,p6[0] , p6[1]] pontos_1 = array('d', pontos)
poli = desenho.AddLightweightPolyline(pontos_1) poli.Closed = 1
a = array('c',str(poli)) # first attempt
aa = numpy.array(poli, dtype='O') # second attempt
g = desenho.AddRegion(aa)
solido = poli.AddExtrudedSolid(g, 1000, 0)
I have the same issue. I've tried to rewrite simple example from documentation to Python:
from pyautocad import Autocad, APoint
acad = Autocad()
arc = acad.model.AddArc(APoint(5, 3, 0), 2.0, 0, 3.141592)
curves = [arc, acad.model.AddLine(APoint(arc.StartPoint), APoint(arc.EndPoint))]
region = acad.model.AddRegion(curves)
but I'm getting the same error: _ctypes.COMError: (-2145320837, None, ... (Invalid array of objects)
Still looking for how to pass array of objects to Autocad correctly.
Ok. Thanks....I´ll keep looking for a solution and then post here!
sadly, this problem is not resolved till today... god help me!
Anyone has the solution?