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

[issue] brep trim

$
0
0

@ivelin.peychev wrote:

Could anyone, please, enlighten me why this code doesn’t work:

###################
### trim by box ###
###################
import System
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import time
import math
#import uuid



tol = sc.doc.ModelAbsoluteTolerance

def TST():
    cutter_brep_obj_id = rs.GetObject("select cutting box: ",rs.filter.polysurface)
    cutter_brep_obj = rs.coercebrep(cutter_brep_obj_id)
    to_be_trimmed_ids = rs.GetObjects("select objects to be trimmed: ",rs.filter.surface|rs.filter.polysurface)
    to_be_trimmed = [rs.coercebrep(id) for id in to_be_trimmed_ids if id is not None]
    if cutter_brep_obj_id == None or to_be_trimmed_ids == None: return
    for obj in to_be_trimmed:
        if cutter_brep_obj.Faces.Count > 1:
            print obj.Trim.Overloads[Rhino.Geometry.Brep,System.Double](cutter_brep_obj,tol)
        if cutter_brep_obj.Faces.Count == 1:
            cutter_surface = cutter_brep_obj.Faces[0]
            cutter_plane = cutter_surface.TryGetPlane(tol)[1]
            print cutter_plane[1]
            print cutter_plane[0]
            print obj.Trim.Overloads[Rhino.Geometry.Plane,System.Double](cutter_plane,tol)



if __name__ == "__main__":
    ts = time.time()
    #rs.EnableRedraw(False)
    
    TST()
    
    print "Elapsed time is {:.2f}".format(time.time()-ts)

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5875

Trending Articles