ScriptSpot

Forum topic · General Scripting

how to make a filter selection on Array

By draging · 2013-08-27

Description

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 (8)

.

miauu · 2013-08-27


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

draging · 2013-08-27

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 · 2013-08-27

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
)

barigazy · 2013-08-27

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)

draging · 2013-08-27

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

draging · 2013-08-27

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 · 2013-08-27


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

draging · 2013-08-27

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