On 10/05/2012 6:38 AM, DANIEL POSE wrote:
I have read about Early Binding but I hadn't tested the line that you
reference:
acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application")

For my surprise, if I replace line:

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

for the line:

acad= win32com.client.gencache.EnsureDispatch("AutoCAD.Application")

I have an error about a missing attribute in the line:

M.append(objeto.InsertionPoint)

Once you use early-binding, the object becomes case sensitive where it usually wasn't before. So I suspect you wanted something like "insertionPoint" or some other difference in case.

The problem here is that if now I go back to use the line:

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

Now pywin32 brokes and I have always the same error in line:
M.append(objeto.InsertionPoint)

I need to reinstall pywin32 in order to repair the problem.

Yeah, this is unfortunate - once you've generated the early binding support, win32com.client.Dispatch will generally be able to use it. A work around without reinstalling would have been to delete the win32com\client\gen_py directory.

HTH,

Mark




2012/5/8 Tim Roberts <t...@probo.com <mailto:t...@probo.com>>

    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 <mailto:t...@probo.com>
    Providenza & Boekelheide, Inc.

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




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



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

Reply via email to