sketchucation logo sketchucation
    • Login
    πŸ€‘ SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

    [code] ComponentDefinition-delete

    Scheduled Pinned Locked Moved Developers' Forum
    9 Posts 5 Posters 2.3k Views 5 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.
    • TIGT Offline
      TIG Moderator
      last edited by TIG

      This script adds a new method for a ComponentDefinition...
      component_definition.delete
      It mimics deleting a component-definition from the component-browser.
      All instances of the component-definition are erased (including any locked ones)
      and the component-definition itself is then purged.
      However, any other 'unused' component-definitions remain unaffected...
      unlike "definitions.purge_all", which purges everything that's unused...
      [EDIT: AlexM has written a better version - recommend you get it here - http://www.sketchucation.com/forums/scf/viewtopic.php?p=145255#p145255]
      I have removed my 'code' 20090402...

      TIG

      1 Reply Last reply Reply Quote 0
      • broomstickB Offline
        broomstick
        last edited by

        This is a very handy time saver πŸ˜„

        Thanks 😎

        1 Reply Last reply Reply Quote 0
        • Chris FullmerC Offline
          Chris Fullmer
          last edited by

          Yeah, thats great. Thanks TIG!

          Chris

          Lately you've been tan, suspicious for the winter.
          All my Plugins I've written

          1 Reply Last reply Reply Quote 0
          • thomthomT Offline
            thomthom
            last edited by

            I wonder what the performance impact is if there's many unused components in a model. Where I work I've seen models which has been worked on for years without every being purged... But until we get a native function this is the only way I can imagine it working.
            Thanks for looking into this TIG.

            Thomas Thomassen β€” SketchUp Monkey & Coding addict
            List of my plugins and link to the CookieWare fund

            1 Reply Last reply Reply Quote 0
            • thomthomT Offline
              thomthom
              last edited by

              Personally I purge like every five minutes. Hooked up to a hotkey. But I'm a bit afraid to just purge stuff from other people's model when I write my plugins. But your method is a fine workaround in any case. I expect that's what I'll be using.

              Thomas Thomassen β€” SketchUp Monkey & Coding addict
              List of my plugins and link to the CookieWare fund

              1 Reply Last reply Reply Quote 0
              • W Offline
                wolfy
                last edited by

                Thanks Tig! Will come in usefull when rendering with Vray since getting rid of any component instances should make render times quicker (after a file copy of course).

                1 Reply Last reply Reply Quote 0
                • TIGT Offline
                  TIG Moderator
                  last edited by

                  You could also use my Purge.rb that purges all Components, Layers, Materials and Styles in one go... Then your model would be 'trim'... Later on a few unused things won't give much of an overhead...

                  I've tried "definition.delete" with 30+ unused definitions and it took 'no time at all'...

                  TIG

                  1 Reply Last reply Reply Quote 0
                  • TIGT Offline
                    TIG Moderator
                    last edited by

                    A better version has been written by AlexM http://www.sketchucation.com/forums/scf/viewtopic.php?p=145255#p145255
                    I recommend you change to that and I have added a note to the initial page on this thread...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      AlexM has found the basis of doing this without a new method at all...

                      model.start_operation("Delete Definition")
                        definition.entities.erase_entities(definition.entities.to_a)
                      model.commit_operation
                      

                      I'm removing my 'code' and rewriting ComponentInstance-add_entites.rb to suit...

                      TIG

                      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