def members(self, flatten=False): # type: (bool) -> List[DependNode] result = [] # type: List[DependNode] selection = self.mfn.getMembers(flatten) tmp_mfn = _om2.MFnDependencyNode() tmp_mfn_comp = _om2.MFnComponent() for i in range(selection.length()): try: # component mdagpath, mobj = selection.getComponent(i) tmp_mfn_comp.setObject(mobj) comp = _graphs.to_comp_instance(tmp_mfn_comp, mdagpath, mobj) result.append(comp) except RuntimeError: # node mobj = selection.getDependNode(i) tmp_mfn.setObject(mobj) mdagpath = None if mobj.hasFn(_om2.MFn.kDagNode): mdagpath = selection.getDagPath(i) node = _graphs.to_node_instance(tmp_mfn, mdagpath) result.append(node) return result
def eval(obj_name): # type: (Union[str, Iterable[str]]) -> Any tmp_mfn_comp = _om2.MFnComponent() tmp_mfn_node = _om2.MFnDependencyNode() if isinstance(obj_name, (str, text_type)): return _graphs.eval(obj_name, tmp_mfn_comp, tmp_mfn_node) else: return [_graphs.eval(name, tmp_mfn_comp, tmp_mfn_node) for name in obj_name]
def create(cls, dagpath, comptype=None): comptype = comptype or cls._mtype if isinstance(dagpath, basestring): dagpath = api.MSelectionList().add(dagpath).getDagPath(0) indexed = cls._indexed_class() indexed = indexed.create(comptype) cfn = api.MFnComponent(indexed) cfn.setObject(dagpath.node()) return cls(dagpath, indexed)
def eval_component(comp_name): # type: (str) -> 'Component' tmp_mfn = _om2.MFnComponent() return _graphs.eval_component(comp_name, tmp_mfn)