String pattern for linetypes documentation error

Hi,

was doing a custom string pattern for a dashed linetype and I’ve noticed the method only works if both numbers are positive like below.

string pattern = "5,5";
var linetype = Rhino.DocObjects.Linetype.CreateFromPatternString(pattern, true);

The documentation suggests otherwise:

Values greater than zero represent line segments, and values less than or equal to zero represent space segments.

… which is not true, since string pattern = "5,-5"; silently fails and just returns continuous line…

Cheers

Out of curiosity, what is the output of PatternString? Should also be something like “+, -” according to the documentation.

maybe AppendSegement(double length, bool isSolid) is the better choice to create the pattern ?
and you may also want to check the output of PatternString

what s your system 's language / location / culture/ globalization setting … just a guess - maybe the implementation is (buggy and ..) interpreting “5,5” as “5.5” ?

It is also two positive numbers, “5.00, 5.00” (cc @Tom_P )

The system language doesn’t interpret the pattern wrong… I haven’t worked with append segment yet, so can’t tell.

looks like a wrong documentation - yes.

// #! csharp
using System;
using Rhino;
using Rhino.DocObjects;

Linetype myLineType = new Linetype();
myLineType.Name = "test";
myLineType.AppendSegment(1,true);
myLineType.AppendSegment(2,false);
myLineType.AppendSegment(3,true);
myLineType.AppendSegment(4,false);
myLineType.AppendSegment(5,true);
myLineType.AppendSegment(6,false);
RhinoApp.WriteLine(myLineType.PatternString(true));

will also output no negative values.

1.00, 2.00, 3.00, 4.00, 5.00, 6.00

Hi @Sven_Duplić,

Looks like a bug to me - I’ll see to tuning up this function.

For now, you can just pass a comma-delimited string of numbers >= 0. The first number, in the parsed array, will be a line segment, the second a space, the third a line segment, etc. alternating to the end of the array.

#! python 3
import Rhino
import scriptcontext as sc

def TestLinetype():
    # line, space, line, space, line, space
    pattern = "1.25, 0.25, 0, 0.25, 0, 0.25"
    lt = Rhino.DocObjects.Linetype()
    lt = Rhino.DocObjects.Linetype.CreateFromPatternString(pattern, True)
    lt.Name = "Property Line"
    print(lt.PatternString(True))
    sc.doc.Linetypes.Add(lt)

if __name__ == "__main__":
    TestLinetype()

– Dale

RH-95417 is fixed in Rhino 8 Service Release 32