Can Not Instantiate User Object

Member Posts: 1 **

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

  • Member, Employee Posts: 385
    25 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited May 2024

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

    1. def oninit(self, Obj):
    2. pass
    3.  
    4. def onadd(self, Obj):
    5. pass
    6. def onremove(self, Obj):
    7. global ActObjDict
    8. del ActObjDict[self.ActObj.ObjectId]
    9.  
    10. def GetMechanicalObject(self):
    11. """
    12. """
    13. ExtAPI.DataModel.GetObjectById(self.ActObj.ObjectId)

Welcome!

It looks like you're new here. Sign in or register to get started.