Selecting Dims based on value

Are there arguments or commands within Rhinoscript or Python that can select dimensions based on their value?

We have a script we use to automatically pull dimensions between holes on the edge of a part, and often times this script returns dims of 0 value because holes are in alignment with each other. We then have to go by hand and delete out these 0 value dims from each part, this would be easier if we could add an argument to the initial script that would suppress or select and delete the 0 value dim object. This could also be a separate script ran after applying dims to the parts, where it cleans up all of the 0 value dim objects at once.

Hi Mason,

The snippet below will select all ‘selectable’ dimensions that have a value exactly equal to 0:

import rhinoscriptsyntax as rs

all_dims = rs.ObjectsByType(512)

for dim in all_dims:
    if rs.DimensionValue(dim) == 0:
        rs.SelectObject(dim)

Does that work for you?

-Willem

i tried to copy in the text and test it, but i am getting this error message:

@Mason, this seems to work:

import rhinoscriptsyntax as rs
import Rhino
all_dims = rs.ObjectsByType(512)

for dim in all_dims:
    
    dim = rs.coercerhinoobject(dim)
    if type(dim) !=  Rhino.DocObjects.TextObject:
        if rs.DimensionValue(dim) < 0.00001:
            rs.SelectObject(dim)
1 Like

image

this error message comes up when i try to run from alias, but no errors found when running through debugger.
the script is located within the search path locations.

@Mason this means it is still finding objects with objectsbytype(512) that are neither dimensions nor textobjects
In fact this finds all annotation objects.
To see which others it finds you can temporarily put the following code:
print type(dim)
continue
before the first of statement and report this back.
Or send an example file where the code fails.

@Mason

this code should work better:

import rhinoscriptsyntax as rs
import Rhino
all_dims = rs.ObjectsByType(512)

for dim in all_dims:

    dim = rs.coercerhinoobject(dim)
    #print type(dim)
    #continue
    if type(dim) == Rhino.DocObjects.TextObject or Rhino.DocObjects.LeaderObject or Rhino.DocObjects.CentermarkObject:
        continue
    else:
        if rs.DimensionValue(dim) < 0.00001:
            rs.SelectObject(dim)