Is it possible to create a command to import an item into sketchup?

I have a working prototype now: All i have to do is provide the path to the skp file and the program will dynamically create the ruby code to import that in. very basic so far but it works. I need to learn how to attach the new component to the mouse cursor.

Try to replace:

instance = model.entities.add_instance(component_definition, Geom::Transformation.new)

by

model.place_component component_definition, false

as @dezmo suggested in this post Insert dynamic component from the component folder by a plugin - #6 by dezmo

(edited following @dezmo post below)

The Model #place_component method does not return an instance but the model. ( or ‘nil’ ) :innocent:

Corrected! Thanks @dezmo

That worked, thanks dezmo and rtches.

Any easier way to send these scripts to sketchup? smaller ruby console window or dockable version or can i send them via command line to sketchup.exe?

You can code a small extension asking for a path and pasting your path there…
Or you can code an extension with your own html dialog doing it entirely inside SketchUp