sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Deleting Component Definition

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 2 Posters 3.4k Views 2 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • K Offline
      ktkoh
      last edited by

      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

      1 Reply Last reply Reply Quote 0
      • Dan RathbunD Offline
        Dan Rathbun
        last edited by

        def_Panel = component_instance.definition def_Panel.clear!

        There is no method named " clear!" for the Sketchup::ComponentDefinition class, nor inherited from any of it's ancestor classes. (You are confusing the Entities#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.
        See Sketchup::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 the Sketchup::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.

        I'm not here much anymore.

        1 Reply Last reply Reply Quote 0
        • K Offline
          ktkoh
          last edited by

          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

          1 Reply Last reply Reply Quote 0
          • 1 / 1
          • First post
            Last post
          Buy SketchPlus
          Buy SUbD
          Buy WrapR
          Buy eBook
          Buy Modelur
          Buy Vertex Tools
          Buy SketchCuisine
          Buy FormFonts

          Advertisement