We already have a preferred way to do this:
skp = UI.openpanel("Import Model","","SketchUp Model (SKP)|*.skp||"))
return if skp.nil? # user cancelled
mod = Sketchup::active_model
cdef = mod.definitions.load(skp)
return unless cdef # good practice
# could be "next unless cdef" inside a loop
point = Geom::Point3d::new( 10, 10, 0 ) # loaded from external file
cinst = mod.active_entities.add_instance(
cdef,
Geom::Transformation::new( point )
)
If no errors occur, the instance can be exploded:
cinst.explode if cinst && cinst.respond_to?(:explode)
Once done inserting components, if all are exploded, purge the definitions:
mod.definitions.purge_unused()
see: DefinitionList#load
and: Entities#add_instance