[Closed] Collection of custom helpers from selection
I’m trying to now figure out how to specifically create a collection of all the scripted helper objects I created that are found in the current selection.
The helper object code can be found here: http://forums.cgsociety.org/showthread.php?f=98&t=824604 its a plugin helper extending dummy.
I have a codeblock that grabs everything from the selection that is geometry
allObj = for o in selection where findItem GeometryClass.classes (classof o) > 0 collect o
and it works great…
now I need to do the same for the scripted helper objects in the same selection right after that line…I tried this:
allLight = for p in selection where findItem XPlaneObj8Light (classof p) > 0 collect p
but it tells me there’s no finditem for XPlaneObj8Light. I guess I need a different way to pull just those out of the selection.
I’m getting somewhere I think, but no dice…
allLight = for p in selection where classof == XPlaneObj8Light collect p
I think that SHOULD work…but its not…its giving me an empty array.
if I change it to just one = as opposed to == I get:
– Error occurred in p loop
– Frame:
– p: $X-Plane Light01
– classOf: XPlaneObj8Light
– Type error: if-test requires BooleanClass, got: XPlaneObj8Light
And if in the listener I type in “classof selection[1]” I get XPlaneObj8Light so I know its able to read the class, but how do I collect them?
Just one letter missing.
allLight = for p in selection where classof p == XPlaneObj8Light collect p
Cheers,
Drea
hah! I had just figured that out and was coming to post it when I saw you replied. Thanks! I need to get BoBos dvd
Ack…now I have a different problem…Selection Order…
In the past with my allobj selection, it was in the order the objects were selected, which allowed me to process things in the order they were selected…very useful. Now I need to have the XPlaneObj8Light helpers as part of the same collection as allobj…if thats even possible?
is there a way to combine the where clause of these two lines so they produce a collection that contains both the Geometry only objects AND the XPlaneObj8Light helper objects without screwing things up? I know I’ll have to evaluate if its a helper or a mesh when I loop through the collection later.
allObj = for o in selection where findItem GeometryClass.classes (classof o) > 0 collect o
allLight = for p in selection where classof p == XPlaneObj8Light collect p
Trying a simple or now btw.
And nope, no such luck.
Oooh that did work! I typoed! Done with thread Thanks!
Once there’s more than one test for the where, I like to put them all in a helper function. It helps keep your lines a bit more manageable.
fn isMyThing obj =
(
(superClassOf obj == Geometry) OR (classOf obj == XPlaneObj8Light)
)
objsAndLights = for i in selection where (isMyThing i) collect i
Cheers,
Drea