Insert dynamic component from the component folder by a plugin

I am a newbie to ruby. I have some dynamic components in my default component folder. I have to add an extension with some buttons to insert a specific component. Is that possible?
I found a simple ruby code for a message box when click an extension button. What I have to change here to insert a specific component.
Here is the ruby I found and it’s working.

Please, don’t post an imagen to show your code, post as this link says…

You need to insert ruby code to be executed in…

cmd ="Toolbar Button") {
  #Your code here
1 Like
toolbar = "Test"
cmd ="Test") {
model = Sketchup.active_model
entities = model.active_entities
point =, 20, 30)
transform =
path = Sketchup.find_support_file("drawers 1.skp", "Components/Drawer/")
definitions = model.definitions
componentdefinition = definitions.load(path)
instance = entities.add_instance(componentdefinition, transform)
cmd.small_icon = "ToolPencilSmall.png"
cmd.large_icon = "ToolPencilLarge.png"
cmd.tooltip = "Test Toolbars"
cmd.status_bar_text = "Testing the toolbars class"
cmd.menu_text = "Test"
toolbar = toolbar.add_item cmd

I used as he said. but code is showing like this why?

And It’s working perfectly. thanks. but what I want is, component should come with the cursor until I place it. similar to insert component from component browser. any idea for that?

You have to define a class for pick point. See this exampe

The Model #place_component method places a new component in the Model using the component placement tool.