are you just trying to select the shells(islands) based on selected components or check if selected components are in the same shell?
On Thu, Sep 18, 2014 at 5:03 PM, Geordie Martinez <[email protected] > wrote: > here is some code I use for doing that. It could be written better, but I > was young. I needed the money. It has some code smell, but I dont' have > time to improve it. > > import pymel.core as pmdef tfmAtCentroid(vertSel=None, tfmSel=None, > locator=True, name=None): > """ select verts and joints. snaps a joint to the centroid position of > selected verts. """ > # SELECTED VERTS AND JOINTS > > verts = vertSel or [] > tfms = tfmSel or [] > sel = pm.selected() > > returnList=[] > > # NOTHING PASSED IN OR SELECTED > if not vertSel and not tfmSel and not sel: > return > > # IF NO ARGS PASSED IN GET SELECTED > if sel: > for item in sel: > # SORT THE SELECTION > if item.__class__.__name__ == "MeshVertex": > verts.append(item) > > else: > tfms.append(item) > > # JUST SELECTED WHOLE PIECE(s) OF GEOM > if tfms != [] and verts == []: > > for tfm in tfms: > try: > pm.select("%s.vtx[:]"%tfm,r=True) > newTfm = tfmAtCentroid(locator=locator,name=name)[0] > returnList.append(newTfm) > except: > # NOT A MESH > if locator: > name = name or "%sNUL"%tfm > loc = pm.spaceLocator(n=name) > pm.delete(pm.pointConstraint(tfm,loc,mo=False)) > returnList.append(loc) > else: > name = name or "%sJNT"%tfm > pm.select(d=True) > j = pm.joint(n=name) > pm.select(d=True) > pm.delete(pm.pointConstraint(tfm,j,mo=False)) > returnList.append(j) > > # HAVE TO RETURN HERE OR IT WILL CONTINUE ON AND MOVE YOUR TFM TO THE > ORIGIN > return returnList > > # SELECTED SOME VERTS AND THATS IT > if tfms == [] and verts != []: > if locator: > name = name or "%sNUL"% verts[0].node() > loc = pm.spaceLocator(n=name) > tfms.append(loc) > returnList.append(loc) > else: > name = name or "%sJNT"% verts[0].node() > j = pm.joint(n=name) > pm.select(d=True) > tfms.append(j) > returnList.append(j) > > pm.select(verts,r=True) > # CREATE A CLUSTER TEMPORARILY > clsNode, clsHandle = pm.cluster() > for tfm in tfms: > # SNAP JOINTS TO THE CLUSTER HANDLE > pm.select(d=True) > pm.delete(pm.pointConstraint(clsHandle,tfm,mo=False)) > > #DELETE THE CLUSTER HANDLE > pm.select(d=True) > try: > pm.delete(clsNode,clsHandle) > except: pass > > return returnList > > > > On Thu, Sep 18, 2014 at 4:52 PM, <[email protected]> wrote: > >> Hi, Thanks for replying. >> >> by "component islands", I mean to say - 'Groups' of connected components >> (edges, faces, verts) in the current selection or passed in component id's. >> >> I'd love some help with that. I will just be creating locators at the >> average tfm of those component 'Groups' for now. >> >> I've figured out my previous posts dilemma, by just instancing a >> pm.MeshVertex() with the string(s) that the conversion cmd was giving me. >> that's probably not that best way though i figure. >> >> even so, now I have access to their positions and normals, just need to >> do some err, math. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/9c954523-f47d-4f5d-b67e-50b8bd6a13fe%40googlegroups.com >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CABPXW4g0KD%2Bw61MzjDZTZaiy1LhR%3Ddq4gn%2Bj1RYHL3w2%3DTjgrA%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CABPXW4g0KD%2Bw61MzjDZTZaiy1LhR%3Ddq4gn%2Bj1RYHL3w2%3DTjgrA%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAM9RXoLp%2Bm%2BFBbkcQUyW%2B71JpHN6qQUV30t-L6OdZfa4gCN-PA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
