8 Jan 2009 18:54
Re: Problem with AutoCAD
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 = comtypes.cast(obj, comtypes.POINTER(ACAD.IAcadBlockReference))
> # I hope this would work
> # block = comtypes.cast(obj, ACAD.IAcadBlockReference)
>
> print "Layer name: %s" % block.Layer
> print "Color: %d" % block.Color
> print block.InsertionPoint
> print block.XScaleFactor
>
> But I'm getting error when trying to access various block properties. See output
> below. Apparently it was OK to access the "Layer" and "Color" properties. Don't
> know why. Waiting for Thomas...
I haven't followed this thread so I do not really know what
all this is about.
Anyway, you should NOT use 'cast' with COM object pointers. Last,
but not least, 'cast' doesn't handle the COM reference count correctly.
(Continue reading)
RSS Feed