[Closed] selecting with class test?
I have a bit of script that does what I want for the most part… until someone changes the name of a modifier… What I wanted to know is, is there a tidy way to do the following but with a class test rather than a name test?
select (for o in geometry where ((o.modifiers[#pointcache]!=undefined)\
or (o.modifiers[#Point_Cache_Binding] != undefined)) collect o)
I do know I can do a for loop to go thru the modifiers and set a flag, but I was hoping someone knew a tidy way like the code above, but for class testing rather than name testing.
Cheers,
Cg.
so you want a if statment like if (classof $) == dummy, or superclassof? Or the class of the modifier?
select (for o in geometry where \
(for m in o.modifiers where classof m == Point_Cache or classof m == Point_CacheSpacewarpModifier collect m).count > 0 \
collect o)
Loop through all geometry objects.
For each object, loop through all modifiers and collect Point Cache modifiers and WSMs.
If there are one or more modifiers, collect the object.
Select the resulting array.
Thanks Bobo. Such tidy code.
You should have seen my messy way of doing the same thing.
Cg.
Here is a shorter one:
select (for o in geometry where (for m in o.modifiers where matchPattern ((classof m) as string) pattern:"Point_Cache*" collect m).count > 0 collect o)
Hehe, now you’re just showing off
The way that you code always makes me think about things differently.
Many thanks,
Cg.