Hi guys, i want to check if one material use transparency or not.I have alredy used material.use_alpha? and material.color.alpha > 0 but not works , maybe i am doing something wrong or i dont understand how theese works
This is my code, i hope in your help
if(material.use_alpha? == false || material.color.alpha > 0)
UI.messagebox " NO material is NOT transparent"
elsif(material.use_alpha? == true || material.color.alpha == 0)
UI.messagebox " OH material is transparent"
end
material.use_alpha? || material.color.alpha > 0 are both true
unless it’s the ‘default color’, it either has it or not…
so you can simply test for that…
material = Sketchup.active_model.materials.current
if !material.nil? && material.use_alpha?
UI.messagebox " OH material is transparent"
else
UI.messagebox " NO material is NOT transparent"
end
material = Sketchup.active_model.materials.current
if !material.nil? && material.respond_to?(:texture)
p [material.texture.width, material.texture.image_width, material.texture.height, material.texture.image_height]
else
p " NO material has no texture"
end
width, height are in inches and image_width, image_height are in pixels…