I need to insert some geometry from a skp file.into the model
The API seems to have no way to do this except to
- load the file as a component definition
- Add an instance of the definition.
- explode the instance.
This all works fine, but then I want to clean up and erase! the definition.
This produces the error "“Cannot determine parent of entity”.
Here’s some code:
mod = Sketchup.active_model # Open model ent = mod.active_entities # All entities in model dimfolder = "Plugins/2DXY_SiteSurvey/resources/" dimfile = "dimft.skp" filepath = Sketchup.find_support_file dimfile, dimfolder #load the file as comp def dimcompdef = mod.definitions.load filepath # now add an instance point = Geom::Point3d.new 0,0,0 transform = Geom::Transformation.new point instance = ent.add_instance dimcompdef, transform #now explode the instance entarr = instance.explode #need to delete the definition status = dimcompdef.erase!