Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5887

IsValid: Brep vs. components

$
0
0

@spb wrote:

When a brep's IsValid is False, shouldn't the relevant components' IsValid also be False?

Running the following code on the breps in IsValid.3dm (32.0 KB)
shows where this is not the case.

import rhinoscriptsyntax as rs

def checkBrepComponents(collection):
    print '-'*80
    print collection.ToString()
    print 'Component count:', collection.Count
    print "Indices of invalid components:",
    for i in range(collection.Count):
        if not collection[i].IsValid: print i,
    print

def main():
    idBreps = rs.GetObjects("Select surfaces/polysurfaces", preselect=True,
            filter=rs.filter.polysurface)
    if idBreps is None: return
    
    for i, idBrep in enumerate(idBreps):
        print '-'*80 + '\n' + '-'*80 + '\n' + "Brep:", i
        rgBrep = rs.coercebrep(idBrep)
        
        b, log = rgBrep.IsValidWithLog() # rgBrep.IsValid
        if not b:
            print log
            map(checkBrepComponents, (rgBrep.Faces, rgBrep.Edges,
                    rgBrep.Vertices, rgBrep.Loops, rgBrep.Trims,
                    rgBrep.Surfaces, rgBrep.Curves2D, rgBrep.Curves3D))

if __name__ == "__main__": main()

Thank you,
Steve

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 5887

Trending Articles