Convert Array into Integer
-
Hi,
I am trying to use a simple bit of code that allows me to set the color alpha value in SketchUp 7.
I use this version as its the last one with a free DWG importer.
Anyway the problem is I can only get an array from 'UI.inputbox' and I need an integer to set the color.alpha value.
Can anyone correct the code?
Thanks
Ross
` def translucent
model = Sketchup.active_model
materials = model.materials
m=materials.add("translucent") unless m=materials["translucent"] # Adds a material to the "in-use" material pallet.title = 'Opacity'
prompt = 'Opacity'
default = 0.5
result = UI.inputbox([prompt], [default], "text") # need to use arrayUI.messagebox(result)
m.color = Sketchup::Color.new(100, 100, 100, result) # Specify the colour.opacity
color = m.color
alpha = m.alpha=0.5 # Set material transparency
materials.current = materials["translucent"] # Set to the current material
Sketchup.send_action "selectPaintTool:" # Start the paint tool
end` -
You need to access the items inside the array. In your case you only have one item so it would be:
result[0]
.m.color = Sketchup::Color.new(100, 100, 100, result[0])
You should also check result to see if the user hit Cancel in the inputbox.
-
Hi, that has sorted it.
Thank you
Advertisement