Hi all,
I got a new problem using ruby in sketchup...
I tray to create a dialog box which let user to load some objects inside the "component folder". I've successfully made it but I would like to attached the object loaded to the pointer in order to place it with the mouse like sketchup do when we drag and drop some SKP from desktop to the working window...
here is a simple example :
# First we pull in the standard API hooks.
require 'sketchup'
# Add a menu item to launch that one.
UI.menu("PlugIns").add_item("Load Tree") {
# Method calling.
load_Tree
}
def load_Tree
# Prompt parameters dialogue
prompts = ["X in cm","Y in cm","Z in cm"]
defaults = ["0","0","0"]
list = ["","",""]
input = UI.inputbox prompts, defaults, list, "Origine Point"
pannelType = "MyTree.skp"
model = Sketchup.active_model
entities = model.active_entities
path = Sketchup.find_support_file pannelType ,"Components/"
definitions = model.definitions
componentdefinition = definitions.load path
x0= input[0].to_i / 2.54
y0= input[1].to_i / 2.54
z0= input[2].to_i / 2.54
point = Geom;;Point3d.new x0,y0,z0
transform = Geom;;Transformation.new point
instance = entities.add_instance componentdefinition, transform
if (instance)
UI.messagebox "Tree successfully loaded"
else
UI.messagebox "Failure"
end
end
My goal is to delete the "x,y,z" arguments in the dialog box and place the object with mouse but I can't find anything inside the Google API and I turn in a round reading it...
I think it's possible and quite easy to do that...
Thanks for your suggestions