Matching component selection pivot to object pivot

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 03 March 2013   #1
Matching component selection pivot to object pivot

string $sel[] = `ls -sl`;
float $pivPos[] = `xform -q -ws -t ($sel[0]+".rotatePivot")`;
int $count[] = `polyEvaluate -v $sel[0]`;
select ($sel[0]+".vtx [0:" + ($count[0] - 1) + "]");

// everything is fine till now. but when i try to move the component pivot using below line, don`t //work for me.

move $pivPos[0] $pivPos[1] $pivPos[2] ($sel[0] + ".scalePivot") ($sel[0] + ".rotatePivot");

when i move component pivot in 3D space. nothing showing up in script editor output pannel, even with echo all commands turned on :(

Last edited by theJackson : 03 March 2013 at 06:25 AM.
 
Old 03 March 2013   #2
Hmm, I'm confused as to what you're actually trying to do here.

You query the world space coordinates of the rotate pivot, and but then in your move command you're just moving it to that position, which doesn't do anything, because it is already there, and unless you've separately moved the scale pivot, it is as well, unless the selected objects are parented to something aside from the world etc.
If you're trying to move the pivot for all the vertices you've selected, you need to iterate through the list of selected vertices. So you'd have to do ls -sl again, after you've selected the vertices (and obviously get a string array etc), and then create a for loop that iterates through that array and uses your last line for each object in the new string array. Actually, you wouldn't need to iterate through them all or define a new string array. Since you already have them all selected, you can just use the move command without any strings for object/pivot names, i.e.:
move x y z

Where x y and z are the values you want to move it to ($pivpos[0] etc).

However, by moving the vertices' rotate and scale pivots to the objects pivot, you're not really going to accomplish much. Rotating or scaling the vertices of an object from the object's pivot doesn't do anything macroscopically different than rotating or scaling the object normally. On the back side of things, however, you'd have a lot of vertex transformations, which Maya may or may not deal with in terrible ways, I'm not sure. I would guess that it wouldn't play nicely with it. It seems to me you're trying to do a lot for something that is really not doing anything that is very helpful, though I could be wrong, as I don't know what it is that you are trying to accomplish.
 
Old 03 March 2013   #3
Thanks for the reply!
as the component (all the vertex) pivot basically pivots in average position between all the verts, i want to move all the vertex rotate pivot to the objects rotate pivot, that way the pivot position remains the same whether i select object or any all the components of that particular object.
so yeah, i realised i was moving the objects pivot again. so here i modified it a little bit.

string $sel[] = `ls -sl`;
float $pivPos[] = `xform -q -ws -t ($sel[0]+".rotatePivot")`;
int $count[] = `polyEvaluate -v $sel[0]`;
$vertsPivot = `select ($sel[0]+".vtx [0:" + ($count[0] - 1) + "]")`;

$allVertsPivot =`xform -q -ws -t ($vertsPivot +".rotatePivot")`;
move $pivPos[0] $pivPos[1] $pivPos[2] ($allVertsPivot+ ".scalePivot") ($allVertsPivot + ".rotatePivot");

still doesn`t work though, i`m confused

Edit: this guy got the same problem with no solution
http://www.creativecrash.com/forums...cted-components

Last edited by theJackson : 03 March 2013 at 07:52 AM.
 
Old 03 March 2013   #4
There is an option for this inside the tool setings for rotation and scaling called "component use object pivot" for the older versions, in the newer versions this is a radio button "scale pivot:"...
 
Old 03 March 2013   #5
Originally Posted by theJackson: Thanks for the reply!
as the component (all the vertex) pivot basically pivots in average position between all the verts, i want to move all the vertex rotate pivot to the objects rotate pivot, that way the pivot position remains the same whether i select object or any all the components of that particular object.
so yeah, i realised i was moving the objects pivot again. so here i modified it a little bit.

string $sel[] = `ls -sl`;
float $pivPos[] = `xform -q -ws -t ($sel[0]+".rotatePivot")`;
int $count[] = `polyEvaluate -v $sel[0]`;
$vertsPivot = `select ($sel[0]+".vtx [0:" + ($count[0] - 1) + "]")`;

$allVertsPivot =`xform -q -ws -t ($vertsPivot +".rotatePivot")`;
move $pivPos[0] $pivPos[1] $pivPos[2] ($allVertsPivot+ ".scalePivot") ($allVertsPivot + ".rotatePivot");

still doesn`t work though, i`m confused

Edit: this guy got the same problem with no solution
http://www.creativecrash.com/forums...cted-components


Think about what your code is doing. Go line by line and really think about how you're defining your variables, more so if you're declaring them anywhere. Two of your variables aren't even declared or casted. and you're querying the world space position of the vertex arrays pivots? They would naturally be the position of the vertices. That line isn't necessary, and you don't need the variable you've defined there either. Remember when you're trying to attach strings like ".rotatePivot", you need to add that to another string, specifically, the string that contains the name of the object whose pivot you are trying to move. Anyway what zaskar said is probably better. I would suggest using what he pointed out, but take a look at your code again for the sake of good programming practice.
 
Old 03 March 2013   #6
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 07:09 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.