Script to select all 4 sided surfaces

Hi all, i am looking for a script (or pointers for creating a script) that will highlight all surfaces in a model with a specific number of sides. any help would be fantastic!

Alec

You mean BrepFaces (any N of “sides” i.e. Locus points on the outer loop defining “sides”) or just Surfaces? (sides 3 or 4). Or you just want to find BrepFaces that are in fact Surfaces?

In any case post a demo test case.

thanks Peter. OK, so i have a triangular surface (3 points, 1 single simple surface) that is incredibly small, and a huge number of rectangular surfaces (4 points, 1 single simple surface). i would like to be able to find the tiny triangular surface, without having to go through the painstaking task of selecting each known 4 sided shape and changing its layer in Grasshopper. i know this sounds trivial but i cannon work out he best way of doing it. currently i am doing it by ‘checking’ via area, whether there are in fact and small surfaces, however this does not highlight them in the model, and only alerts me that there is a tiny surface somewhere in the mix… many thanks for you quick reply!

Alec

Hi,
you can try something like this:

Cheers,

Raul

Hi Alec, below python script selects all surfaces with singularities. Hope it helps:

import Rhino
import rhinoscriptsyntax as rs

def find_singularity():
    objs=rs.ObjectsByType(8)
    has_singularity = []
    for obj in objs:
        srf=rs.coercesurface(obj)
        for n in xrange(4):
            if srf.IsSingular(n):
                has_singularity.append(obj)
                break
    if has_singularity:
        rs.SelectObjects(has_singularity)
        
find_singularity()
1 Like

Hi,
How’s this:

import rhinoscriptsyntax as rs
n = 3
nsided = []
rs.EnableRedraw(False)
for obj in rs.ObjectsByType(8): # 8 == surfaces
    edges = rs.DuplicateEdgeCurves(obj)
    if len(edges) == n:
        nsided.append(obj)
    rs.DeleteObjects(edges)
rs.EnableRedraw(True)
rs.SelectObjects(nsided)
1 Like

Thank you Raul, this is very useful!