Short script that collapses component clusters for Maya 2018
Full credits to eltarbos!
(Python) Code:
import maya.cmds as cmds<br>sel = cmds.ls(sl=1, fl=1)<br>convVerts = cmds.polyListComponentConversion(sel, tv=1)<br>cmds.scale(0, 0, 0, cs=1, r=1)<br>cmds.polyMergeVertex( convVerts, d=0.000001 )
Original Post:
So I've been getting into Python in hopes of not banging my head as frequently as I do whenever I get to make my own scripts. Right now I was trying to mimic Max' merging ways, in which it welds to the center of separate clusters of selected components. For this, I think I would need to...
1-make a for operation that would evaluate whether the component right next to the selected one is also selected or not; so that it knows when a selected shell ends.
2-Calculate the center of these shells.
3-Weld to center by individual shells one at a time.
Maybe I'm going wrong about this though...perhaps I could just skip 2) and do 3) while hiding momentarily individual shells so that it doesnt all weld together...
Does anyone know of any scripts that do any of these 3 steps (mainly 1) ), so that I can have a look at how it's written?
Replies
If you are on maya 2018, thanks to the improved component space, you can use this simple script:
cs=1? WHat's that? Cant find that in the documentation. That's the new component space? What is it?
In this mode, in maya 2018, every component shell has its own pivot on the averaged normal of its components.
In previous versions, you had only one pivot at the average normal of all selected components.
Too bad i'm on LT