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...

Thanks. 

"C:\Python25\pythonw.exe"  "C:\Python25\codes\autocad\temp\cast_test.py" 
Layer name: 0
Color: 256
Traceback (most recent call last):
  File "C:\Python25\codes\autocad\temp\cast_test.py", line 12, in <module>
    print block.InsertionPoint
WindowsError: exception: access violation reading 0x00000000




------------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It is the best place to buy or sell services for
just about anything Open Source.
http://p.sf.net/sfu/Xq1LFB
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to