That MSelectionList.merge() actually sounds like what I'm going for. Will that work with multiple component types? (ie. edges and vertices)
On Dec 8, 4:07 pm, Paul Molodowitch <[email protected]> wrote: > Hmm... well, not entirely certain what exactly you're trying to accomplish. > Do you mean you'd like a single component MObject, which holds ALL of the > selected components on that object? Ie, something that would hold the > selected vertices, AND edges, AND uvs, etc? > > If so, that's not possible. Component MObjects are hardwired to only > contain information about only one type of component. > > However, your comment about 'grabbing all the component indices and going > back through and rebuilding the selectionList' makes me think I'm just not > understanding what your end goal here is. Are you trying to, say, build an > 'aggregate selection' from multiple MSelectionList objects? In that case, > the best strategy might be to just use MSelectionList.merge()... > > - Paul > > On Tue, Dec 8, 2009 at 1:15 PM, Brandon Harris <[email protected]> wrote: > > ok, Issue now is with how to work around this particular limitation. > > If Iter over the selection list and grab the component data. Is there > > a way (without converting the component MObject into indexes) to add > > the component data together on objects that are the same. This is > > mainly to account for multiple component type selections on multiple > > objects. > > > import maya.OpenMaya as openMaya > > import maya.OpenMayaAnim as openAnim > > > #first thing is to find out how many objects we're selecting. > > > selection = openMaya.MSelectionList() > > openMaya.MGlobal.getActiveSelectionList(selection) > > > selectionItr = openMaya.MItSelectionList(selection) > > objects = {} > > while not selectionItr.isDone(): > > tmpObject = openMaya.MObject() > > tmpPath = openMaya.MDagPath() > > selectionItr.getDagPath(tmpPath,tmpObject) > > > object[tmpPath.fullPathName()] = tmpObject > > > selectionItr.next() > > > so here I have it use the dagPath as a key so that later I can add > > other components from the same mesh to it. The issue is that, as far > > as I know, there isn't a way of adding all of the components together > > as MObjects. Is there a way of doing it without going through the > > process of determining mesh type, grabbing all the component indices > > and going back through and rebuilding the selectionList? > > > Brandon L. Harris > > > On Dec 3, 2:14 pm, Ling <[email protected]> wrote: > > > You guys are SSSSOOOOOOOOOOOO awesome! > > > > I got it works with your tips.. thanks a lot guys! > > > > On Dec 2, 7:21 am, Paul Molodowitch <[email protected]> wrote: > > > > > > 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 > > -- http://groups.google.com/group/python_inside_maya
