how to make a filter selection on Array

I have 3 objects

MyObj = #($box001,$box002,$sphere001)

In my case, I want to change the wirecolor of all the objects to be red but I don't want to change the color on MyObj array, then I want to select objects that have become red.

for o in objects do
(
o.wirecolor = (color 255 0 0)
for i in MyObj do
(
i.wirecolor = -- don't change this
-- What next ? :o
)
)

I tried this but, it doesn't work.

Any suggestions?

Thank you

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

(
	myObjArr = #($box001,$box002,$sphere001)	---	selection as array
 
	for o in objects where (findItem myObjArr o ) == 0 do
		o.wirecolor = red
)
draging's picture

yess that's what I need

yess that's what I need :D
thanks miauu

but how to select them (objects with red color) ?
with 'select o' its not working correctly

miauu's picture

.

You have to use selectMore 0, but this is slow(in scene with many many objects) compared to this:

(
	myObjArr = #($box001,$box002,$sphere001)	---	selection as array
 
	objWithRedWirecolorArr = #()
	for o in objects where (findItem myObjArr o ) == 0 do
	(
		o.wirecolor = red
		append objWithRedWirecolorArr o
	)
	select objWithRedWirecolorArr
)
draging's picture

I had read the MXS help yup,

I had read the MXS help
yup, 'selectmore' make the process slower

your script is good for faster processing
its working correctly :D

thanks again Miauu

barigazy's picture

...

MyObj = #($box001,$box002,$sphere001)
select (for o in objects where findItem MyObj o == 0 collect (o.wirecolor = red; o))

barigazy

draging's picture

yess, cool.... its working

yess, cool.... its working correctly :D
thank you very much barigazy

barigazy's picture

...

Kostadin is right. "SelectMore" fn is slow. Anyway this is similar solution in one line

MyObj = #($box001,$box002,$sphere001)
select (for o in objects where findItem MyObj o == 0 and o.wirecolor = red collect o)

barigazy

draging's picture

hi barigazy thank you for

hi barigazy
thank you for your attention :)
its good in one line like your scripts. but there is no function to change the color of objects to be red first, then select the objects. or vice versa: select and then change the colors...
so how to make it in one line ? :D

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.