PDA

View Full Version : Check for skin modifier.. weird results


Malkalypse
03-26-2009, 04:53 PM
I'm working on creating a script that will require first checking to see if an object has a skin modifier. I thought I knew how to do this, but when I tried I was getting false positives. After putting in a few format lines to debug,

hasSkin = false
for i = 0 to $.modifiers.count do
(
format "hasSkin = %\n" hasSkin
if $.modifiers[i] == modifier_skin do (hasSkin = true)
format "modifer %: %\n" i $.modifiers[i]
format "hasSkin = %\n" hasSkin
)

the results I keep getting for an object with no modifiers are:

false
hasSkin = false
modifer 0: undefined
hasSkin = true
OK
OK

I don't understand what I'm doing wrong...?

SyncViewS
03-26-2009, 05:06 PM
Hi Kevin,
modifiers is an array and starts from index 1, that's why you got that "modifier 0: undefined". Then you need to check the modifier class to be sure it is what you're looking for, in this case it is 'Skin'.


hasSkin = false
for i = 1 to $.modifiers.count do
(
if ((classOf $.modifiers[i]) == Skin) then
(
hasSkin = true
)
)
format "hasSkin = %\n" hasSkin

- Enrico

JHN
03-26-2009, 07:29 PM
Or


(for m in $.modifiers where isKindOf m skin collect m).count


Will return the amount of skin modifiers so test if the outcome is 0.

-Johan

Malkalypse
03-26-2009, 08:03 PM
Thanks both, I realized my mistake shortly after posting, but

(for m in $.modifiers where isKindOf m skin collect m).count

wow, is that tight code! :O

eek
03-27-2009, 02:22 AM
(selection[1].skin != undefined)

or

(selection[1].modifiers[#skin] != undefined)

ZeBoxx2
03-27-2009, 02:33 AM
(selection[1].skin != undefined)

or

(selection[1].modifiers[#skin] != undefined)

wouldn't rely on that - that uses the name of the modifier, which is user-modifiable

CGTalk Moderation
03-27-2009, 02:33 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.