Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-07 Thread Kelie
Kelie <[EMAIL PROTECTED]> writes:
> Thomas, Sorry I didn't get a chance to try what you suggested. I'll do that
> Monday. Thanks.
> 

Thomas, I just installed the lastest svn version and seems the problem has been
fixed.
Thank you!

>>> import comtypes.client
>>> comtypes.client.CreateObject("AutoCAD.Application")
# Generating comtypes.gen._851A4561_F4EC_4631_9B0C_E7DC407512C9_0_1_0
# Generating comtypes.gen._00020430___C000_0046_0_2_0
# Generating comtypes.gen.stdole
# Generating comtypes.gen.AutoCAD





-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-05 Thread Kelie
Thomas Heller <[EMAIL PROTECTED]> writes:

> In comtypes 0.4.1, safearrays containing com pointers are not implemented.
> They are, though, in the current SVN version.  I wanted to release the next
version
> after another MicroStation bug was examined, but the OP did not yet respond to
> my question.

Thomas, Sorry I didn't get a chance to try what you suggested. I'll do that
Monday. Thanks.




-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-04 Thread Kelie
Thomas Heller <[EMAIL PROTECTED]> writes:
> Hm, is this a bug in Autocad, or is comtypes behaving wrong here; does this
> error code mean we have to wait a little and retry the call?  How do other
> COM clients, like VB or pywin32, behave?
> 

Thomas, pywin32 does not have such as problem. I can launch AutoCAD with: 

import win32com.client
acadApp = win32com.client.Dispatch("AutoCAD.Application")

Btw, AutoCAD has built-in VBA support.


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-04 Thread Thomas Heller
Ed Blake schrieb:
> I just tested under comtypes 0.3 and 0.4 with Autocad 2008.  I get this
> exception for both when using CreateObject:
> ##
 acad = client.CreateObject("AutoCAD.Application")
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 203,
> in CreateObject
> return _manage(obj, clsid, interface=interface)
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
> in _manage
> obj = wrap(obj)
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 122,
> in wrap
> typeattr = tinfo.GetTypeAttr()
>   File "D:\Python25\Lib\site-packages\comtypes\typeinfo.py", line 262, in
> GetTypeAttr
> return _deref_with_release(self._GetTypeAttr(), self.ReleaseTypeAttr)
> COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0,
> None))
> ##
> 
> I think this happens because comtypes is trying to talk to Autocad before it
> is finished its post startup initialization (loading modules, CUI, lisp
> files).

Hm, is this a bug in Autocad, or is comtypes behaving wrong here; does this
error code mean we have to wait a little and retry the call?  How do other
COM clients, like VB or pywin32, behave?

> Using client.GetActiveObject on the other hand successfully generates the
> Autocad modules and returns a pointer to the first running instance.  It
> doesn't work if Autocad isn't running though.
> 
> BTW Thomas: I had to switch back to version 0.3.3 because something broke
> between that version and the current.

With this remark I assume you mean the code below, right?

>  When I try to get a pointer to
> Microstation under 0.4.1 I get this:
> ##
 usta = client.GetActiveObject("MicroStationDGN.Application")
> # Generating comtypes.gen._CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 166,
> in GetActiveObject
> return _manage(obj, clsid, interface=interface)
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
> in _manage
> obj = wrap(obj)
>   File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 134,
> in wrap
> mod = GetModule(tlib)
>   File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
> 100, in GetModule
> is_current, mod = _CreateWrapper(tlib, pathname)
>   File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
> 218, in _CreateWrapper
> mod = _my_import(fullname)
>   File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line 14,
> in _my_import
> return __import__(fullname, globals(), locals(), ['DUMMY'])
>   File
> "D:\Python25\lib\site-packages\comtypes\gen\_CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0.py",
> line 223, in 
> ( ['retval', 'out'], POINTER(_midlSAFEARRAY(POINTER(_DataBlock))), 'pVal'
> )),
>   File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 18, in
> _midlSAFEARRAY
> sa_type = _make_safearray_type(itemtype)
>   File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 46, in
> _make_safearray_type
> raise TypeError(itemtype)
> TypeError: 
> ##
> 
> Something to do with the safearray refactor?

