[Closed] Skin Mod & Morpher Mod help
Hey all!
The skin modifier has me stumped! How can I add a skin modifier to a multiple selection and then tell it which bones to add?
I’ve added a variable “boneSelection = $ as array” and I can add these to a selected object using:
modPanel.addModToSelection (Skin ()) ui:on
bonesARR = boneSelection as array
for i in bonesARR do
(
skinOps.addBone $.modifiers[#Skin] i 1
)
This works fine unless multiple objects are selected, in which case I get a “– Unknown property: “modifiers” in $selection” error.
Any ideas on this?
On a side note, how would I set a Morpher modifier to 100% on multiple selected objects? I know that:
$.modifiers[#morpher][1].value = 100
Will set the value to 100 on a selected object, but won’t work on multiple.
Any thoughts would be cool, cheers in advance
- Stu
$ and selection and $selection have some issues.
If a single object is selected, then $ will return that single node. But if multiple objects are selected, then $ returns an array. As there is no modifiers property for the array class, you have to manually check each object in the array for the property.
What I usually do with $selection is something like this:
objs = $selection as array
if(objs.count !=0) then
(
for i in objs do
(
print i.modifiers
)
)
else
(
messageBox "Please select at least one object"
)
EDIT: In the first line of code I used $selection as array. This is to make sure that if only one object is selected, the objs variable is still an array, though it only has one object in it. This is so that we can unify how we check out the objects.
Doing this will ensure that you are able to access each object’s properties, even if only one object is selected. If no object is selected, then it will prompt the user to select something.
-Dave
As for the morpher modifiers, you have two options. The first is based on an assumption, and assumptions are generally bad. The assumption is that each object in the selection has a morpher modifier as the first modifier in the stack. The following code does some basic error checking, skipping any modifier that does not match the proper criteria. The problem with doing this, is that you don’t really get any feedback to tell you which objects have been skipped because that did’nt match the criteria. I’ve left some else switches that could be used to count or define which objects have been skipped.
Here’s an example:
objs = $selection as array
if(objs.count != 0) then
(
for i in objs do
(
if((classOf i.modifiers[1]) == Morpher) then
(
for f in 1 to i.modifiers[1].numSubs do
(
if(i.modifiers[1][f].value != undefined) then
(
i.modifiers[1][f].value = 100
)
)
)
else
(
)
)
)
The other option, which is more involved, would require you to check the class of all the modifiers for each object, and for each morpher modifier, change all the values to 100. This may be better, as it would catch a morpher modifier that was in a position in the stack that you had’nt anticipated.
Let me know if that helps, or if you have any questions.
-Dave
Hey thanks for the info Dave.
It cleared up a few things for me, and I got all the scripts working. Thanks for taking the time to help me out there, much appreciated.
Cheers
- Stu