Polyline.IsClosed (API) Version 7.7.32

Previous to Version 7.7.32, we were working with defined shapes using vertex and face definitions. These shapes are formed successfully in other programs using mesh objects — converted to Breps.

For Rhino, we were using polylines to form mesh faces.

After 7.7.32, the same objects failed to form in Rhino. The problem seems to be a failure with IsClosed as applied to a Polyline object prior to conversion to a mesh face.

I’ve attached a test script (Python) including three objects. Two are derived from a simple box.

The box face data are as follows:

Data derived from Box created in Rhino:
Vertex Point
0 0, 200, 0
1 300, 200, 0
3 300, 0, 0
2 0, 0, 0
close 0, 200, 0

Data created by hand:
Vertex Point
3 300, 0, 0
2 300, 200, 0
1 0, 200, 0
0 0, 0, 0
close 300, 0, 0

These data sets represent opposite rotations (CW and CCW), but both sets are plainer and valid as Polylines that should rate as closed.

FulcrumPolylineTest_cmd.py (8.5 KB)

1 Like

Hi @Doug_Bors,

I’ve tried running your script. But I’m not sure what I’m looking for. And it error on line 102:

Message: range() integer end argument expected, got float.

That said, this works:

import Rhino
import scriptcontext as sc

def test1():
    p0 = Rhino.Geometry.Point3d(0, 200, 0)
    p1 = Rhino.Geometry.Point3d(300, 200, 0)
    p2 = Rhino.Geometry.Point3d(300, 0, 0)
    p3 = Rhino.Geometry.Point3d(0, 0, 0)
    p4 = Rhino.Geometry.Point3d(0, 200, 0)
    points = [p0, p1, p2, p3, p4]
    pline = Rhino.Geometry.Polyline(points)
    print("test1: Polyline.IsValid = {0}".format(pline.IsValid))

    
def test2():
    p0 = Rhino.Geometry.Point3d(300, 0, 0)
    p1 = Rhino.Geometry.Point3d(300, 200, 0)
    p2 = Rhino.Geometry.Point3d(0, 200, 0)
    p3 = Rhino.Geometry.Point3d(0, 0, 0)
    p4 = Rhino.Geometry.Point3d(300, 0, 0)
    points = [p0, p1, p2, p3, p4]
    pline = Rhino.Geometry.Polyline(points)
    print("test2: Polyline.IsValid = {0}".format(pline.IsValid))

test1()
test2()

– Dale

Dale, Thank you. I will integrate the use of Point3D into my larger script tomorrow to test this solution.

Dale, I assumed that applying the series of points as a list (as shown in your tests) would act differently from adding each point to the Polyline individually. But, your test1 and test 2 do not work in Rhino 7.7.32 on my desktop (MAC, Intel i7, running Ventura 13.5). The issue first appeared in 7,7,32, so I would look into the procedure that forms a Polyline on MAC. Thanks.

Someone else has reported a similar issue with 7.32…

Hi @Doug_Bors,

I just ran the script I posted above in Rhino 7 for Mac SR32, and it ran as expected.

Rhino 7 SR32 2023-8-9 (Rhino 7, 7.32.23221.10242, Git hash:master @ 3d9c816c4cd57561d12d8f53246bce304f314ba2)

@Helvetosaur - I’ve heard this too, but no one has provided a way to repeat.

Thanks,

– Dale

Dale, Ok. My Python Version reports as 2.7.12, so that seems to be Ok. I will try reloading Rhino 7 …

I found the difference in our testing: Dale is testing for IsValid. I am testing for IsClosed:

The Polyline is valid, but not closed. This changed with 7.32.

def test2():
p0 = Rhino.Geometry.Point3d(300, 0, 0)
p1 = Rhino.Geometry.Point3d(300, 200, 0)
p2 = Rhino.Geometry.Point3d(0, 200, 0)
p3 = Rhino.Geometry.Point3d(0, 0, 0)
p4 = Rhino.Geometry.Point3d(300, 0, 0)
points = [p0, p1, p2, p3, p4]
pline = Rhino.Geometry.Polyline(points)
# print(“test2: Polyline.IsValid = {0}”.format(pline.IsValid))
rs.MessageBox('pline.IsClosed: ’ + str(pline.IsClosed), 0, title=“In class PolylineTest”)

import Rhino
import scriptcontext as sc

def test1():
    p0 = Rhino.Geometry.Point3d(0, 200, 0)
    p1 = Rhino.Geometry.Point3d(300, 200, 0)
    p2 = Rhino.Geometry.Point3d(300, 0, 0)
    p3 = Rhino.Geometry.Point3d(0, 0, 0)
    p4 = Rhino.Geometry.Point3d(0, 200, 0)
    points = [p0, p1, p2, p3, p4]
    pline = Rhino.Geometry.Polyline(points)
    print("test1: Polyline.IsValid = {0}".format(pline.IsValid))
    print("test1: Polyline.IsClosed = {0}".format(pline.IsClosed))

    
def test2():
    p0 = Rhino.Geometry.Point3d(300, 0, 0)
    p1 = Rhino.Geometry.Point3d(300, 200, 0)
    p2 = Rhino.Geometry.Point3d(0, 200, 0)
    p3 = Rhino.Geometry.Point3d(0, 0, 0)
    p4 = Rhino.Geometry.Point3d(300, 0, 0)
    points = [p0, p1, p2, p3, p4]
    pline = Rhino.Geometry.Polyline(points)
    print("test2: Polyline.IsValid = {0}".format(pline.IsValid))
    print("test2: Polyline.IsClosed = {0}".format(pline.IsClosed))

test1()
test2()

Version 7

Rhino 7 SR33 2023-8-1 (Rhino 7, 7.33.23213.13002, Git hash:master @ beed91711342a1d84e696dc6725c3bf7d407dce0)

result

test1: Polyline.IsValid = True
test1: Polyline.IsClosed = False
test2: Polyline.IsValid = True
test2: Polyline.IsClosed = False

Ugh, sorry. Getting late in the day.

Still not repeating on Windows. I’ve got an internal build. Let me grab SR32.

– Dale

Hi All,

When this week’s Rhino 7 SR33 release candidate is available, download and install it. This should fix the issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-76245

– Dale

Dale,

Thank you.

today i came across this issue on a clients windows 10 with an older Rh 7 SR 29 version while developing a rhinocommon c# plug-in. (nothing with grasshopper)
An update fixed the problem. no further intervention needed

But just to have it documented:

Version 7 SR29
(7.29.23107.3001, 2023-04-17)
under Windows 10

the attached gh file with internalized curve produces a polyline that should be closed but is not “isClosed”

   // tolerance tol will be quite rough 0.5
    // tested 0.001 ... 1.0
    // crv is closed
    // polyline is not closed ? gab /  Distance  start- end is 2.8421709430404E-14
    Polyline pl = crv.ToPolyline(tol, tol, tol * 10, 0).ToPolyline();
    double gab = pl[0].DistanceTo(pl.Last); // 2.8421709430404E-14
    A = crv.IsClosed;
    B = pl.IsClosed;
    C = gab.ToString();

polyline_is_not_closed.gh (6.7 KB)