I have been playing with the mergeVertexTool lately and i simply cannot get it to work like a weld vertex tool in Max. I have made a tool where if you selcet all verts it merges vertex’s that are on top of each other but cant get the 1st vertex to go on top of the 2nd vertex i selcet. I there already a simple solution to this already out there?
What are you expecting that it isn’t doing? I can use the merge vertex tool and drag from one vertex to another and it will merge the two. Is that not the behavior that you are getting?
polyMergeVertex welds any vertices that are within a certain distance of each other.
In order to weld two vertices together regardless of distance you have to use the alwaysMergeTwoVertices/am flag and pass the function exactly two vertices to weld. The am flag will only work if it is only operating on two vertices–if there are more it will behave as though am is False.
To weld two vertices:
So am i looking at the wrong command to get what i want?
I want to hit target weld tool and then the 1st vertex i select merges with the 2nd vertex i select in the 2nd vertex’s position.
Sorry if I am sounding like a complete noob…i am
The easiest method for building your own UI with existing Maya functionality is to create a new, temporary shelf, and hold down CTRL-SHIFT while choosing Menu Items. This creates a Shelf Button that executes the same code as the Menu Item. You can then open the Shelf Editor and inspect what command is executed when that menu item is picked (usually it is a runtime command, but sometimes it can be an embedded mel script).
You can then copy and paste this command into your own UI, or at the very least use the “whatIs” Mel command to find out more about how that particular feature works.
In terms of the ui, i have a pretty good working docked ui which has all my other noob tools (real basic stuff to help me self teach) however i am in the middle of creating a new updated version of my script in QT designer.
[QUOTE=bcottage;26234]So am i looking at the wrong command to get what i want?
I want to hit target weld tool and then the 1st vertex i select merges with the 2nd vertex i select in the 2nd vertex’s position.
Sorry if I am sounding like a complete noob…i am
As far as I can tell you have to move the first vert to the location of the second before merging in order to get the desired effect. Your process should be this:
User presses button:
Get selected verts (must be only two verts)
Get world position of the second vert (this is where we want the merged verts to be placed). Use cmds.xform to get it
Move the first vert to the position of the second vert using cmds.xform
Call polyMergeVertex with the two selected verts (cmds.polyMergeVertex(vert1, vert2, am=True)
It is stored in Preferences. I don’t believe it defaults to True, but I could be wrong (it is a performance hit to track the selection order).
As far as I can remember the “ls” command always returns the selection sorted, not in the order it was selected.
selection(sl) boolean create
List objects that are currently selected.
orderedSelection(os) boolean create
List objects and components that are currently selected in their order of selection. This flag depends on the value of the -tso/trackSelectionOrder flag of the selectPref command. If that flag is not enabled than this flag will return the same thing as the -sl/selection flag would.
[QUOTE=capper;26236]Why not just use the Merge Vertex Tool in the Edit Mesh menu? It allows you to merge one vertex to another by dragging between them.[/QUOTE]
Im trying to replicate exactly this. Finding it really hard atm
If you want the drag behavior, then just activate the merge vertex tool:
cmds.setToolTo('polyMergeVertexContext')
If you want that behavior with selected vertices, then the steps that rgkovach and I outlined should get you there. If you’re having problems with that let us know which parts and/or post your current code.