simple script help

simple script help

Anonymous
Not applicable
594 Views
1 Reply
Message 1 of 2

simple script help

Anonymous
Not applicable

hey yall, i dont know if i am crazy or what but i have been looking for a script that i cannot find. i want to select an object with values in transform, rotate and scale and click a button to have that object grouped. the kicker is the group inherits the transforms so the obj is zeroed out. i currently make a null put it under the obj, freeze it then pull it out on its own. then i put the obj under the null and freeze it. that way its at zero and has its own aim and stuff. 

 

anyone know where i can find this script? i had one once called create offset transform.

 

OR

i am trying to make it myself but im a noob and cannot figure out how to create a group under an obj (basically the first step) anyone know how to achieve this. 

0 Likes
595 Views
1 Reply
Reply (1)
Message 2 of 2

phoebe
Participant
Participant

You can retrace your steps to achieve the same using code, so anything you need to do by hand, you can find the equivalent command to call by looking at the script editor read-out. Here I've given you an example where the process will run on every object you have selected. You want to be careful with freezing transforms in instances like this one, it'll kill the rotations on the object.

 

This code runs in python, not MEL, so you'll need to use a python tab in the script editor, and I've left all the args long, so you can see what they're doing.

import maya.cmds as cmds

current_sel = cmds.ls(selection=True)

for each in current_sel:
    new_group = cmds.group(em=True, name=each + '_fix')
    cmds.delete(cmds.parentConstraint(each, new_group, maintainOffset=False))
    cmds.delete(cmds.scaleConstraint(each, new_group, maintainOffset=False))
    
    cmds.parent(each, new_group)

Here's a link to Chad Vernon's page on maya scripting for artists, it'll help you get started!

http://www.chadvernon.com/blog/resources/python-scripting-for-maya-artists/

 

= ^.^ =

0 Likes