Can Not Instantiate User Object
I have created a user class that I would like to implement to drive ACT extension behavior. I have written some XML to insert a generic DataModelObject into the tree and given a class="MyClassName" attribute in the object tag for the xml definition. When I insert an object of my user defined type in the tree I get the following outputs to my ACT log:
Unable to instanciate object from class 'GenericClassName'.
'ObjectDictionaryExpando' object has no attribute 'GenericClassName'
MissingMemberException
at CallSite.Target(Closure , CallSite , Object )
at IronPython.Runtime.PythonContext.ScopeGetVariable(Scope scope, String name)
at Ansys.ACT.Core.Extension.CreateObjectController(String className, Object[] args)
I am not sure what the issue is here, I have files in the extension directory that define the class behavior and have included them using the .
I am also wondering how the underlying user object is associated to the corresponding DataModelObject that exists in the tree. I need the userobject to take data provided by the user in the properties of the DataModelObject that represents the userobject in the tree.
Answers
-
You can use something like this to start.
ActObjDict = {}
class ActObjClass:
def init(self, ExtAPI, ActObj):
global ActObjDict
self.ActObj = ActObj
self.ExtAPI = ExtAPI
ActObjDict[self.ActObj.ObjectId] = self.ActObjdef oninit(self, Obj): pass def onadd(self, Obj): pass def onremove(self, Obj): global ActObjDict del ActObjDict[self.ActObj.ObjectId] def GetMechanicalObject(self): """ """ ExtAPI.DataModel.GetObjectById(self.ActObj.ObjectId)
0