Here is something I have edited for myself from cab.rb from the ruby libray. I end up with panels, a complete cabinet, etc. But when I point the cursor at the object in sketchup, there are no individual components. No individual pieces of timber I can point to, move around., resize, etc. How do I make this script come up with a left panel that is a component and not part of the whole entity.
When I use the menu without the plugin I draw the dimensions, push/pull, select all, and "make component". Then I do the same over again. I get what I want then. How can I get the same result doing a plugin script?
I don't know the ettiquette here, so sorry if pasting all this is wrong. But here goes:
require 'sketchup.rb'
#-----------------------------------------------------------------------------
def create_cab
prompts = ["Cabinet Width", "Cabinet Height", "Cabinet Depth","With Kick?"]
values = [100.cm, 100.cm, 60.cm , 10.cm ]
thick = 1.6.cm #<----panel thickness
results = inputbox prompts, values, "Cabinet Dimensions"
width, height, depth, kick = results
if (kick <= 0.0.cm)
then kick = 0.01.cm
end
#-----------------------------------------------------------------------------
model = Sketchup.active_model
model.start_operation "Create Cab"
entities = model.active_entities
group = entities.add_group
entities = group.entities
ls=[] #left panel
ls[0] = [0, depth, kick]
ls[1] = [0, depth, height-thick]
ls[2] = [0, thick, height-thick]
ls[3] = [0, thick, kick]
ls_base = entities.add_face ls
ls_base.pushpull thick
x = width-thick
rs=[] #right panel
rs[0] = [x, depth, kick]
rs[1] = [x, depth, height-thick]
rs[2] = [x, thick, height-thick]
rs[3] = [x, thick, kick]
rs_base = entities.add_face rs
rs_base.pushpull thick
rp=[] #rear panel
rp[0] = [0, depth, kick]
rp[1] = [0, depth+thick, kick]
rp[2] = [0, depth+thick, height-thick]
rp[3] = [0, depth, height-thick]
rp_base = entities.add_face rp
rp_base.pushpull -width
top=[] #top
top[0] = [thick, 10.cm, height-thick]
top[1] = [thick, 0+thick, height-thick]
top[2] = [thick, 0+thick, height-thick-thick]
top[3] = [thick, 10.cm, height-thick-thick]
top_base = entities.add_face top
top_base.pushpull width-thick-thick
top=[] #top
top[0] = [thick, depth-10.cm, height-thick]
top[1] = [thick, depth, height-thick]
top[2] = [thick, depth, height-thick-thick]
top[3] = [thick, depth-10.cm, height-thick-thick]
top_base = entities.add_face top
top_base.pushpull width-thick-thick
btm=[] #bottom shelf
btm[0] = [thick, thick, kick+thick]
btm[1] = [thick, depth, kick+thick]
btm[2] = [thick, depth, kick+0]
btm[3] = [thick, thick, kick+0]
btm_base = entities.add_face btm
btm_base.pushpull width-thick-thick
kickf=[] #kicktoe panel front
kickf[0] = [0, 4.cm, 0]
kickf[1] = [0, 4.cm+thick, 0]
kickf[2] = [0, 4.cm+thick, kick]
kickf[3] = [0, 4.cm, kick]
kickf_base = entities.add_face kickf
kickf_base.pushpull -width
kickb=[] #kicktoe panel back
kickb[0] = [0, depth-4.cm, 0]
kickb[1] = [0, depth-4.cm-thick, 0]
kickb[2] = [0, depth-4.cm-thick, kick]
kickb[3] = [0, depth-4.cm, kick]
kickb_base = entities.add_face kickb
kickb_base.pushpull -width
#-----------------------------------------------------------------------------
view = model.active_view
view.zoom_extents
#-----------------------------------------------------------------------------
prompts = ["Door Height", "Top Rail Width", "Bottom Rail Width", "Stile Width" ]
values = [100.cm, 10.cm, 10.cm, 3.3.cm]
results = inputbox prompts, values, "Door Frame Dimensions"
height, top, btm, sw = results
#----------------------------------Do Left Door
ld=[] #left style, left door
ld[0] = [0, 0, kick]
ld[1] = [0, 0, height]
ld[2] = [0, thick, height]
ld[3] = [0, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull -sw
x = width/2-sw
ld=[] #right style, left door
ld[0] = [x, 0, kick]
ld[1] = [x, 0, height]
ld[2] = [x, thick, height]
ld[3] = [x, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull -sw
x = sw
ld=[] #top rail, left door
ld[0] = [x, 0, height-top]
ld[1] = [x, thick,height-top]
ld[2] = [x, thick, height]
ld[3] = [x, 0, height]
ld_base = entities.add_face ld
ld_base.pushpull width/2-sw-sw
x = sw
ld=[] #btm rail, left door
ld[0] = [x, 0, kick]
ld[1] = [x, 0, kick+btm]
ld[2] = [x, thick, kick+btm]
ld[3] = [x, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull width/2-sw-sw
x = sw
ld=[] #glazing panel, left door
ld[0] = [x, thick/2, height-top]
ld[1] = [x, thick, height-top]
ld[2] = [x, thick, kick+btm]
ld[3] = [x, thick/2, kick+btm]
ld_base = entities.add_face ld
ld_base.material = Sketchup::Color.new (236,201, 101)
ld_base.material.alpha = 0.7
ld_base.pushpull width/2-sw-sw
#----------------------------------- Do Right Door
x = width/2+sw
ld=[] #left style, right door
ld[0] = [x, 0, kick]
ld[1] = [x, 0, height]
ld[2] = [x, thick, height]
ld[3] = [x, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull sw
x = width-sw
ld=[] #right style, right door
ld[0] = [x, 0, kick]
ld[1] = [x, 0, height]
ld[2] = [x, thick, height]
ld[3] = [x, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull -sw
x = width-sw
ld=[] #top rail, right door
ld[0] = [x, 0, height-top]
ld[1] = [x, thick,height-top]
ld[2] = [x, thick, height]
ld[3] = [x, 0, height]
ld_base = entities.add_face ld
ld_base.pushpull width/2-sw-sw
x = width-sw
ld=[] #btm rail, right door
ld[0] = [x, 0, kick]
ld[1] = [x, 0, kick+btm]
ld[2] = [x, thick, kick+btm]
ld[3] = [x, thick, kick]
ld_base = entities.add_face ld
ld_base.pushpull width/2-sw-sw
x = width-sw
ld=[] #glazing panel, right door
ld[0] = [x, thick/2, height-top]
ld[1] = [x, thick, height-top]
ld[2] = [x, thick, kick+btm]
ld[3] = [x, thick/2, kick+btm]
ld_base = entities.add_face ld
ld_base.material = Sketchup::Color.new (236,201, 101)
ld_base.material.alpha = 0.7
ld_base.pushpull width/2-sw-sw
#-----------------------------------------------------------------------------
prompts = ["Counter Top Height", "Thickness", "Reveal"]
values = [100.cm, 3.3.cm, 1.cm]
results = inputbox prompts, values, "Countertop Optional"
height, th, reveal = results
top=[] #countertop
top[0] = [0, thick, height]
top[1] = [0, thick, height+reveal]
top[2] = [0, 0, height+reveal]
top[3] = [0, 0, height+th]
top[4] = [0, depth, height+th]
top[5] = [0, depth, height]
top_base = entities.add_face top
top_base.pushpull -width
#-----------------------------------------------------------------------------
model.commit_operation
end
#-----------------------------------------------------------------------------
if( not file_loaded?("Cab.rb") )
add_separator_to_menu("Plugins")
UI.menu("Plugins").add_item("Cab") { create_cab }
end
#-----------------------------------------------------------------------------
file_loaded("cab.rb")