this is my code but it’s giving wrong dimensions.here i am selecting the component on which i have to put cover panel , and giving direction left or right on which side i want to put the cover panel…
comp_height = Sketchup.active_model.selection[0].get_attribute(:rio_atts,‘height’)
comp_width = Sketchup.active_model.selection[0].get_attribute(:rio_atts,‘width’)
comp_breadth = Sketchup.active_model.selection[0].get_attribute(:rio_atts, ‘breadth’)
def add_cover_panel sel2,direct
vector = Geom::Vector3d.new(0, 0, 1)
angle = 90.degrees
model = Sketchup.active_model
definitions = model.definitions
panel_path = "C:/something/cache/PANEL.skp"
panel_def = model.definitions.load(panel_path)
trans_right = Geom::Transformation.new([1,0,0])
defn = definitions.add "defn_name"
trans_comp = sel2.transformation
y_factor = comp_breadth.to_i.mm
z_factor = comp_height.to_i.mm
if direct=="right"
int_width = comp_width.to_i
x_factor = int_width.mm+18.mm
instance = defn.entities.add_instance panel_def,trans_right
transform_rotate = instance.transform!(Geom::Transformation.rotation(trans_right.origin,vector,angle))
transform_size = instance.transform!(Geom::Transformation.scaling(x_factor,y_factor,z_factor))
ent = Sketchup.active_model.active_entities
new = ent.add_instance defn,trans_comp
end
end
add_cover_panel Sketchup.active_model.selection[0],"right"
component_on_which_to_put_cover_panel.skp (212.4 KB) PANEL.skp (140.0 KB)