Re: [comtypes-users] Problem with AutoCAD

2009-01-09 Thread Thomas Heller
Kelie schrieb: Thomas Heller thel...@... writes: Anyway, you should NOT use 'cast' with COM object pointers. Last, but not least, 'cast' doesn't handle the COM reference count correctly. Please use 'QueryInterface' with them, like so: block = obj.QueryInterface(ACAD.IAcadBlockReference)

Re: [comtypes-users] Problem with AutoCAD

2009-01-08 Thread Thomas Heller
Kelie schrieb: Ronan, There is a cast function. But the syntax isn't much shorter. import comtypes import comtypes.gen.AutoCAD as ACAD app = comtypes.client.GetActiveObject(AutoCAD.Application) obj = app.ActiveDocument.ModelSpace(1) #Assume this obj is a block block =

Re: [comtypes-users] Problem with AutoCAD

2009-01-08 Thread Thomas Heller
Ronan Paixão schrieb: Also, I'm had some problems with type coercion. In the VB examples, the variable types are declared before using, which coerce return types. The comtypes documentation is terrible and I didn't find anything to do similar. The problem is that ms.Item(number), where ms is

Re: [comtypes-users] Problem with AutoCAD

2009-01-08 Thread Kelie
Thomas Heller thel...@... writes: Anyway, you should NOT use 'cast' with COM object pointers. Last, but not least, 'cast' doesn't handle the COM reference count correctly. Please use 'QueryInterface' with them, like so: block = obj.QueryInterface(ACAD.IAcadBlockReference) Thanks

Re: [comtypes-users] Problem with AutoCAD

2009-01-06 Thread Ronan Paixão
Thanks a lot for your help! It certainly was crucial to kickstart my script. Specially since I didn't know I could send Lisp commands with SendCommand(). Here's what I'm doing: Em Seg, 2009-01-05 às 10:15 +, Kelie escreveu: Ronan, Thanks for taking time to explain what you're after.

Re: [comtypes-users] Problem with AutoCAD

2009-01-06 Thread Kelie
Ronan, There is a cast function. But the syntax isn't much shorter. import comtypes import comtypes.gen.AutoCAD as ACAD app = comtypes.client.GetActiveObject(AutoCAD.Application) obj = app.ActiveDocument.ModelSpace(1) #Assume this obj is a block block = comtypes.cast(obj,

Re: [comtypes-users] Problem with AutoCAD

2009-01-05 Thread Kelie
Ronan, Thanks for taking time to explain what you're after. Here is an ugly way of achieving what you're trying to do. If you know AutoLisp/VisualLisp, this would be quite easy to follow. I'm not aware that there is a COM/ActiveX function equivalent to the ssgetfirst function. HTH. import

Re: [comtypes-users] Problem with AutoCAD

2009-01-03 Thread Kelie
Ronan, I'm not sure what the answer is to your question. But I'm curious why you're trying to use Python to execute the measure command. Do you know any AutoLisp/VisualLisp or VBA? Both of them would be much easier to use in this case. What I'm finding is Python (win32com or comtypes) has its