Script for creating curve at the center of the volume of object ?


#1

Hi Guys is there any script that creates curve at the center of the mesh ,like if the cylindrical pipe is there and curve at the center of it ?


#2

I’m your huckleberry.

For this script to work your edge loops have to be clean and “Track Selection Order” has to be enabled in your maya settings.


import maya.cmds as cmd
import maya.mel
def makeCenter():
    #track selection order must be on for this to work
    points = 'curve -d 3 '
    sel = cmd.ls(os=True)
    for one in sel:
        strip = re.search(r"\[([0-9]+)\]", one)
        num = strip.group(1)
        cmd.select(one)
        cmd.polySelect(el=int(num))   
        clust = cmd.cluster(n = 'poo#')
        posi = cmd.getAttr(clust[0]+'HandleShape.origin')
        points = points + ('-p %s %s %s ' %(posi[0][0], posi[0][1], posi[0][2]))
        cmd.delete (clust[0])
    mel.eval(points)


makeCenter()

Sample Video:

//youtu.be/_EwK0qHUoj0