Hi,
I am trying to create various shapes(2D, 3D both) with webdialog, not inputbox. Im already familiar with the way creates shapes with inputbox and It was a bit easy to learn. Determining variables(with @) -> drawing shape(with add_face, add_line etc.) -> coordinate(Geom::Transformation) are all steps i have done for creating shapes with inputbox.
On the other hand, Webdialog,,,, looked unfamilir. To say exactly, Im not good at HTML and Javascript yet. Now, Im looking for the way how I can draw various shapes in Sketchup with Ruby API and Webdialog. Could you please give me advice or help? Your reply will encourage me to study Ruby API hard.
Again, What I want to know is to make a webdialog can create shapes with variables for length(if the shape is box, and it would be radius or diameter if the shape is sphere), coordinate. Im sharing an example I tried. Id like to apply this code to Webdialog.
toolbar = UI;;Toolbar.new "Box"
cmd = UI;;Command.new("Create_Box") { box }
cmd.small_icon = cmd.large_icon = "box.png"
toolbar = toolbar.add_item cmd
toolbar.show
def box
model = Sketchup.active_model
entities = model.entities
@Length = 0.mm unless @Length
@Width = 0.mm unless @Width
@Height = 0.mm unless @Height
@X = 0.mm unless @X
@Y = 0.mm unless @Y
@Z = 0.mm unless @Z
results = inputbox(['Length', 'Width', 'Height', 'X', 'Y', 'Z'], [@Length, @Width, @Height, @X, @Y, @Z], 'Box')
return nil unless results
@Length, @Width, @Height, @X, @Y, @Z = results
#Points
p1 = [0, 0, 0]
p2 = [@Length, 0, 0]
p3 = [@Length, @Width, 0]
p4 = [0, @Width, 0]
group=entities.add_group
entities=group.entities
face = entities.add_face(p1, p2, p3, p4)
face.pushpull @Height
pos = Geom;;Transformation.new([@X, @Y, @Z])
group.transform! (pos)
end