Grasshopper

algorithmic modeling for Rhino

Hello, 

 

can someone please help me with this. This should be pretty simple, but I have no idea why this is happening. I am trying to close two polycurves using the MakeClosed method. I am aware of the tolerances, but the tolerance only seems to work as a lower limit (bellow which the curve that does close won't close), not as an upper limit. 

 

I can manage to close the curve on the right, but one on the left won't close. 

I know I can append or create a new segment and join it, but that takes more steps to compute. 

 

 

 

Here is the code. Is there a way to format code here like in stackoverflow?

 

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs
import rhinoscript.utility as rhutil


def CloseCrvTest():
    ##Select the curve
    curve = rs.GetCurveObject("Select a close polyline to obtain it's kernel", True, True)
    if not curve:
        return
    curveGuid = curve[0]
    curveGeo = rhutil.coercecurve(curveGuid, -1, True)

    tol = rs.Distance(curveGeo.PointAtStart, curveGeo.PointAtEnd)
    curveClosed = curveGeo.MakeClosed(tol )
    print 'Curve was closed:', curveClosed
    rs.DeleteObject(curveGuid)
    curveGeoGuid = scriptcontext.doc.Objects.AddCurve(curveGeo)
    scriptcontext.doc.Views.Redraw()

if __name__=="__main__":
    CloseCrvTest()

Thanks again everyone. 

Views: 278

Attachments:

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2026   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service