View Full Version : Create Primitive with altered pivot/position

10 October 2006, 02:29 PM
Hi all,

How can I go about making a mel button for my shelf which will generate a new primitive (cube lets say) which already has it's pivot set to the centre of the bottom face and which is then realigned to (0,0,0) once this is done?

I tried just echoing the script editor and copying this to my shelf but the cube just came in as normal - I assume because the pivot change involves the objects name. How do I get around this to make it a generic button I can use to make any number of cubes aligned this way?

Apolgogies if this has been asked way back when but there was nothing in the search.


Robert Bateman
10 October 2006, 03:46 PM
$w = 1.0;
$h = 1.0;
$d = 1.0;

$cube = `polyCube -w $w -h $h -d $d`;
setAttr ($cube[0]+".rotatePivot") 0 (-$h/2) 0;
setAttr ($cube[0]+".scalePivot") 0 (-$h/2) 0;
setAttr ($cube[0]+".ty") ($h/2);

10 October 2006, 08:39 PM
Sweet! Thats exactly what I'm looking for. Thanks a lot Robert.

CGTalk Moderation
10 October 2006, 08:39 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.