Kelie schrieb: > Hello, > > I have this function in an event handler: > > def ObjectAdded(self, this, entity): > print "Object %s added in %s." % (str(entity), self.doc.Name) > print type(entity) > > and this is the output: > > Object VARIANT(vt=0x4009, byref(<POINTER(IAcadLine) ptr=0x28c7e4 at e8d3f0>)) > added in 04_C4-C10_PLANS.dwg. > <class 'comtypes.automation.tagVARIANT'> > > I have no idea what vt=0x4009 stands for here. My question is how do I access > the 2nd part of this VARIANT so I can get to the LINE object?
These changes have been done in comtypes 0.5, I had posted a preliminary description in the message 'What's going on in SVN' to this list a few days ago. EVERYONE using comtypes 0.5 should read this post, there will be / are some incompatible changes in comtypes 0.5; but I will also make another maintanance release of 0.4 for those that want to be compatible. The VARIANT __repr__ was changed recently to include the typecode in the output (for easier debugging). The typecode of 0x4009 is 'VT_BYREF | VT_DISPATCH', the codes are declared in the comtypes.automation module. These typecodes are defined by Windows, for more info you should look into the MSDN docs for the VARIANT and VARIANTARG type. The VT_BYREF part means that the VARIANT contains a variable that is passed by reference and not by value, so (in principle at least) you are able to modify the value to pass something to the object. You can get the actual contained value by indexing the entity with .[0], just as you would do with a pointer instance, and you can change the contained value in the same way. Something like this code should work: > def ObjectAdded(self, this, entity): > print "Object %s added in %s." % (str(entity), self.doc.Name) > print type(entity) print entity[0] entity[0] = something_else -- Thanks, Thomas ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ comtypes-users mailing list comtypes-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/comtypes-users