Changing edge color for a single entity

The following derived Mesh class demonstrate how to change edge color for a single entity.

class MyMesh : Mesh
{
    public Color EdgeColor = Color.Empty;

    public MyMesh(Mesh another, Color edgeColor) : base(another)
    {
        EdgeColor = edgeColor;
    }

    protected override void DrawEdges(DrawParams data)
    {
        data.RenderContext.SetColorWireframe(EdgeColor);
        base.DrawEdges(data);
    }
}
Was this article helpful?
3 out of 3 found this helpful
Have more questions? Submit a request

Comments

6 comments
  • Excellent 👍

    0
    Comment actions Permalink
  • Hi Alberto, 

    that was very useful for changing the edge colors of a single entity. 

    I have a question: 

    How do we change a single Edge's color in the entity?

    I imagined something like following but does not work:

    Brep workEntity = (Brep)viewportLayout1.Entities[5];
    workEntity.Edges[2].Color?

    workEntity.Edges[2].Curve.Color?

     

    Thanks

     

    Ceyhun Sözbir

    0
    Comment actions Permalink
  • This is not possible, sorry.

    0
    Comment actions Permalink
  • @ Ceyhun Sözbir

    I have the same Problem.

     

    You can do it on your own. I do it as follw:

     

    in the Model1SelectedChange when i Click a SelectedEdge, i take a look what kind of Curve i have in this Edge ( Line, Arc, Circle, ................. or a complex ICurve )

    Then for Example: Line ==> Read the property and make your own Line. Set your Line.ColorMethod, Line.Color, Line.LineWeightMethod and Line.LineWeight.

    Then add it to the TempEntityCollection.

     

    In older Versions add it directly to the Modell.

    To sepparate them you can use CustomData for this Entities or you can write some String in Line.EntityData to sepparate them. 

    I use a casted (DirectCast) temporery List of Entity. 

     

    Regards

     

     

    0
    Comment actions Permalink
  • Very Good!
    TempEntityCollection  is very good idea in version 12 
    0
    Comment actions Permalink
  • thanks a lot for the answers :-D

    0
    Comment actions Permalink

Please sign in to leave a comment.