In comtypes 0.4.1, safearrays containing com pointers are not implemented.
They are, though, in the current SVN version.  I wanted to release the next 
version
after another MicroStation bug was examined, but the OP did not yet respond to
my question.  Maybe you can help; or I should release anyway?  See
http://sourceforge.net/tracker/index.php?func=detail&aid=1919272&group_id=115265&atid=692940

Thomas


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-04 Thread Ed Blake
I just tested under comtypes 0.3 and 0.4 with Autocad 2008.  I get this
exception for both when using CreateObject:
##
>>> acad = client.CreateObject("AutoCAD.Application")
Traceback (most recent call last):
  File "", line 1, in 
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 203,
in CreateObject
return _manage(obj, clsid, interface=interface)
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
in _manage
obj = wrap(obj)
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 122,
in wrap
typeattr = tinfo.GetTypeAttr()
  File "D:\Python25\Lib\site-packages\comtypes\typeinfo.py", line 262, in
GetTypeAttr
return _deref_with_release(self._GetTypeAttr(), self.ReleaseTypeAttr)
COMError: (-2147418111, 'Call was rejected by callee.', (None, None, None, 0,
None))
##

I think this happens because comtypes is trying to talk to Autocad before it
is finished its post startup initialization (loading modules, CUI, lisp
files).

Using client.GetActiveObject on the other hand successfully generates the
Autocad modules and returns a pointer to the first running instance.  It
doesn't work if Autocad isn't running though.

BTW Thomas: I had to switch back to version 0.3.3 because something broke
between that version and the current.  When I try to get a pointer to
Microstation under 0.4.1 I get this:
##
>>> usta = client.GetActiveObject("MicroStationDGN.Application")
# Generating comtypes.gen._CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0
Traceback (most recent call last):
  File "", line 1, in 
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 166,
in GetActiveObject
return _manage(obj, clsid, interface=interface)
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 171,
in _manage
obj = wrap(obj)
  File "D:\Python25\Lib\site-packages\comtypes\client\__init__.py", line 134,
in wrap
mod = GetModule(tlib)
  File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
100, in GetModule
is_current, mod = _CreateWrapper(tlib, pathname)
  File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line
218, in _CreateWrapper
mod = _my_import(fullname)
  File "D:\Python25\lib\site-packages\comtypes\client\_generate.py", line 14,
in _my_import
return __import__(fullname, globals(), locals(), ['DUMMY'])
  File
"D:\Python25\lib\site-packages\comtypes\gen\_CF9F97BF_39F2_4B8E_835C_8BE9E99DAF5B_0_8_0.py",
line 223, in 
( ['retval', 'out'], POINTER(_midlSAFEARRAY(POINTER(_DataBlock))), 'pVal'
)),
  File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 18, in
_midlSAFEARRAY
sa_type = _make_safearray_type(itemtype)
  File "D:\Python25\Lib\site-packages\comtypes\safearray.py", line 46, in
_make_safearray_type
raise TypeError(itemtype)
TypeError: 
##

Something to do with the safearray refactor?

Ed Blake
--- Thomas Heller <[EMAIL PROTECTED]> wrote:

> Kelie schrieb:
> > Hello group,
> > 
> > I'm getting an error when trying to launch AutoCAD using comtypes.  The
> > application does get started. But the variable 'app' does not seem to
> hold a
> > valid instance of it, because I was not able to access its properties
> such as
> > ActiveDocument, WindowState, etc..
> > 
> > This is copied from Python shell:
> > 
>  import comtypes
>  comtypes.__version__
> > '0.4.2'
>  app = comtypes.client.CreateObject("AutoCAD.Application")
> > # Generating comtypes.gen.AutoCAD
> > Traceback (most recent call last):
> >   File "", line 1, in 
> >   File
> "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> > line 202, in CreateObject
> > return _manage(obj, clsid, interface=interface)
> >   File
> "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> > line 170, in _manage
> > obj = GetBestInterface(obj)
> >   File
> "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> > line 133, in GetBestInterface
> > interface = getattr(mod, itf_name)
> > AttributeError: 'module' object has no attribute 'IAcadApplication'
> > 
> > Any idea why?
> 
> Hm, the exception seems to be raised when the module is generated.  Please
> look
> into the comtypes\gen directory, do you find a (valid) AutoCAD.py file, and
> the file
> that is imported by AutoCad.py?
> 
> If so, can you please look into the latter if there is a 'IAcadApplication'
> interface
> defined?
> 
> If not, you should probably set a breakpoint on line 132 in
> comtypes\client\__init__.py,
> and inspect the generated module (which has not yet been written to disk). 
> Or put a line
>   print dir(mod)
> must before line 133 in this file.  This should provide some insight.
> 
> Th

Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-04 Thread Thomas Heller
Kelie schrieb:
> Hello group,
> 
> I'm getting an error when trying to launch AutoCAD using comtypes.  The
> application does get started. But the variable 'app' does not seem to hold a
> valid instance of it, because I was not able to access its properties such as
> ActiveDocument, WindowState, etc..
> 
> This is copied from Python shell:
> 
 import comtypes
 comtypes.__version__
