Dear Mr Dan, I tried to insert the lines of code as your advice, but it does not work, I do not understand where I am wrong, my purpose is to, up to the width of the hole, less than or equal to 63 cm, I create a single door, over 64 cm, the doors inserted should be two, to get this, I thought of grouping together in a single group, the individual groups corresponding to the upper, lower, right, left and central wing of the door, and then copy and move it, attach an image file and ruby file, for better clarification, thank you.
Joseph.
#..........previous code
ents = group_doorvertLathSx.parent.entities
ary = [group_doorvertLathSx, group_doorvertLathDx, group_doorhorizLathTop, group_doorhorizLathBot, group_doorashWo]
new_groupDoorSx = ents.add_group(ary)
group_doorDx = new_groupDoorSx.copy
group_doorDx.name = 'doorDx'
point = Geom::Point3d.new((lg_hole -4.cm) / 2,0,0)
transformation = Geom::Transformation.new point
group_doorDx.move!(transformation)
#........next code
#........**full ruby file**
def frame_with_door()
mod = Sketchup.active_model
definit_frame_door = mod.definitions
comp_frame_door = definit_frame_door.add("FrameDoor")
ent = comp_frame_door.entities
# Create "InputBox"....
prompts = ["Height Hole: ", "Width Hole: ", "Structure Thickness: "]
options = ["", "", ""]
defaults = [65.cm, 50.cm, 2.cm]
title = "Create Frame_Door"
answers = UI.inputbox(prompts, defaults, options, title)
hg_hole = answers[0]
lg_hole = answers[1]
str_tck = answers[2]
# Create "Frame"....
# clear horizontal lath width
wth_horiz_lath = (lg_hole -6.cm)
layer_frame = mod.layers.add("Frame")
mod.active_layer = layer_frame
# left vertical lath
group_vertLathSx = ent.add_group
group_vertLathSx.name = 'vertLathSx'
pt_orig = ORIGIN
pt1 = [0,0,0]
pt2 = [0,str_tck,0]
pt3 = [3.cm,str_tck,0]
pt4 = [3.cm,0,0]
face_vertLathSx = group_vertLathSx.entities.add_face(pt1,pt2,pt3,pt4)
face_vertLathSx.pushpull (-hg_hole)
# right vertical lath
group_vertLathDx = ent.add_group
group_vertLathDx.name = 'vertLathDx'
pt5 = pt1.transform([(lg_hole -3.cm),0,0])
pt6 = pt5.transform([0,str_tck,0])
pt7 = pt6.transform([3.cm,0,0])
pt8 = pt7.transform([0,-str_tck,0])
face_vertLathDx = group_vertLathDx.entities.add_face(pt5,pt6,pt7,pt8)
face_vertLathDx.pushpull (-hg_hole)
# top horizontal lath
group_horizLathTop = ent.add_group
group_horizLathTop.name = 'LathTop'
pt9 = pt4.transform([0,0,(hg_hole -3.cm)])
pt10 = pt9.transform([0,str_tck,0])
pt11 = pt10.transform([0,0,3.cm])
pt12 = pt11.transform([0,-str_tck,0])
face_horizLathTop = group_horizLathTop.entities.add_face(pt9,pt10,pt11,pt12)
face_horizLathTop.pushpull (wth_horiz_lath)
# bottom horizontal lath
group_horizLathBot = ent.add_group
group_horizLathBot.name = 'LathBot'
pt13 = pt4.transform([0,0,3.cm])
pt14 = pt3.transform([0,0,3.cm])
face_horizLathBot = group_horizLathBot.entities.add_face(pt4,pt13,pt14,pt3)
face_horizLathBot.pushpull (-wth_horiz_lath)
if answers[1] <= 63.cm
# Create "Door..one..Sx"....
layer_door = mod.layers.add("Door")
mod.active_layer = layer_door
# left vertical lath of the door
group_doorvertLathSx = ent.add_group
group_doorvertLathSx.name = 'doorvertLathSx'
pt_dr1 = pt13.transform([-1.cm,0,-1.cm])
pt_dr2 = pt_dr1.transform([0,-3.cm,0])
pt_dr3 = pt_dr2.transform([5.cm,0,0])
pt_dr4 = pt_dr3.transform([0,3.cm,0])
face_doorvertLathSx = group_doorvertLathSx.entities.add_face(pt_dr1,pt_dr2,pt_dr3,pt_dr4)
face_doorvertLathSx.pushpull (hg_hole -4.cm)
# right vertical lath of the door
group_doorvertLathDx = ent.add_group
group_doorvertLathDx.name = 'doorvertLathDx'
pt_dr5 = pt_dr4.transform([(lg_hole -14.cm),0,0])
pt_dr6 = pt_dr5.transform([0,-3.cm,0])
pt_dr7 = pt_dr6.transform([5.cm,0,0])
pt_dr8 = pt_dr7.transform([0,3.cm,0])
face_doorvertLathDx = group_doorvertLathDx.entities.add_face(pt_dr5,pt_dr6,pt_dr7,pt_dr8)
face_doorvertLathDx.pushpull (hg_hole -4.cm)
# top horizontal lath of the door
group_doorhorizLathTop = ent.add_group
group_doorhorizLathTop.name = 'doorhorizLathTop'
pt_dr9 = pt_dr3.transform([0,0,(hg_hole -4.cm)])
pt_dr10 = pt_dr9.transform([0,0,-5.cm])
pt_dr11 = pt_dr10.transform([0,3.cm,0])
pt_dr12 = pt_dr11.transform([0,0,5.cm])
face_doorhorizLathTop = group_doorhorizLathTop.entities.add_face(pt_dr9,pt_dr10,pt_dr11,pt_dr12)
face_doorhorizLathTop.pushpull (lg_hole -14.cm)
# bottom horizontal lath of the door
group_doorhorizLathBot = ent.add_group
group_doorhorizLathBot.name = 'doorhorizLathBot'
pt_dr13 = pt_dr3.transform([0,0,5.cm])
pt_dr14 = pt_dr4.transform([0,0,5.cm])
face_doorhorizLathBot = group_doorhorizLathBot.entities.add_face(pt_dr3,pt_dr13,pt_dr14,pt_dr4)
face_doorhorizLathBot.pushpull -(lg_hole -14.cm)
# ashlar wood
group_doorashWo = ent.add_group
group_doorashWo.name = 'doorashWo'
pt_ashWo1 = pt_dr3.transform([0,1.cm,5.cm])
pt_ashWo2 = pt_ashWo1.transform([0,1.5.cm,0])
pt_ashWo3 = pt_ashWo2.transform([0,0,(hg_hole -14.cm)])
pt_ashWo4 = pt_ashWo3.transform([0,-1.5.cm,0])
face_doorashWo = group_doorashWo.entities.add_face(pt_ashWo1,pt_ashWo2,pt_ashWo3,pt_ashWo4)
face_doorashWo.pushpull (lg_hole -14.cm)
elsif answers[1] >= 64.cm
# Create "Door..one + one = two..Sx + Dx"....
layer_door = mod.layers.add("Door")
mod.active_layer = layer_door
# left vertical lath of the door
group_doorvertLathSx = ent.add_group
group_doorvertLathSx.name = 'doorvertLathSx'
pt_dr1 = pt13.transform([-1.cm,0,-1.cm])
pt_dr2 = pt_dr1.transform([0,-3.cm,0])
pt_dr3 = pt_dr2.transform([5.cm,0,0])
pt_dr4 = pt_dr3.transform([0,3.cm,0])
face_doorvertLathSx = group_doorvertLathSx.entities.add_face(pt_dr1,pt_dr2,pt_dr3,pt_dr4)
face_doorvertLathSx.pushpull (hg_hole -4.cm)
# right vertical lath of the door
group_doorvertLathDx = ent.add_group
group_doorvertLathDx.name = 'doorvertLathDx'
pt_dr5 = pt_dr4.transform([(lg_hole -14.cm),0,0])
pt_dr6 = pt_dr5.transform([0,-3.cm,0])
pt_dr7 = pt_dr6.transform([5.cm,0,0])
pt_dr8 = pt_dr7.transform([0,3.cm,0])
face_doorvertLathDx = group_doorvertLathDx.entities.add_face(pt_dr5,pt_dr6,pt_dr7,pt_dr8)
face_doorvertLathDx.pushpull (hg_hole -4.cm)
# top horizontal lath of the door
group_doorhorizLathTop = ent.add_group
group_doorhorizLathTop.name = 'doorhorizLathTop'
pt_dr9 = pt_dr3.transform([0,0,(hg_hole -4.cm)])
pt_dr10 = pt_dr9.transform([0,0,-5.cm])
pt_dr11 = pt_dr10.transform([0,3.cm,0])
pt_dr12 = pt_dr11.transform([0,0,5.cm])
face_doorhorizLathTop = group_doorhorizLathTop.entities.add_face(pt_dr9,pt_dr10,pt_dr11,pt_dr12)
face_doorhorizLathTop.pushpull (lg_hole -14.cm)
# bottom horizontal lath of the door
group_doorhorizLathBot = ent.add_group
group_doorhorizLathBot.name = 'doorhorizLathBot'
pt_dr13 = pt_dr3.transform([0,0,5.cm])
pt_dr14 = pt_dr4.transform([0,0,5.cm])
face_doorhorizLathBot = group_doorhorizLathBot.entities.add_face(pt_dr3,pt_dr13,pt_dr14,pt_dr4)
face_doorhorizLathBot.pushpull -(lg_hole -14.cm)
# ashlar wood
group_doorashWo = ent.add_group
group_doorashWo.name = 'doorashWo'
pt_ashWo1 = pt_dr3.transform([0,1.cm,5.cm])
pt_ashWo2 = pt_ashWo1.transform([0,1.5.cm,0])
pt_ashWo3 = pt_ashWo2.transform([0,0,(hg_hole -14.cm)])
pt_ashWo4 = pt_ashWo3.transform([0,-1.5.cm,0])
face_doorashWo = group_doorashWo.entities.add_face(pt_ashWo1,pt_ashWo2,pt_ashWo3,pt_ashWo4)
face_doorashWo.pushpull (lg_hole -14.cm)
ents = group_doorvertLathSx.parent.entities
ary = [group_doorvertLathSx, group_doorvertLathDx, group_doorhorizLathTop, group_doorhorizLathBot, group_doorashWo]
new_groupDoorSx = ents.add_group(ary)
group_doorDx = new_groupDoorSx.copy
group_doorDx.name = 'doorDx'
point = Geom::Point3d.new((lg_hole -4.cm) / 2,0,0)
transformation = Geom::Transformation.new point
group_doorDx.move!(transformation)
end
layer_comp = mod.layers.add("Component Frame_Door")
mod.active_layer = layer_comp
comp_frame_door.insertion_point = pt_orig # punto di iserimento del componenete stesso scelto da noi....
mod.place_component(comp_frame_door, false)
end
UI.menu("Plugin").add_item("Frame_Door"){frame_with_door}