DANIEL POSE wrote:
> 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:
> ...
>
> 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.
>

I hope that's not a surprise to you.  The first loop (block2) involves
two calls into the AutoCAD COM object in each iteration.  The second
loop (block3) is simply manipulating lists of integers, entirely within
Python.

> Some suggestions for speed up pywin32 code in this example?
>

There isn't really anything here to speed up.  You're just "glue".  The
work is being done in AutoCAD.  It is almost impossible for me to
believe that Visual Basic does this same loop any faster.

However, you can certainly try switching to early binding by using:
    acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application")

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

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

Reply via email to