> '0.4.2'
 app = comtypes.client.CreateObject("AutoCAD.Application")
> # Generating comtypes.gen.AutoCAD
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 202, in CreateObject
> return _manage(obj, clsid, interface=interface)
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 170, in _manage
> obj = GetBestInterface(obj)
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 133, in GetBestInterface
> interface = getattr(mod, itf_name)
> AttributeError: 'module' object has no attribute 'IAcadApplication'
> 
> Any idea why?

Hm, the exception seems to be raised when the module is generated.  Please look
into the comtypes\gen directory, do you find a (valid) AutoCAD.py file, and the 
file
that is imported by AutoCad.py?

If so, can you please look into the latter if there is a 'IAcadApplication' 
interface
defined?

If not, you should probably set a breakpoint on line 132 in 
comtypes\client\__init__.py,
and inspect the generated module (which has not yet been written to disk).  Or 
put a line
  print dir(mod)
must before line 133 in this file.  This should provide some insight.

Thomas


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-03 Thread Kelie
Thomas Heller <[EMAIL PROTECTED]> writes:
> You should remove *all* the files in the comtyes\gen directory and try again.

Thanks Thomas. That didn't work. When I said "I didn't used to get this error",
I forgot to mention that I was using a different computer too.





-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


Re: [comtypes-users] problem using comtypes with AutoCAD

2008-04-03 Thread Thomas Heller
Kelie schrieb:
> Hello group,
> 
> I'm getting an error when trying to launch AutoCAD using comtypes.  The
> application does get started. But the variable 'app' does not seem to hold a
> valid instance of it, because I was not able to access its properties such as
> ActiveDocument, WindowState, etc..
> 
> This is copied from Python shell:
> 
 import comtypes
 comtypes.__version__
> '0.4.2'
 app = comtypes.client.CreateObject("AutoCAD.Application")
> # Generating comtypes.gen.AutoCAD
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 202, in CreateObject
> return _manage(obj, clsid, interface=interface)
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 170, in _manage
> obj = GetBestInterface(obj)
>   File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
> line 133, in GetBestInterface
> interface = getattr(mod, itf_name)
> AttributeError: 'module' object has no attribute 'IAcadApplication'
> 
> Any idea why?
> 
> (btw, if I remember correctly, I didn't used to get this error. But I was 
> using
> an earlier version comtypes and an earlier version of AutoCAD.)

You should remove *all* the files in the comtyes\gen directory and try again.

Thomas


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users


[comtypes-users] problem using comtypes with AutoCAD

2008-04-03 Thread Kelie
Hello group,

I'm getting an error when trying to launch AutoCAD using comtypes.  The
application does get started. But the variable 'app' does not seem to hold a
valid instance of it, because I was not able to access its properties such as
ActiveDocument, WindowState, etc..

This is copied from Python shell:

>>> import comtypes
>>> comtypes.__version__
'0.4.2'
>>> app = comtypes.client.CreateObject("AutoCAD.Application")
# Generating comtypes.gen.AutoCAD
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
line 202, in CreateObject
return _manage(obj, clsid, interface=interface)
  File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
line 170, in _manage
obj = GetBestInterface(obj)
  File "C:\Programming\Python\Install\comtypes\comtypes\client\__init__.py",
line 133, in GetBestInterface
interface = getattr(mod, itf_name)
AttributeError: 'module' object has no attribute 'IAcadApplication'

Any idea why?

(btw, if I remember correctly, I didn't used to get this error. But I was using
an earlier version comtypes and an earlier version of AutoCAD.)

Thanks.

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users