Request: untrimmed Intersection script

Hi all, many times I need to find the intersection between 2 surfaces that are trimmed and their edges are not close enough to join and at the same time they don’t intersect to obtain the intersection.
Apart from that these surfaces may have other areas trimmed that need to stay as they are.
No matter the cause, what I usually do is, copy those surfaces to a temp layer, untrim both surfaces keeping the trim object, create the intersection curve again and then update the trim object curve with the new intersection and trim the surfaces again.
I don’t know if its possible with scripts to select 2 trimmed surfaces and obtain the intersection of these curves as if they were untrimmed.

This is a typical case

and what I need is recalculate the intersection between the green and blue surfaces

Hi Joaquín

I adapted a script I use for trimming by base surface.
Here it is

import Rhino

def base( obref ):
  face = obref.Face()
  sur = face.DuplicateSurface()
  surid = Rhino.RhinoDoc.ActiveDoc.Objects.AddSurface( sur )
  return surid

def main():
  result, obrefs = Rhino.Input.RhinoGet.GetMultipleObjects(
      'Surfaces to intersect ?', True, 
      Rhino.DocObjects.ObjectType.Surface )
  if result != Rhino.Commands.Result.Success:
    return
  idlist = []
  for obref in obrefs:
    sid = base( obref )
    idlist.append( sid )
  Rhino.RhinoDoc.ActiveDoc.Objects.UnselectAll()
  for sid in idlist:
    Rhino.RhinoDoc.ActiveDoc.Objects.Select( sid )
  Rhino.RhinoApp.RunScript( '_Intersect', True )
  Rhino.RhinoDoc.ActiveDoc.Objects.Delete( idlist, True )
  Rhino.RhinoDoc.ActiveDoc.Views.Redraw()

main()

HTH, regards

1 Like

Hi Emilio, thanks for sharing it!
Can you please tell me how to make it work?
Do I have to save it as rvb and create a button with ! _-LoadScript? because I tried it without luck…
I don’t know much about scrips.

No, this is a Python script, the command is different.

You have to write

_-RunPythonScript (

<copy the script here>

)

in the button.

Thanks a lot, this script is great!

There is an updated version of this great scritp here:

https://discourse.mcneel.com/t/python-script-stops-working-on-v5/92327/2?u=laborda

1 Like