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. Please use 'QueryInterface' with them, like so: block = obj.QueryInterface(ACAD.IAcadBlockReference) Thomas ------------------------------------------------------------------------------ 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