How to remove self-intersections on non-planar curve using Rhinoscript

Hi everyone

I am quite new to Rhino and I am trying to create a surface from a non-planar curve. The problem is that I need the surface to be bigger than the curve by a certain offset (I’ve been using 2mm), so I cannot just use Patch with Trim.
I have used the command OffsetCrvOnSrf to make a curve slightly bigger than the original one on my surface, however since the curve is quite complex the larger curve has many self-intersections.

Is there an easy way to create the surface without removing the self-intersections by e.g. using the boundary of the curve, if there is such a thing? Or does anyone know how to remove the self intersections automatically using python and rhinoscriptsyntax? I need to repeat the same procedure on many curves so it would be cool to have it automatic and independent of size.

I have attached an example rhino file as well as the code I use to create the curves. The example layer in the Rhino file has a surface that I made by hand of how I need it to look.

I am also new to these forums so if I have not provided all the required information I apologize.
I would appreciate any help! :slight_smile: Thanks!

example_surface.3dm (4.0 MB) (4.3 KB)

Hi Lara - in Rhno, try this:

Select your surface.
Start CreateUVCrv
Select the curve to flatten with the surface.
Offset the flattened curve.
CurveBoolean to get rid of the self intersections.
ApplyCrv this curve plus the outer rectangle to the surface.


1 Like

Hi Pascal

Thanks for your help! It works perfectly in Rhino :smiley: Now I am trying to automate it using Python and am struggling a bit with the first step. The others also work from Python.

As far as I can tell the CreateUVCrv does not have an equivalent rhinoscript function so I am using rs.Command. However I don’t manage to select both the surface and the curve automatically from Python.
The command I use is:

rs.SelectObject(patchId) # patchId is the guid of the surface
rs.SelectObject(curveId) # curveId is the guid of the curve

Is there a way of making Rhino continue reading the next line after the command to automatically select the curve and not wait for user input before continuing? Or another way to avoid it waiting for a user to select the curve?


Hi Lara - when you create objects using rs.Command() you can get the results like this:

rs.Command(etc etc)
if rs.LastCommandResult() == 0:
    newIds = rs.LastCreatedObjects()

Does that help?


Hi Pascal
I think I am stuck a small step before your answer would apply :sweat_smile: I am not able to create the flat UV curve using `rs.Command(’_-CreateUVCrv’) because it wants me to manually select the curve (the one still on the surface) but I would like to select it automatically using its guid.
If have tried selecting both objects (surface and curve) before running the command or selecting the surface before and the curve after the command (as I wrote above) but it always wants this user input. Is there a way to make rs.Command work without the user having to manually select the curve?

I added a picture below of the point where it wants user input (the surface is correctly selected but the curve is not). And I am running the command from python with the same three lines as above.

I hope what I am asking makes sense :smiley:

Ah - ok - use SelId in the command string.
Hold on, I’ll make an example.

def test():
    srfId = rs.GetObject('Select a  surface', filter = 8, preselect=True)
    if not srfId: return
    crvId = rs.GetObject('Select a  curve', filter = 4, select=False)
    if not crvId: return

    rs.Command ('CreateUVCrv SelId ' + str(crvId) +  ' Enter')



Thank you very much! This is exactly what I was looking for, it’ working now :smiley:

1 Like