Hello again,
I I did shorten the code very much to ask this question.
How can I make the planes transparent and clickable and add a function to that plane when clicked?
selected_object = Sketchup.active_model.selection[0]
bounding_box = selected_object.bounds
center = bounding_box.center
largest_side = [bounding_box.width, bounding_box.height, bounding_box.depth].max
plane_size_percentage = 100
plane_size = largest_side * plane_size_percentage / 100.0
plane_transparency = 50
transparency = plane_transparency / 100.0
# Draw the x plane
x_plane = Sketchup.active_model.entities.add_face(
[center.x - plane_size / 2, center.y - plane_size / 2, center.z],
[center.x + plane_size / 2, center.y - plane_size / 2, center.z],
[center.x + plane_size / 2, center.y + plane_size / 2, center.z],
[center.x - plane_size / 2, center.y + plane_size / 2, center.z]
)
x_plane.back_material = x_plane.material = Sketchup::Color.new(255, 0, 0, 255 * transparency)
# Draw the y plane
y_plane = Sketchup.active_model.entities.add_face(
[center.x, center.y - plane_size / 2, center.z - plane_size / 2],
[center.x, center.y + plane_size / 2, center.z - plane_size / 2],
[center.x, center.y + plane_size / 2, center.z + plane_size / 2],
[center.x, center.y - plane_size / 2, center.z + plane_size / 2]
)
y_plane.back_material = y_plane.material = Sketchup::Color.new(0, 255, 0, 255 * transparency)
# Draw the z plane
z_plane = Sketchup.active_model.entities.add_face(
[center.x - plane_size / 2, center.y, center.z - plane_size / 2],
[center.x + plane_size / 2, center.y, center.z - plane_size / 2],
[center.x + plane_size / 2, center.y, center.z + plane_size / 2],
[center.x - plane_size / 2, center.y, center.z + plane_size / 2]
)
z_plane.back_material = z_plane.material = Sketchup::Color.new(0, 0, 255, 255 * transparency)
x_plane.material.alpha = 255 * transparency
y_plane.material.alpha = 255 * transparency
z_plane.material.alpha = 255 * transparency
x_plane.back_material.alpha = 255 * transparency
y_plane.back_material.alpha = 255 * transparency
z_plane.back_material.alpha = 255 * transparency
#Also see no difference using this line.
Sketchup.active_model.rendering_options["EdgeTransparency"] = transparency
Any suggestions? I guess I don not understand the ruby documentation well or have a wrong impression about those functions and calls.
Thank you.