> > 1.but if I run > dagFn = om.MFnDagNode(MObject) > > if will have error like: > RuntimeError: (kInvalidParameter): Object is incompatible with this > method # > > is this because the MFnDagNode is for MObject handle pointing to a dag > node instead of a component? >
Yup, you got it. The component MObject doesn't have any information about nodes, or dag paths, etc. It's essentially little more than a set of indices (in most cases, anyway - there's actually a large variety of different component types, some of which hide a bunch of information we can't access). This means, for instance, you could use the same component object to refer to vertices on two different meshes, if you wanted to reference the same set of vertices on both meshes. > 2. also,dose the components, such as poly face or poly edge has any > bounding box? > If it dosen't, I want to get all the points position on that poly > face, and do some simple math, so how can get these positions? > I don't know of any easy built in method that will give you a bounding box if you have a dag path and an component mobj; As Brandon pointed out, though the best way to get the point positions is to use one of the MIt* classes. You could always feed those values into an MBoundingBox object as you go... > 3. After some conditions, I want to return the component MObject's > string name,but > > dagPath.fullPathName() > will return : # Result: |pCube1|pCubeShape1 # > > how can i get the original 'pCubeShape1.f[0]' instead? > The fullPathName gives that because, just like the component mobject has no information about dag paths or nodes, the dagPath has no information about components. You need both to "completely specify" an exact component. If you want a string to a given component, the easiest way I know is to just use an MSelectionList: # Do some stuff to get myDagPath and myComponentMobj sel = MSelectionList() sel.add(myDagPath, myComponentMobj) compNames = [] sel.getSelectionStrings(0, compNames) Note that you need an array of strings, even though you're only grabbing the first item in the selection list, because a single component mobj may need to be represented as several strings - ie, myComponentMobj => f[0], f[3:7], f[10] - Paul -- http://groups.google.com/group/python_inside_maya
