sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    πŸ›£οΈ Road Profile Builder | Generate roads, curbs and pavements easily Download

    [Req.] remove instance duplicates plugin

    Scheduled Pinned Locked Moved Plugins
    10 Posts 4 Posters 1.5k Views 4 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.
    • N Offline
      NewOne
      last edited by

      Hy! I need a script that removes all component instances that share same space. (I guess I'd better say component instances who have same transformations).
      I usually extract cutting lists from my furniture projects and if accidentally some parts are copied over themselves, this thing can not be identified visually, but in my cut list I will have more parts than I need.
      It would be nice to identify other types of geometry that coincide (let's say a group over a component having same shape)

      I did attached a visual example because I am not sure if it's really understandable what I mean.
      Thank you.


      instance duplicate.png

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

        hm...
        detecting overlapping bounding boxes are one thing. detecting the same shape... not so easy...

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

        1 Reply Last reply Reply Quote 0
        • R Offline
          remus
          last edited by

          Newone, when you say 'component instances' do you mean the components that share the same space are the same? or are they different components?

          http://remusrendering.wordpress.com/

          1 Reply Last reply Reply Quote 0
          • N Offline
            NewOne
            last edited by

            @remus said:

            Newone, when you say 'component instances' do you mean the components that share the same space are the same? or are they different components?

            Components that share the same space are the same. Let's say resulted from duplicating and not moved.

            1 Reply Last reply Reply Quote 0
            • N Offline
              NewOne
              last edited by

              @thomthom said:

              hm...
              detecting overlapping bounding boxes are one thing. detecting the same shape... not so easy...

              Trying to use vertex number and position to match geometry shape might make this possible? (if the number of verticles is identical for both component instance and group and their positions coincide, in that case those elements are overlapping, right?) -I guess this can be used to identify free geometry overlapping a component/group in the same manner.

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

                So you want a 'duplicate_check' tool so that any overlaid components are found ? Something like this ?

                
                ### (c) TIG 2009
                require 'sketchup.rb'
                def duplicate_check()
                  model=Sketchup.active_model
                  defns=model.definitions
                  ss=model.selection
                  ss.clear
                  dup=0
                  defns.each{|defn|
                    bbs=[]
                    defn.instances.each{|inst|
                      bb=inst.bounds;bbmax=bb.max;bbmin=bb.min
                      if bbs.include?([bbmax,bbmin])
                        ss.add(inst)
                        dup+=1
                      end#if
                      bbs<<[bbmax,bbmin]
                    }
                  }
                  puts(dup.to_s+" Duplicated Instances Highlighted...")if dup>0
                end#def
                
                

                To use: type 'duplicate_check' in the Ruby Console. If there are any duplicated then their number is shown in Console and they are highlighted - use 'delete' key or Move etc as desired...

                This only traps duplicate instances of each definition BUT could be adjusted to find all duplicated bbs of any definition instances (which'd include groups too - though it'd be very easy to have duplicate bbs for these with different geometry inside !) ? Checking for duplicated 'shape' is going to be almost impossible if there's any sort of complexity !

                TIG

                1 Reply Last reply Reply Quote 0
                • N Offline
                  NewOne
                  last edited by

                  @tig said:

                  To use: type 'duplicate_check' in the Ruby Console. If there are any duplicated then their number is shown in Console and they are highlighted - use 'delete' key or Move etc as desired...

                  It only tells "nil" in console and doesn't highlight anything.
                  I had 3 component instances in model, two of them were one over the other, and the third was at a distance.

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

                    Works for me. Are the overlapping instances the same definition and are they exactly overlapped? Copy one and move it by a corner snapping back over the other - you should then get a highlighted instance when tested...

                    TIG

                    1 Reply Last reply Reply Quote 0
                    • N Offline
                      NewOne
                      last edited by

                      @tig said:

                      Works for me. Are the overlapping instances the same definition and are they exactly overlapped? Copy one and move it by a corner snapping back over the other - you should then get a highlighted instance when tested...

                      It works now. It is possible that I did not overlapped exactly. Now I tried again moving back by exact distance. Can you add a tolerance ? +/- 0,1mm ? Bigger tolerance is easy identified by eye.
                      Thank you for the script!

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

                        An xyz tolerance is possible for bbmax and bbmin... unfortunately I don't have time right now... Can someone else do this part ??? πŸ˜„

                        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