• Login
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.
  • T Offline
    TIG Moderator
    last edited by TIG 29 Mar 2009, 16:57

    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
    • B Offline
      broomstick
      last edited by 29 Mar 2009, 17:05

      This is a very handy time saver πŸ˜„

      Thanks 😎

      1 Reply Last reply Reply Quote 0
      • C Offline
        Chris Fullmer
        last edited by 29 Mar 2009, 17:12

        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
        • T Offline
          thomthom
          last edited by 29 Mar 2009, 17:15

          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
          • T Offline
            thomthom
            last edited by 29 Mar 2009, 17:35

            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 29 Mar 2009, 17:48

              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
              • T Offline
                TIG Moderator
                last edited by 29 Mar 2009, 17:51

                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
                • T Offline
                  TIG Moderator
                  last edited by 1 Apr 2009, 09:00

                  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
                  • T Offline
                    TIG Moderator
                    last edited by 2 Apr 2009, 08:42

                    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
                    1 / 1
                    • First post
                      9/9
                      Last post
                    Buy SketchPlus
                    Buy SUbD
                    Buy WrapR
                    Buy eBook
                    Buy Modelur
                    Buy Vertex Tools
                    Buy SketchCuisine
                    Buy FormFonts

                    Advertisement