Sorry!!! my mistake!!! really there are a speed up, the timing using late-binding is:<div><div>M_dimension= 512</div><div>R_dimension= 262144</div><div>t_block1= 3.00059867944</div><div>t_block2= 12.2370913063</div><div>t_block3= 0.488927223991</div>
<div>t_total= 15.7266172097</div></div><div><br></div><div>Then it is about half time using early-binding for my example. It is wonderfull!!</div><div><br><div><br><br><div class="gmail_quote">2012/5/13 DANIEL POSE <span dir="ltr">&lt;<a href="mailto:iinjdpa@gmail.com" target="_blank">iinjdpa@gmail.com</a>&gt;</span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Just for conclude the discusion, the solution is win32.client.CastTo() as Mark said. However, this modification doesn&#39;t speed up the code (at least in my case).<div>
Then, perhaps I need to learn C++ in order to embed python inside AutoCAD as Dan Glassman said. But, not now...</div>
<div>Here I post the code using CastTo:</div><div><br></div><div>&lt;code&gt;</div><div><br></div><div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">import win32com.client</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">import time</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">import string</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">import random</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">def nombrealeatorio(size=10, chars=string.ascii_uppercase + string.digits):</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    &#39;&#39;&#39;Esta función crea un nombre aleatorio de 10 caracteres&#39;&#39;&#39;</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    return &#39;&#39;.join(random.choice(chars) for x in range(size))</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t1=time.clock()</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">acad= win32com.client.gencache.EnsureDispatch(&quot;AutoCAD.Application&quot;)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">doc=win32com.client.CastTo(acad,&quot;IAcadApplication&quot;)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">doc = acad.ActiveDocument</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">seleccion=win32com.client.CastTo(doc,&quot;IAcadSelectionSets&quot;)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">seleccion=doc.SelectionSets.Add(nombrealeatorio())</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">seleccion=win32com.client.CastTo(seleccion,&quot;IAcadSelectionSet&quot;)</p><div class="im">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">seleccion.SelectOnScreen()</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t2=time.clock()</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">M=[]</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">for objeto in seleccion:</p>
</div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    objeto=win32com.client.CastTo(objeto, &quot;IAcadBlockReference&quot;)</p><div class="im">
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    if objeto.ObjectName==&#39;AcDbBlockReference&#39;:        </p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">        M.append(objeto.InsertionPoint)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t3=time.clock()</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;M_dimension=&#39;,len(M)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">R=[]</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">for m in M:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">    for x in M:</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">        R.append(max(m)+max(x))</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;R_dimension=&#39;,len(R)</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t4=time.clock()</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block1=t2-t1</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block2=t3-t2</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block3=t4-t3</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;t_block1=&#39;,t_block1</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;t_block2=&#39;,t_block2</p>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;t_block3=&#39;,t_block3</p>
</div><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">print &#39;t_total=&#39;,t4-t1</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

&lt;/code&gt;</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">timing using early-binding:</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">M_dimension= 512</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">R_dimension= 262144</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

t_block1= 3.46952811042</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block2= 4.81084020455</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block3= 0.49030086226</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_total= 8.77066917723</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"><br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

timing using late-binding:</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px"></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">M_dimension= 512</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

R_dimension= 262144</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block1= 3.20033803179</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block2= 4.96431445896</p>

<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_block3= 0.570101227949</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">t_total= 8.7347537187</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">Thank you for this wonderfull mailing list and pywin32.</p><div><div class="h5"><p></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px">

<br></p><p></p><div class="gmail_quote">2012/5/13 Mark Hammond <span dir="ltr">&lt;<a href="mailto:mhammond@skippinet.com.au" target="_blank">mhammond@skippinet.com.au</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>On 13/05/2012 5:00 AM, DANIEL POSE wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I had tried to change attribute name in several ways (InsertionPoint,<br>
insertionPoint, insertionpoint,...) but I obtained the same error:<br>
<br>
Traceback (most recent call last):<br>
   File &quot;&lt;ipython console&gt;&quot;, line 1, in &lt;module&gt;<br>
   File<br>
&quot;C:\Python27\lib\site-<u></u>packages\spyderlib\widgets\<u></u>externalshell\startup.py&quot;,<br>
line 128, in runfile<br>
     execfile(filename, glbs)<br>
   File &quot;C:\Documents and Settings\Usuario\Mis<br>
documentos\Dropbox\PYTHON\<u></u>PruebaAutoCAD.py&quot;, line 29, in &lt;module&gt;<br>
     M.append(objeto.<u></u>insertionpoint)<br>
   File &quot;C:\Python27\lib\site-<u></u>packages\win32com\client\__<u></u>init__.py&quot;,<br>
line 465, in __getattr__<br>
     raise AttributeError(&quot;&#39;%s&#39; object has no attribute &#39;%s&#39;&quot; %<br>
(repr(self), attr))<br>
AttributeError: &#39;&lt;win32com.gen_py.AutoCAD 2008 Type Library.IAcadEntity<br>
instance at 0x88940672&gt;&#39; object has no attribute &#39;insertionpoint&#39;<br>
</blockquote>
<br></div>
In the gen_py directory you should find a generated file supporting the AutoCAD object - it will have a GUID in its name so it might not be obvious which one applies, but inside that you should find the &#39;IAcadEntity&#39; object.  That should have a _prop_map_get attribute which lists the attributes available on the object - I&#39;d expect to find insertionPoint listed there.  It may turn out it is actually on a different object, in which case the win32com.client.CastTo() function might be useful to get the appropriate interface.<div>

<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
If I delete only the win32com\client\gen_py  folder It doesn&#39;t work. I<br>
need delete for example win32com and win32 folders and restore older ones.<br>
</blockquote>
<br></div>
Hrm - I certainly can&#39;t explain that!  Or maybe I can - check your %TEMP% folder and see if there is a gen_py directory there?<span><font color="#888888"><br>
<br>
Mark<br>
</font></span></blockquote></div><br></div></div></div>
</blockquote></div><br></div></div>