def sphere @mod = Sketchup.active_model @ent = @mod.active_entities @Radius = 1000.mm unless @Radius @X = 0.mm unless @X @Y = 0.mm unless @Y @Z = 0.mm unless @Z #WebDialog @dlg=UI::WebDialog.new("Create Sphere", false,"WDID",200,300,10,10,true) html = <<-HTML
HTML @dlg.set_html(html) #Webdialog can call to perform function @dlg.add_action_callback("sphere") {|d,p| p.gsub!("?",""); tokens=p.split("&"); puts p tokens.each{|t| var,val = t.split("="); puts t case var when 'Radius' then @Radius = val.to_l when 'X' then @X = val.to_l when 'Y' then @Y = val.to_l when 'Z' then @Z = val.to_l end } #Drawing shapes @mod.start_operation "Create Sphere" center = [@X,@Y,@Z] circle = @ent.add_circle center,[0,0,1], @Radius face = @ent.add_face circle face.material = Sketchup::Color.new(255,0,0) face.material.alpha = 0.3 group = @ent.add_group face path = @ent.add_circle [@Radius,0,0],[0,1,0], @Radius+1 face.followme path @ent.erase_entities path @mod.commit_operation }; RUBY_PLATFORM =~ /(darwin)/ ? @dlg.show_modal() : @dlg.show(); end sphere