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 CLOSED
 
Thread Tools Search this Thread Display Modes
  09 September 2005
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:
http://www.unm.edu/~jgibz/joints.gif

When I try to run the script passing the two joints' names in strings I get:
http://www.unm.edu/~jgibz/afterProcedure.gif

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.
 
  09 September 2005
It works properly in my test case. You may have to post a scene...
 
  09 September 2005
I generally just use...

delete `parentConstraint "object1" "object2"`;


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

.j
__________________
Make something idiot proof and they'll just build a better idiot
 
  09 September 2005
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.
 
  09 September 2005
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...
ie.

  string $newPC[] = `parentConstraint`;


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

ie

  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..

.j
__________________
Make something idiot proof and they'll just build a better idiot
 
  09 September 2005
makes perfect sence, thanks a bunch.
 
  11 November 2005
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?
 
  11 November 2005
While reading some of the other posts here I found <pointPosition> This works, if anyone out there cares
 
  11 November 2005
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 Highend3D.com 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.

-S
__________________
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.
 
  11 November 2005
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).
 
  11 November 2005
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
 
  11 November 2005
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 12:31 PM.


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