[Req.] remove instance duplicates plugin
-
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.
-
hm...
detecting overlapping bounding boxes are one thing. detecting the same shape... not so easy... -
Newone, when you say 'component instances' do you mean the components that share the same space are the same? or are they different components?
-
@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.
-
@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.
-
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 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. -
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 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! -
An xyz tolerance is possible for bbmax and bbmin... unfortunately I don't have time right now... Can someone else do this part ???
Advertisement