Advanced locator

This is another take on the locator. It supports multiple shapes and can have a unique color instead of only Maya’s built-in colors.

locator

It does not:
> Actually draw curves (I just called it that because I usually use degree-1 curves as controls, it just uses GL_LINES).
> Support separate colors per shape. It is in the end one shape node.

It does:
> Save you from the hassle of parenting curve shapes manually and having other scripts break because you suddenly have too many (shape) children.
> Support any color!

Scripts to convert selected curves to a CurveLocator (it samples smooth curves to have enough points so the look is the same):

Plugin:
> Compiled against Maya 2014
MLL file

Source:
> Solution is Visual Studio 2013
Source

The code that made the preview image:

from maya import cmds
cmds.loadPlugin("CurveLocator.mll", qt=True)

#david star
l = cmds.createNode("CurveLocator", n='CurveLocatorShape')
cmds.setAttr('%s.shapes[0].closed'%l, True)
cmds.setAttr('%s.shapes[0].point[0]'%l, 1.8, -1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[1]'%l, 0.6, -1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[2]'%l, 0, -2, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[3]'%l, -0.6, -1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[4]'%l, -1.8, -1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[5]'%l, -1.2, 0, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[6]'%l, -1.8, 1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[7]'%l, -0.6, 1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[8]'%l, 0, 2, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[9]'%l, 0.6, 1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[10]'%l, 1.8, 1, 0, type='double3')
cmds.setAttr('%s.shapes[0].point[11]'%l, 1.2, 0, 0, type='double3')
cmds.setAttr('%s.color'%l, 0.8, 0.5, 0.1, type='float3')

#joint like shape
from math import sin, cos, pi
l = cmds.createNode("CurveLocator", n='CurveLocatorShape')
cmds.setAttr('%s.shapes[0].closed'%l, True)
cmds.setAttr('%s.shapes[1].closed'%l, True)
cmds.setAttr('%s.shapes[2].closed'%l, True)
for i in range(36):
    cmds.setAttr('%s.shapes[0].point[%s]'%(l, i), cos(i / 18.0 * pi), -sin(i / 18.0 * pi), 0, type='double3')
    cmds.setAttr('%s.shapes[1].point[%s]'%(l, i), cos(i / 18.0 * pi), 0, -sin(i / 18.0 * pi), type='double3')
    cmds.setAttr('%s.shapes[2].point[%s]'%(l, i), 0, cos(i / 18.0 * pi), -sin(i / 18.0 * pi), type='double3')
cmds.setAttr('%s.color'%l, 0.0, 0.87, 0.3, type='float3')

#circle
l = cmds.createNode("CurveLocator", n='CurveLocatorShape')
for i in range(36):
    cmds.setAttr('%s.shapes[0].point[%s]'%(l, i), cos(i / 18.0 * pi), -sin(i / 18.0 * pi), 0, type='double3')
cmds.setAttr('%s.color'%l, 1.0, 0.1, 0.8, type='float3')

#jagged circle
l = cmds.createNode("CurveLocator", n='CurveLocatorShape')
for i in range(36):
    cmds.setAttr('%s.shapes[0].point[%s]'%(l, i), cos(i), -sin(i), 0, type='double3')
cmds.setAttr('%s.color'%l, 1.0, 0.1, 0.8, type='float3')

Leave a Reply

Your email address will not be published. Required fields are marked *