Using Ruby for imported dwg layers to add materials
-
Man I thought python and Dynamo were hard. I even had a go at lisp but for some reason I cant get my head a round ruby. have been trying to modify someone else code with no success
P.S. I am bringing in a dwg (exported from Revit) with 30 or so layers and want to put all the layers to 1 color but windows I want them to be on Translucent Glass Gray
F.E. all layers to color 123_White except
0_EX_Glazing it needs to be on Translucent Glass GraySome of the issues
the import comes in as 1 group (with layers in the group)
some of the groups come in the main group with groups within groups (doors and Door windows)
Objects come in with a material not defined ()so a generic material must be placed on all the objects for the script to have a chance.
using some lings gets me close but doesn’t do the back faces (so windows are not completely see through
Thanks in advanceP.S. the code I am trying to modify is on this page
https://sketchucation.com/forums/viewtopic.php?f=180&t=22337&p=663388#p663388
-
The Ruby API only lets you set a layer/tag's color.
[Note in v2020 'layers' were renamed 'tags', but in the API they're always called 'layers'].
But you can't [yet] set a layer/tag's material [i.e. there's no access to textures or to transparency settings].However, in Ruby you could set up a separate color for the transparent layer [but setting a alpha value does nothing] and when it's set you do a simple edit for the layer/tag's color in the Layer/Tag Browser, and NOW you can add some transparency...
model=Sketchup.active_model model.start_operation("LayerColors",true) model.layers.each{|layer| if layer.name=="0_EX_Glazing" #grey to get transparency setting later on... layer.color=Sketchup;;Color.new(150,150,150,50) else # 0128_White ? Set up any RGB you want ! layer.color=Sketchup;;Color.new(255,255,255) end } model.commit_operation
Ensure your Model is set up to use color by layer/tag - in the layer/tag-browser pop-out...
Run this in the Ruby Console...
Next manually edit the "0_EX_Glazing" layer/tag color in the layer/tag-browser to have some transparency...
There's no option for 'back' material in layer's colors...
Advertisement