Untrim command available in Python?

Is it possible to access something like the Untrim command in Python? I want to step through a list of trimmed surfaces and untrim all of them. If not, any suggestions on how to do it?

Well, you could simply script the Untrim command with rs.Command(). Otherwise, there appears to be no rhinoscriptsyntax direct method, so you would need to delve into a little RhinoCommon. Sample code:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino

srfID=rs.GetObject("Select a trimmed surface to untrim",8,preselect=True)
if rs.IsSurfaceTrimmed(srfID):
    srf=sc.doc.Objects.Find(srfID).Geometry
    if isinstance(srf,Rhino.Geometry.Brep):
        face=srf.Faces[0]
        base_face=face.UnderlyingSurface()
        sc.doc.Objects.Replace(srfID,base_face)
        sc.doc.Views.Redraw()

(The above deletes the original input, the untrimmed surface will have the same guid as the original)

–Mitch

_UntrimAll would be the non-scripted solution
just in case…

1 Like