Checking for layers and auto assigning materials

I tried creating a small script which would assign materials to the appropriate layers. My only problem is that if a layer doesn't exist, the code stops and does not execute. Using this method:

$'Layer:ROOF_3D'.material = meditMaterials[1]
$'Layer:BRICK_WALL'.material = meditMaterials[2]
$'Layer:BRICK_COURSE'.material = meditMaterials[2]
ETC...

How could I check for a layer and if not present ignore it and move to the next line?

Also, this is kinda a 2 part request but each layer not only has set material defs but also they have material id's because of the multi/sub object materials being used. Notice the code above shows material[2] for both the Brick_wall and Brick_course layers. Brick_wall needs to be set to material id=1 and Brick_course set to =2.

Comments

Comment viewing options

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

I've been looking for this

I've been looking for this feature for a while, could you please share your script?.

I'm so tired of assingning materials by layers to my dwg imports. I would love to have an automatic assigment tool because I've many layers and mostly use the same always.

vidorq's picture

hi, your ideia is great.

hi, your ideia is great. I´m tryng find a script like that, you solve the problem?

Comment viewing options

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