Problems with trimming and intersecting surfaces

Hello all,

I’m a bit stressed with the commands to trim or intersect surfaces or polysurfaces. I’m trying to make a very simple script that should give me the intersection curve of a vertical plane (wich belongs to layer1), and a polysurface (wich is in layer2). I’ve tried many things and commands, like “trimbreps”, “trimsurface”, “Splitsurface”… but no one Works. I put the script below, with the command “intersectbreps”. The thing is that it doesn’t give me any error or message, it simply doesn’t do anything. Do you know what could be the error? Thank you a lot


Dim sup1, sup2, s1, s2

sup1 = Rhino.ObjectsByLayer(“Layer2”)
sup2 = Rhino.ObjectsByLayer(“Layer1”)

s1 = Rhino.SelectObjects(“sup1”)
s2 = Rhino.SelectObjects(“sup2”)

Rhino.IntersectBreps “s1”, “s2”


Rhino.IntersectBreps(strBrep1, strBrep2)

is expecting a single object ID in each of the first two arguments. Your variables s1 and s2 contain the number of selected objects and no object ID, and you are passing the two numbers as strings if you set the variables in quotes eg. by using “s1” or “s2” which cannot work.

If you are sure that each layer only contains a single object, just pass the first object returned from these two method results:

sup1 = Rhino.ObjectsByLayer("Layer1")
sup2 = Rhino.ObjectsByLayer("Layer2")

sup1 and sup2 now both contain an Array of object IDs with a single element each.

arrResult = Rhino.IntersectBreps( sup1(0), sup2(0) )

There is no need to select objects before making the intersection. If the result worked, you can select the intersection objects like so:

If Not IsNull(arrResult) Then Rhino.SelectObjects(arrResult)