Select objects

Next
 From:  pixelhouse
9658.1 
Hello friends,

I'm searching for an script that can select small objects, to delete small things like screws, springs and washers.
I had an script for Cinema 4d that is written in Phyton, but it dosn't run in R19 and R 20....
This one was extrem helpfull and makes a fast workflow to clean up SW-models for visualisations.
In Solidworks itself it is not possible to delete small tings automaticly.
I'm not sure if its possible to select small things via a script about the volume or the size or the point-count.

Maybe there is such a script already?

Thank you for any Tips and ideas :)

Kind regards
Jörg
Das Leben ist ein Spaziergang. Manchmal bei beschissenem Wetter ;)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
9658.2 In reply to 9658.1 
Change your values as you want! ;)

script: /* Select by length */ var min = 1.0, max = 5.0; var crvs = moi.geometryDatabase.getObjects().getCurves(); for ( var i = 0; i < crvs.length; ++i ) { var crv = crvs.item(i); var len = crv.getLength(); if ( len>= min && len <= max ) { crv.selected = true; } }

script: /* select biggest curve */ var curves = moi.geometryDatabase.getObjects().getCurves(); var maxlen = -1; var maxcrv = null; for ( var i = 0; i < curves.length; ++i ) { var crv = curves.item(i); if ( crv.hidden || crv.locked ) { continue; } var thislen = crv.getLength(); if ( thislen> maxlen ) { maxlen = thislen; maxcrv = crv; } } if ( maxcrv != null ) maxcrv.selected = true;

script: /* select smallest curve*/ var curves = moi.geometryDatabase.getObjects().getCurves(); var minlen = 1e100; var mincrv = null; for ( var i = 0; i < curves.length; ++i ) { var crv = curves.item(i); if ( crv.hidden || crv.locked ) { continue; } var thislen = crv.getLength(); if ( thislen < minlen ) { minlen = thislen; mincrv = crv; } } if ( mincrv != null ) mincrv.selected = true;
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
9658.3 In reply to 9658.1 
And a couple other ones here:
http://kyticka.webzdarma.cz/3d/moi/#SelectTiny

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pixelhouse
9658.4 In reply to 9658.2 
Hi Pilou,

thank you for your response :)
I have copied the script and add a short cut, but only curves will be selected.
There are some lines in the code with "curves" :) I need to select objects, no curves. I'm not confirm with scripting.

This script from Petr's MOI page seems to do this :)

script: /* Select objects smaller than the given size */ var size = 1.0; var objs = moi.geometryDatabase.getObjects(); for ( var i = 0; i < objs.length; ++i ) { var obj = objs.item(i); var bbox = obj.getBoundingBox(); if ( bbox.diagonalLength < size ) obj.selected = true; }

Thanks a lot :)
Das Leben ist ein Spaziergang. Manchmal bei beschissenem Wetter ;)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pixelhouse
9658.5 In reply to 9658.3 
Thank you Michael,

this script works fine :)
Das Leben ist ein Spaziergang. Manchmal bei beschissenem Wetter ;)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
 From:  Frenchy Pilou (PILOU)
9658.6 In reply to 9658.4 
Seems you right...

EDITED: 21 Jan 2020 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All