Link Constraint Key Access

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
  07 July 2011
Link Constraint Key Access

It's been a long couple days, so it may just be the fog of crunchtime getting to me, but I'm not seeing any way to access/manipulate the keys of a link constraint controller? Ran searches here, looked in maxscript help, not seeing anything that points to a keyArray for that controller.

Specifically what I'm looking to do is have a function that deletes any keys after the currentTime on any sleceted objects that have link constraint controllers. I can figure out how to code that, if I can manage to find how to get what the existing constraint keys are.


Thanks for any ideas!

Edit: Getting closer, I don't know enough about subAnims, so found
$.transform.controller[2].keys
to get to the linkTimes keyArray, but doing
deleteKey $.transform.controller[2].keys 3
results in OK but the $.transform.controller[2].keys.count doesn't change. More digging needed...
__________________
| Twitter | LinkedIn | JCanimator.com |

Last edited by SnipeyX : 07 July 2011 at 08:59 PM.
 
  07 July 2011
Originally Posted by SnipeyX: It's been a long couple days, so it may just be the fog of crunchtime getting to me, but I'm not seeing any way to access/manipulate the keys of a link constraint controller? Ran searches here, looked in maxscript help, not seeing anything that points to a keyArray for that controller.

Specifically what I'm looking to do is have a function that deletes any keys after the currentTime on any sleceted objects that have link constraint controllers. I can figure out how to code that, if I can manage to find how to get what the existing constraint keys are.


Thanks for any ideas!



you can't delete keys from LinkTimeControl controller. It's driven by link targets. You have to delete a target, and it automatically deletes the correspondent key from Link_Times.
getframeno, getnumyargets, deletetarget are your methods.
 
  07 July 2011
Ahhhhhhhhhhhhhhh. Right. I knew that. I used addTarget all over the place in this script, but DeleteTarget never even entered my mind when it came to this.

Thank you!
__________________
| Twitter | LinkedIn | JCanimator.com |
 
  07 July 2011
The Solution

In case anyone else comes across wanting to do the same thing, here's what I wound up doing, seems to work thus far.


sel = selection as array
objs = for o in sel where classOf o.transform.controller == Link_Constraint collect o 
for o in objs do (
	num = o.transform.controller.getNumTargets()
	for i=num to 1 by -1 do (
		frameNo = o.transform.controller.getFrameNo i
		if frameNo > currentTime then o.transform.controller.DeleteTarget i
	)
)
__________________
| Twitter | LinkedIn | JCanimator.com |
 
  07 July 2011
Originally Posted by SnipeyX: In case anyone else comes across wanting to do the same thing, here's what I wound up doing, seems to work thus far.


  sel = selection as array
  objs = for o in sel where classOf o.transform.controller == Link_Constraint collect o 
  for o in objs do (
  	num = o.transform.controller.getNumTargets()
  	for i=num to 1 by -1 do (
  		frameNo = o.transform.controller.getFrameNo i
  		if frameNo > currentTime then o.transform.controller.DeleteTarget i
  	)
  )
  

j-man knows my paranoid taste of optimization... i can't just ignore the it:

  for node in selection where iskindof (c = node.track) Link_Constraint do
 	for i = c.getnumtargets() to 1 by -1 where (c.getframeno i ) > currenttime do c.deletetarget i
  
 
  07 July 2011
Wow, that's pretty awesome. Still working my way up that coding knowledge hill where I can think of it like that. This helps a lot, appreciate it.
__________________
| Twitter | LinkedIn | JCanimator.com |
 
  07 July 2011
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 04:49 AM.


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