Insert object on mouse click

Hello everyone, I wrote a small file Api Ruby, with which I create a pillar, setting the two
measurements at the base of the pillar, side along the x-axis and y and the height, all by entering the measurements
inputbox… in creating the face for the “pushpull”, the first point equals pt1 [0, 0, 0]
origin of the X, Y, Z axes … I would like the pillar object to remain momentarily attached
cursor and subsequently inserted on screen at a precise point at the click of the mouse insertion,
I hope I have explained myself… Possibly? What should I write to the Ruby file, for this insertion wait
pillar object… Thank you.

Greetings

Joseph

Pil_1_piano.rb (1.1 KB)

You can use model.place_component for that:

Thanks for the answer, I’ve already tried watching " model.place.component",
but I understood very little, if he was kind enough to show me with practical example
using my ruby file, it would be great…Thank you

Joseph

Currently your code adds a group and then creates geometry in it.

You could add a new definition into the model’s definitions, and then add your geometry into its entities context, much as you did with the group.entities.
http://ruby.sketchup.com/Sketchup/DefinitionList.html#add-instance_method
http://ruby.sketchup.com/Sketchup/ComponentDefinition.html#entities-instance_method

Then use model.place_component(…) with the reference to this new component definition.


Also note that you should wrap your method inside your own module, so that it remains separate from everyone elses...
1 Like

I understand very little…Thanks all the same

Joseph.