def addAttribute_(self, name, value): p = nm.tree_createnode(self.__nodep, NODE_ATTRIBUTE, name) self.__nodeattributes[name.lower()] = Tree(p) if type(value) == type(np.array([])): nm.tree_setvalue(p, value.tolist()) elif value is not None: err = nm.tree_setvalue(p, value)
def addElement_(self, name, value=None): if name.lower() not in self.__nodechildren: self.__nodechildren[name.lower()] = TreeList([]) p = nm.tree_createnode(self.__nodep, NODE_ELEMENT, name) self.__nodechildren[name.lower()].append(Tree(p)) if type(value) == type(np.array([])): nm.tree_setvalue(p, value.tolist()) elif value is not None: nm.tree_setvalue(p, value)
def __setattr__(self, name, value): if name == "x_": # Update object in neuromechanic memory if type(value) == type(np.array([])): nm.tree_setvalue(self._Tree__nodep, value.tolist()) else: nm.tree_setvalue(self._Tree__nodep, value) else: # default setattr super().__setattr__(name, value)