Thanks for the suggestions & in answer to the questions:
Yes, I’ve had it work with using the CurveBoolean command from within the interface, quite happily.
I like the idea of just pulling in the CurveBooleanUnion function to my script to debug (previously I’d been adding debug comments to the curve.py file which required a restart every alteration). This leaves me with 2 questions:
- how would I import utility as rhutil in my own script so that the CurveBooleanUnion function will work? I’ve tried but it states there is no module called utility!
- From my debugging it looks like the function is creating a valid curve in out_curves and appends it to curves. Again, no exception is being raised. Please excuse the formatting. I’m not having much luck getting the <pre><code> tags behaving properly in the preview.
From the following code, I get the following output:
print "in CurveBooleanUnion"
"""Calculate the union of two or more closed, planar curves and
add the results to the document. Note, curves must be coplanar.
curve_id = list of two or more close planar curves identifiers
The identifiers of the new objects.
in_curves = [rhutil.coercecurve(id,-1,True) for id in curve_id]
if len(in_curves)<2: raise ValueException("curve_id must have at least 2 curves")
out_curves = Rhino.Geometry.Curve.CreateBooleanUnion(in_curves)
curves = 
print "created out_curves"
print "parsing out_curves"
for curve in out_curves:
print "checking for valid curve"
if curve and curve.IsValid:
print "adding valid curve"
rc = scriptcontext.doc.Objects.AddCurve(curve)
print "disposing of curve"
print "checking if empty"
raise Exception("unable to add curve to document")
print "appending curves with new curve"
print "redrawing view"
and the output:
checking for valid curve
adding valid curve
disposing of curve
checking if empty
appending curves with new curve
[<System.Guid object at 0x000000000000002B [61493cde-3eab-48e0-8113-1854aec4df2d]>]