PDA

View Full Version : Link Constraint Key Access


SnipeyX
07-20-2011, 08:50 PM
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...

denisT
07-20-2011, 10:36 PM
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.

SnipeyX
07-20-2011, 10:38 PM
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. :banghead:

Thank you!

SnipeyX
07-21-2011, 01:48 AM
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
)
)

denisT
07-21-2011, 02:45 AM
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

SnipeyX
07-21-2011, 03:15 AM
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.

CGTalk Moderation
07-21-2011, 03:15 AM
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.