Removing unwanted curves

How to make it so that the desired contour remains and the rest are removed?

import rhinoscriptsyntax as rs

plane = rs.WorldXYPlane()
plane = rs.RotatePlane(plane, 0, [1,0,0])
Rect = rs.AddRectangle( plane, 50.0, 105 )
RectArrayCurve = rs.AddRectangle( plane, 10, 5)

rectBoolean = [ ]

for i in range(10,100,10):
    translation = (0,i,0) #Vector
    copyRectArray = rs.CopyObject(RectArrayCurve,translation)



for j in range(len(rectBoolean)):

    Rect = rs.CurveBooleanDifference(Rect,rectBoolean[j])
    print j
    if j == (len(rectBoolean)-1):
        print j

You should pass the whole rectangles array to the CurveBooleanDifference function instead of iterating on each one.

Why is there no python code here?

Here is the python option, but apparently it doesn’t support arrays for that function.

So instead you will have to do an iteration storing the result of each boolean difference to a variable and using it as Curve A with the next subtracting curve in the next iteration.

Not too difficult to translate. It’s a static function that returns a list of curves and it’s parameters are a curve and a list of curves.

The version of the function you’ve shown is obsolete but you may need to use it if you’re running Rhino V5. I’ve used the version of the function that takes a tolerance as a third parameter. I used the document tolerance, you could hard code a value or use an input value if desired. (10.5 KB)

No need to use RhinoScriptSyntax and iteration, you can call any of the RhinoCommon functions from Python.

You could use the Region Difference component for this as well.


Thanks Kevin.