proc> move to position of the end joint?

Become a member of the CGSociety

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

Thread Tools Search this Thread Display Modes
Old 09 September 2005   #1
proc> move to position of the end joint?

Hi everyone,
I have this simple procedure that moves one object to the position of another. The script works if you have just that--2 objects (like two spheres, etc.) But I want to use the script to move the the top joint in one joint chain to the very bottom joint in another chain.

like so:

When I try to run the script passing the two joints' names in strings I get:

Here's the code

  proc jgMoveToObject(string $moved, string $to)
  	vector $positionTo = `getAttr ($to + ".translate")`;
  	select $moved;
  	move ($positionTo.x) ($positionTo.y) ($positionTo.z);
  	select -cl;

Any help would be great.
Old 09 September 2005   #2
It works properly in my test case. You may have to post a scene...
Old 09 September 2005   #3
Old 09 September 2005   #4
I generally just use...

delete `parentConstraint "object1" "object2"`;

that way it get worldSpace not local (sortOf) like getAttr

Make something idiot proof and they'll just build a better idiot
Old 09 September 2005   #5
proc jgMoveToObject(string $moved, string $to)
  	 delete `parentConstraint $to $moved`;
  	 select $moved;
  	 rotate 0 0 0;  //this gets rotated in the y axis after it's moved.

Thanks john, this did it, but how on earth does this work?

EDIT* http://localhost:4446/Maya6.0/en_US/index.html?MEL Ahhhh.

Last edited by jgibz : 09 September 2005 at 12:13 AM.
Old 09 September 2005   #6
a parent constraint with no options set does not maintain offset... so it basically aligns

so the command `parentConstraint` creates a parentConstraint between the 2 objects thus moving it.

as with all mel, when you create anything it returns the result, and this can be stored in a variable...

  string $newPC[] = `parentConstraint`;

you can then edit/delete/whatever you want the constraint as its name is in the variable..


  delete $newPC[0];

I just skipped this step by deleting the result of the constraint command..

essentially the line says.. "delete (create a constraint)" so it creates it so it can delete it ;^)

hope that makes sence, its sorta hard to word..

Make something idiot proof and they'll just build a better idiot
Old 09 September 2005   #7
makes perfect sence, thanks a bunch.
Old 11 November 2005   #8
I've been working on another script, and I want to move a node, say a locator, to the posiition of a vertice.

   proc jgMoveToObject(string $moved, string $to)
   	vector $positionTo = `getAttr ($to + ".translate")`;
   	select $moved;
   	move ($positionTo.x) ($positionTo.y) ($positionTo.z);
   	select -cl;

Similair to the above code, I'm using

 global proc jgCenterVerts()
 string $verts[] = `ls -sl`;
 string $vert;
 vector $vertPos;
 vector $locPos;
 spaceLocator -p 0 0 0;
 rename "jgLoc";
 for($vert in $verts)
 $vertPos = `getAttr $vert`;
 select jgLoc;
 move ($vertPos.x) ($vertPos.y) ($vertPos.z); 

I'm having the same problems here as shown in the two pics above, this time the locator and the vert, like the two joints, dont lie in the same position. The fix suggested by John_homer worked for the joints, but not for the locator and vertice.

Does anyone have any ideas?
Old 11 November 2005   #9
While reading some of the other posts here I found <pointPosition> This works, if anyone out there cares
Old 11 November 2005   #10
Hey dude. I read very quickly your thread, cause I havent got much time right now, but what I understand is that you want to move an "object", in this last case is an object to the place of a vertex. well, I made a little script for that. It is in you can grab it here. If I understood your problem uncorrectly I'm sorry for that, but i'm in a little rush. In the script, I used the xform command, and I move the objects in World Space, not in local space. Check it out if you like. This script only works with objects, not with components. Hope it helps

If you need help in this vertex case, PM me, cause I may forget to check this thread again..hehe...sorry for that...Although, you have to somehow enter component mode, and then check what vertex is selected, and then move the object to the place of the vertex.

My name is Leo Getz!! Anything you need, Leo gets, get it?!?!?

My Homepage

Last edited by Stucky : 11 November 2005 at 10:58 PM.
Old 11 November 2005   #11
Hey Stucky,
Thanks for the reply, I'll check your script out, as for my problem, it's okay i figured out a solution(see above).
Old 11 November 2005   #12
ok dude. sorry for reading your post so quickly, and didnt notice that yu already had the answer. but check my script, its always good to see other people achieve the same goals.
My name is Leo Getz!! Anything you need, Leo gets, get it?!?!?

My Homepage
Old 11 November 2005   #13
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
Society of Digital Artists

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

All times are GMT. The time now is 02:27 PM.

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