Loop that select biggest Mesh and Nurbs object


#1

Hi,
I have a model in NURBS on layer1 and mesh version of the same thing on layer2 and I need to
select part as a nurbs and then the same part as mesh a then perform an specific action on each pair (NURBS+mesh).

My idea is to create a loop that will find two biggest - in terms of volume or area, geometries, then two second biggest and so on… till it ends with the smallest pair.

I have found some interesting scripts when it comes to selecting geometry by volume but I am getting an error
"

  • Message: ObjectsByType() got an unexpected keyword argument ‘state’

Traceback:
line 6, in SelSrfsByArea, “C:\Users\Dell\Downloads\SelSrfsByArea.py”
line 77, in , “C:\Users\Dell\Downloads\SelSrfsByArea.py”
"SelSrfsByArea.py (2.6 KB)


#2

That’s actually my script… I am wondering if you have an old version of Rhino (Mac?) in which the state argument has not yet been implemented in ObjectsByType()…? There are some workarounds, but it’s better to update your Rhino…

That script will only work on surfaces/polysurfaces, there is another one for meshes… I don’t know where you found the original.


#4

Thanks, I will try to reinstall/update.
I have found it here in some very old topic ;).
Anyway do you have any idea how to solve my problem? Maybe I could select these pair by finding objects with
the same postion of gumball.


#5

Well, if you don’t know which goes with which, yes, you could try to select with a number of criteria to be reasonably sure. Fastest I guess will be to find which objects have the same bounding box size and location (within tolerance), then if a match is found, do further checking by area/volume (within tolerance) etc…

Of course, another way to always know what NURBS part goes with what mesh part is to create the mesh directly from the NURBS model in the script, then it’s trivial…


#6

hmm… that not so trivial for me but I manged to come up with something.
I am giving names to NURBS from 1 to total amount and then changing layer to meshes and giving names from 101 to total amount of meshes. Then selecting NURBS - 1 and MESH - 101. It kind of works but sometimes it selects randomly for example 14 - nurbs and 154 - mesh. Pair300_cmd.py (9.9 KB)