From 04da9732a8091a0a2e76ab48f5dfcc0dbe050c36 Mon Sep 17 00:00:00 2001 From: Alain Date: Sat, 23 May 2015 08:38:05 +0200 Subject: [PATCH] add Giulio's mod #RH-30298 --- Scripts/rhinoscript/surface.py | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/Scripts/rhinoscript/surface.py b/Scripts/rhinoscript/surface.py index 0503077b..741ed006 100644 --- a/Scripts/rhinoscript/surface.py +++ b/Scripts/rhinoscript/surface.py @@ -2053,23 +2053,20 @@ def TrimBrep(object_id, cutter, tolerance=None): else: cutter = rhutil.coerceplane(cutter, True) if tolerance is None: tolerance = scriptcontext.doc.ModelAbsoluteTolerance breps = brep.Trim(cutter, tolerance) - if scriptcontext.id == 2: #gh - return breps + rhobj = rhutil.coercerhinoobject(object_id) + if rhobj: + attr = rhobj.Attributes if scriptcontext.id == 1 else None #no attributes in gh + rc = [] + for i in range(len(breps)): + if i==0: + scriptcontext.doc.Objects.Replace(rhobj.Id, breps[i]) + rc.append(rhobj.Id) + else: + rc.append(scriptcontext.doc.Objects.AddBrep(breps[i], attr)) else: - rhobj = rhutil.coercerhinoobject(object_id) - if rhobj: - attr = rhobj.Attributes - rc = [] - for i in range(len(breps)): - if i==0: - scriptcontext.doc.Objects.Replace(rhobj.Id, breps[i]) - rc.append(rhobj.Id) - else: - rc.append(scriptcontext.doc.Objects.AddBrep(breps[i], attr)) - else: - rc = [scriptcontext.doc.Objects.AddBrep(brep) for brep in breps] - scriptcontext.doc.Views.Redraw() - return rc + rc = [scriptcontext.doc.Objects.AddBrep(brep) for brep in breps] + scriptcontext.doc.Views.Redraw() + return rc def TrimSurface( surface_id, direction, interval, delete_input=False):