Hello,

I am writing code to program AutoCAD access from Python using pywin32. When
I need to work with a high number of AutoCAD objects, it is faster to use
vba than python.
Are there some way to speed up python code in order to work faster with
AutoCAD elements?
For example in the next code when I work with 512 AutoCAD blocks:

import win32com.client

import time

t1=time.clock()

acad= win32com.client.Dispatch("AutoCAD.Application")

doc = acad.ActiveDocument

seleccion=doc.SelectionSets.Add('selection6')

seleccion.SelectOnScreen()

t2=time.clock()

M=[]

for objeto in seleccion:

if objeto.ObjectName=='AcDbBlockReference':

M.append(objeto.InsertionPoint)

t3=time.clock()

print 'M_dimension=',len(M)

R=[]

for m in M:

for x in M:

R.append(max(m)+max(x))

print 'R_dimension=',len(R)

t4=time.clock()

t_block1=t2-t1

t_block2=t3-t2

t_block3=t4-t3

print 't_block1=',t_block1

print 't_block2=',t_block2

print 't_block3=',t_block3


The output for the code is the following:

M_dimension= 512
R_dimension= 262144
t_block1= 4.25343304805
t_block2= 3.88635510938
t_block3= 0.487477319045


Then it is faster to work with R than M, even though R is bigger.

Some suggestions for speed up pywin32 code in this example?


Best Regards,

Daniel Pose.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to