Python introspection... 2005-06-10 - By Bernard Lebel
Back Sorry, see below...
On 6/10/05, Bernard Lebel <3dbernard@(protected)> wrote: > Hello, > > Is there an easier way to check if an object has, for example, the > "LocalProperties" attribute, other than by going through such a chunk > of code? > > Right now I have this: > > xsi = Application > > oObject = xsi.selection(0) > > # Iterate object attributes > for i in xrange( 0, oObject._oleobj_.GetTypeInfoCount() ): > > typeInfo = xsi.selection(0)._oleobj_.GetTypeInfo( i ) > typeAttr = typeInfo.GetTypeAttr() > > # Iterate "functions" of object > for iFunction in xrange( 0, typeAttr.cFuncs ): > > functionDescription = typeInfo.GetFuncDesc( iFunction ) > > # Get name of function (even if function is actually a property) > sName = typeInfo.GetNames( functionDescription.memid )[0] > > if sName == 'LocalProperties': xsi.logmessage( 'yeah!' ) > > > I have tried simpler approches, like > > if not oObject.localproperties: xsi.logmessage( 'no' ) > > But I get an attribute error (<unknown>.localproperties)
[Bernard] It should have been: I get this error if I have, for instance, the primitive of an object selected.
Sorry! Bernard
--- Unsubscribe? Mail Majordomo@(protected) with the following text in body: unsubscribe xsi
|
|