In Chapter 12 of Mark Hammond's book Python Programming on Win32, there is an
example DynamicPolicy.py which demonstrates how to implement a COM server that
exposes the entire Python string module. Can such a thing be done in comtypes?
If so, is there an example? Thanks!
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
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,
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
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
Thomas Heller [EMAIL PROTECTED] writes:
I finally found the bug - the arguments are passed as 'named' arguments by
Thomas, Thanks for the update!
-
This SF.Net email is sponsored by the Moblin Your Move Developer's
Anthony Tuininga [EMAIL PROTECTED] writes:
I've tried and app.ActiveDocument returns something but any attempt to
reference ModelSpace or anything else that looks like an object
doesn't appear to work.
What did you get for the ActiveDocument? Something like this?
POINTER(IAcadDocument)
Thomas,
Please see if the following snippet would be enough. Thanks.
Sampe to demonstrate how to use comtypes to automate AutoCAD: adding a point
, a line to the drawing; and attaching xdata of different types to them. The
objective
is to actually show how to create variants of different types
Mark McMahon [EMAIL PROTECTED] writes:
I would suggest trying a simple test with Word for example, automate AutoCAD
through the VBA in word - and see
if it is much faster than Python.
Thanks Mark!
I followed your suggestion. My limited tests show using VBA in Word to automate
AutoCAD is
Suraj Barkale [EMAIL PROTECTED] writes:
OK here is a longer version:
Array_of_2_VAR = comtypes.ARRAY(VARIANT, 2)
XData = Array_of_2_VAR(VARIANT('Test_Application'), VARIANT(600))
I hope this will create a true Array of variants. If this fails; only
Thomas would be able to help you.
10 matches
Mail list logo