Kelie schrieb:
> Hello,
> 
> I tried using comtypes to change the colors of all objects in the ModelSpace 
> of
> a drawing and got some interesting (at least to me) results. First of all, the
> speed of Python code is much slower than Autolisp/VisualLisp (a programming
> language built into AutoCAD) code. Second of all, I'm puzzled by the 
> significant
> differences among different Python methods. 
> 
> Python code:
> 
> import time
> import comtypes.client
> 
> app = comtypes.client.GetActiveObject("AutoCAD.Application")
> ms = app.ActiveDocument.ModelSpace
> 
> print "Starting 1st test..."
> timestart = time.clock()
> for i in xrange(ms.Count):
>     ms.Item(i).Color = 3
> timepassed = time.clock() - timestart
> print "Done. %.3f seconds passed." % timepassed

It might be faster to use this code; you sabe one COM call in the loop:


item = ms.Item
for i in xrange(ms.Count):
    item(i).Color = 3

Thomas


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to