PDA

View Full Version : Selection by Diffuse Color


Edgemaster
06-02-2011, 07:41 PM
Hello everyone,

Well I'm trying to create a script that collects all the objects with the same diffuse color. I've gotten some of the info I need from other threads. But I'm having trouble on one spot.

So from this thread

http://forums.cgsociety.org/showthread.php?f=98&t=772087&page=1&pp=15

I adjusted some of the script and this is where I'm currently at.


(mats= for m in sceneMaterials collect mfor m in mats do (
if m.diffuse == color 150 150 150 do
--So for example I need the mats with this diffuse color to do what action I need below
(
--Select the all objects with the diffuse color properties above
)
)
)


So I dont know how to go about selecting the objects with the specific diffuse color applied.All I really need to do is select all the materials with this certain diffuse color applied to them and select these objects so I can just apply a new material to them.

(
mats= for m in sceneMaterials collect m
for m in mats do


( if m.diffuse == color 150 150 150 do
( m.diffuse = color 1 1 1 --So I know something like this works for example.--Just dont know how to go about and selecting the objects in the scene.
)
)
)

Thanks for any help that is posted

Alex Antuna

plastic
06-02-2011, 11:06 PM
try this:

objectsArray=for i in objects where i.material.diffuse==color 150 150 150 collect i
select objectsArray

jonlauf
06-03-2011, 02:36 AM
theObjs = #()
for m in scenematerials where m.diffusecolor == color 150 150 150 do join theObjs (refs.dependentNodes m)
select theObjs

Edgemaster
06-03-2011, 01:14 PM
plastic and jonlauf Thank you for the Replies! I tried them both and they work great.

jonlauf - on yours I just had to change the text m.diffusecolor to m.diffuse and it worked after that. I'm using Vray so not sure if that had something to do with it not working with the original text you posted.

Alex

CGTalk Moderation
06-03-2011, 01:14 PM
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.