[Closed] 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…
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.
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!
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
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.