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;
layer.CommitChanges();
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);
doc.Objects.AddLine(l_E,att);
doc.Views.Redraw();
return Result.Success;
}