Thks dan,i’m also troubled by this question,I try a test.rb
as the code
$mod = Sketchup.active_model #
$ent = $mod.entities #
#sel = mod.selection #
#
class Creatgz
def onLButtonDown flags,x,y,view
ip1 = Sketchup::InputPoint.new
ip1.pick view,x,y
@ip = ip1.position
crt_wrb
end
def crt_wrb
prompts = ["high", "wight", "depth"] #
defaults = ["2400mm","800mm","600mm"]
yjgz = UI.inputbox(prompts, defaults, "test")
h = yjgz[0] #
w = yjgz[1] #
d = yjgz[2]
h = h.to_i.mm
w = w.to_i.mm
d = d.to_i.mm
@wrb = [] #
#
box1 = $ent.add_face [0,0,0],[w,0,0],[w,d,0],[0,d,0]
box1.pushpull -h
box1_group = $ent.add_group box1.all_connected
lb = box1_group.to_component
@wrb << Sketchup.active_model.active_entities[-1] #
box2 = $ent.add_face [w*2,0,0],[w*3,0,0],[w*3,d,0],[w*2,d,0]
box2.pushpull -h
box2_group = $ent.add_group box2.all_connected
rb = box2_group.to_component
@wrb << Sketchup.active_model.active_entities[-1] #
wrb_newname = Sketchup.active_model.entities.add_group (@wrb) #
wrb_newname = wrb_newname.to_component #
$ent.transform_entities @ip,wrb_newname
end
end
cm1 = UI::Command.new("test-box"){
Sketchup.active_model.select_tool Creatgz.new
}
toolbar = UI::Toolbar.new"test-box"
toolbar.add_item cm1
toolbar.show
how can I put the component when my code create the test-box at the point I want to,and it can be catch the mid-point or endpoint. at the same time, we can see the icon like this
I have searched many examples of similar problems in the forum,but there’s no completed code。can u help me finish the code then i can understand the methods to put components.Thks again!