Hi,
I am working on a script that activates the paint bucket tool with a predefined material of a certain colour and transparency. The code I have written works fine except on every use it creates a copy of the material eg. 'window1', 'window2' etc. which makes a bit of a mess of the materials palette.
I think it just needs a simple if statement to avoid creating the material if it already exists. Does anyone know how to do this?
Thanks Ross
toolbar = UI;;Toolbar.new "Window"
cmd = UI;;Command.new("Test") { window }
cmd.small_icon = "CBG/window_sm.png"
cmd.large_icon = "CBG/window.png"
cmd.tooltip = "Paint Window"
toolbar = toolbar.add_item cmd
toolbar.show
def window
model = Sketchup.active_model
materials = model.materials
m = materials.add "Window" # Adds a material to the "in-use" material pallet.
m.color = Sketchup;;Color.new(100, 150, 240) # Specify the colour
color = m.color
alpha = m.alpha=0.5 # Set transparency
materials.current = materials["Window"] # Set to the current material
Sketchup.send_action "selectPaintTool;" # Start the paint tool
end