after I imported a FBX model I got a lot of buggy NURBS surfaces. Is there a quick way to repair them? My current workflow: _UntrimBorder → set _KeepTrimObjects=yes, choose surface and untrim. Now trim the clean surface with the border curve again.
I tried _RebuildEdges, but it doesn’t help. Is there an other command to do it in one step?
today I run in the situation again and try to repair the attached surface per script, but nothing happens. I have a lot of this surfaces in my model. Do you know a solution?
! _-RunPythonScript (
import rhinoscriptsyntax as rs
import scriptcontext as sc
import System.Collections.Generic.IEnumerable as IEnumerable
import System.Double as sd
Get the 3d edge curves that you will be splitting with.
Reverse any that come from reversed trims.
Split with those curves.
Now the face that you want to keep will
not have any reversed trims.
tol = sc.doc.ModelAbsoluteTolerance
id = rs.GetObject(filter = 8, preselect=True)
if not id: return
brep = rs.coercebrep(id)
bb = brep.GetBoundingBox(True)
face = brep.Faces
edges = brep.Edges
trims = brep.Trims
for i in range(edges.Count):
crv = edges[i].ToNurbsCurve()
x = trims.IsReversed()
srf = face.UnderlyingSurface()
temp = srf.ToBrep()
tFace = temp.Faces
newBrep = tFace.Split(crvs, tol)
for brepFace in newBrep.Faces:
rev = False
for trim in brepFace.OuterLoop.Trims:
rev = True
if __name__== '__main__':RetrimSrf()
I started your latest script per _-RunPythonScript "Full path to py file inside double-quotes"
and it works fine.
General I try to keep scripts within toolbar buttons (for easier update and transportation to new Rhino versions) and I wonder why your script doesn’t work if I copy the py code within () of this code. Do you see an aspect I have overseen - complete copy at the end of the post. This version makes nothing, no retrim, no messages and no errors.
Often only some surfaces of a polysurface needs a retrim. Could you modify the script for cleaning polysurfaces too please?
It’s the same problem like above which can be fixed per the script from Pascal. Only it’s not so easy to explode the polysurface, start the script and look for the critical surface. Or would the script be to slow for a polysurface, if all surfaces would be retrimmed?
Also I noticed that your file has a very rough tolerance setting of 0.1mm, is this your setting or the result of opening the file you got from your customer in Rhino? In what program was the file made?
Thank you very much Gijs, the script is a big helper now.
Also thank you for the background info so I can try to get better models in the future. My client isn’t creating the model, he got the model by his client, so I don’t have a direct contact to the model creator. But your information are very detailed and I hope to get them to them to the source creator.