Deleting Component Definition
-
I have not been able to delete a component definition
flatPanel = ent.add_group fp_face = flatPanel.entities.add_face (@pt) fp_face.pushpull(-fp_T) component_instance = flatPanel.to_component component_instance.definition.name = ("FlatPanel") component_instance.layer = "NewPanel" def_Panel = component_instance.definition UI.messagebox("Panel Definition Name " + def_Panel.to_s + "component_instance " + component_instance.to_s ) component_instance.erase! def_Panel.clear!
I create this panel and can delete the instance but the cannot delete the definition. The message box shows values for both the instance and definition. Run fails with error " Cannot determine parent of entity" When I comment out the last line the code runs and deletes the component instance.
Keith
-
def_Panel = component_instance.definition def_Panel.clear!
There is no method named "
clear!
" for theSketchup::ComponentDefinition
class, nor inherited from any of it's ancestor classes. (You are confusing theEntities#clear!
method, which only acts upon instance objects within a definition's [or the model's] entities collection.)There was never a specific method to delete a certain definition, before the version 2018 API.
SeeSketchup::DefinitionList#remove()
, which will also remove all instances of the definition argument as well as the definition object.In older versions the only workaround is to do a
purge_unused
upon theSketchup::DefinitionList
collection as a whole. This sometimes can result in the deletion of wanted components (perhaps used by other plugins, but not yet having instances in the model.)
If you must do the purge, try to save up the names and paths of all the other unused components, and reload them after you do the purge that results in removing your definition.
The danger with this workaround is that you will also be purging "internal components" which are sets of geometry the user has created but not yet saved out to a component SKP file. -
Thanks Dan for the explaination. I had tried other terms than clear that was just the last version. I will let the user take care of deleting the old panel def if they need to remake the same panel. The neW panel will automatcaly get the new #diget Sketchup adds to components with the same name. Now I know why I couldnt delete def. Never saw the purge unused.
THANKS AGAIN ans. with exp are very helpful.
Keith
Advertisement