[Closed] Simple loop script to apply to multiple objects not working
Hi all,
Not sure why this loop is not working, I am just getting back into maxscript. Just trying to use a simple loop to apply a controller to all biped objects. It executes with no error however, the changes are not applied? Am I missing something?
script below
for i in objects do
(
if isKindOf i Biped_Object do
(
$.transform.controller.Biped_SubAnim.controller.BipScaleList.controller.Available.controller = ScaleXYZ ()
)
)
[b]i[/b].transform.controller.Biped_SubA... = ...
but not every biped_object has this type of controller. you have to do another check
Check this works first, it just throws an error
$.transform.controller.Biped_SubAnim.controller.Bi pScaleList.controller.Available.controller = ScaleXYZ ()
You sort what you are after in controllers
Add to loop like this for selected Bipeds
Bips = for o in selection where classOf o == Biped_Object collect o
for i = 1 to Bips.count do(
Bips[i].transform.controller.?
)
Thanks!
Hmm not sure why that line is not working when I select an object manually and do
$.transform.controller.Biped_SubAnim.controller.BipScaleList.controller.Available.controller = ScaleXYZ ()
It works.
Just with the collection script, I am getting 0 when I print the count
print Bips.count
Am I printing it the right way, I mean that should return some positive value right?
Oh! Thanks I have identified the COM as the one that does not have the attributes. Also yes the i instead would have selected. To get around this I have used the other way of collecting the BIP objects as AngryBear suggested. However, my selection is still not working, which doesn’t make sense as I print it before I select it to check selection and it seems ok. I have skipped the first object in the collection which is the COM by adding a 3 to start with.
select $*
Bips = for o in selection where classOf o == Biped_Object collect o
print Bips.count
for i = 3 to Bips.count do
(
print Bips[i]
Bips[i].transform.controller.Biped_SubAnim.controller.Bi pScaleList.controller.Available.controller = ScaleXYZ ()
)
why can’t i reference it using Bips[i] ?
for node in selection where iskindof node Biped_Object and iskindof (c = node.controller) BipSlave_Control do
(
result = c.Biped_SubAnim.controller.BipScaleList.controller.Available.controller = ScaleXYZ()
format "node:% controller:% result:%
" node c result
)
Amazing man, thank you…man you’ve helped me so much over the years, do you have a website or sell any scripts etc, I’d happily donate or buy something! I really appreciate it!