Why it is not drawing dotted or hidden lines? RhinoCommon Question

To whom it may concern:
Logically this code below should draw a hidden line. But it does not.

First I have created a layer called "Layer_A"
Then I have changed it’s lineTypeIndex.
Then I have assigned it to attribute and then draw a line from given points. The line should be hidden(dashed)
But it is giving normal. solid line.

It would be a big help, if some one would tell me what it wrong in this small code I wrote below.

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
string layer_name = “Layer_A”;
doc.Layers.Add(layer_name, System.Drawing.Color.Blue);
int index = doc.Layers.Find(layer_name, true);

        doc.Layers.SetCurrentLayerIndex(index, true);
        Rhino.DocObjects.Layer layer = doc.Layers[index];

        layer.Color = System.Drawing.Color.Blue;
        layer.LinetypeIndex = 6;//doc.Linetypes.Count - 1;

        Rhino.DocObjects.ObjectColorSource ColorSource1 = Rhino.DocObjects.ObjectColorSource.ColorFromObject;
        // Rhino.DocObjects.ObjectLinetypeSource line_type_source = Rhino.DocObjects.ObjectLinetypeSource.LinetypeFromObject;
        Rhino.DocObjects.ObjectLinetypeSource LinetypeSource = Rhino.DocObjects.ObjectLinetypeSource.LinetypeFromLayer;
        System.Drawing.Color ObjectColor1 = System.Drawing.Color.Blue;
        Rhino.DocObjects.ObjectAttributes att = new Rhino.DocObjects.ObjectAttributes();
        att.ColorSource = ColorSource1;
        att.ObjectColor = ObjectColor1;
        att.LayerIndex = index;
        att.LinetypeIndex = 6;
        att.LinetypeSource = LinetypeSource;// Rhino.DocObjects.ObjectLinetypeSource.LinetypeFromLayer;
        Point3d Pt1 = new Point3d(68.6988, 522.559, 0);
        Point3d Pt2 = new Point3d(787.361, 522.559, 0);

        Line l_E = new Line(Pt1, Pt2);


        return Result.Success;

Does the layer show as having a linetype in the layer dialog?
If it does, maybe the linetype scale is too small

1 Like

Linetypes are only displayed in Rhino when the PrintDisplay mode is on.

1 Like

Layer_A should show LineType hidden but it is showing continuous.
Please have a look at the image attached. The last layer in the image is Layer_A is showing continuous,it should show as hidden, no?

PrintDisplay is ON. But the problem is, the code I wrote did not change the linetype in the layer table.
It is still showing as continuous. Please see the image.

Linetypes display whether or not PrintDisplay is on.
Maybe you’re thinking of lineweights.

It looks like your linetype index (6) is probably out of range.
When I changed that to a valid index, your code worked.
Then set linetype scale to something like 100 to see the pattern.

1 Like

You’re right; I was confused

I have put line type index to 4
But it does not change to anything. In layer table it still shows continuous, unless I click on the layer table.
If I click on layer table then it changed to Border
It is not automated.
I needed to make it automated.
How to change the scale of the line texture?
Do you think I should write myself for the dashed line? If it does not work automated.

Many thanks !

I don’t know what to tell you about the "automatic " update - I copied your code and just changed the linetype index and it works right.

You can set the linetype scale with
doc.Linetypes.LinetypeScale = 100;

1 Like

OK .Many Thanks!
Not sure why it was not changing the layer-table property before. Now I re-run and it works.

It is working now. when I wrote
layer.LinetypeIndex = doc.Linetypes.Count - 5;
doc.Linetypes.LinetypeScale = 100;