Zoom-independent curve pattern

Eyeshot's Entity.LineTypePattern is zoom dependent, which means that the size of the dashes get bigger or smaller depending on the zoom level:

Capture.PNG Capture2.PNG Capture.PNG

If you want the size of the dashes to remain the same regardless of the zoom level, similar to what AutoCAD® does for selected entities, you can inherit from the relevant Entity class and override the Entity.Draw() method to enable the line stipple feature, like this:

class MyCircle : Circle 
        public ushort Stipple = 0xF0F0; // See http://www.opengl.org/sdk/docs/man/xhtml/glLineStipple.xml 

        public MyCircle(double x, double y, double z, double radius) 
            : base(x, y, z, radius) 
protected override void Draw(DrawParams data) {
data.RenderContext.SetLineStipple(1, Stipple, data.Viewport.Camera); data.RenderContext.EnableLineStipple(true); base.Draw(data);             data.RenderContext.EndDrawBufferedLines(); data.RenderContext.EnableLineStipple(false);

This will be the result:

Capture.PNG Capture2.PNG Capture.PNG


If you want to obtain the same result for the Region entity, you need to override the Region.DrawEdge() as shown in the below code snippet:

class MyRegion : Region
    public ushort Stipple = 0xF0F0; // See http://www.opengl.org/sdk/docs/man/xhtml/glLineStipple.xml 

    public MyRegion(Region another) : base(another) { }

    private double _myTol;
    public override void Regen(RegenParams data)

        _myTol = data.ChordalErr; //I want to use the same tolerance for drawing the edges.

    protected override void DrawEdges(DrawParams data)
float currentLineWidth = data.RenderContext.CurrentLineWidth; if (this.LineWeightMethod == colorMethodType.byEntity) { data.RenderContext.SetLineSize(this.LineWeight, true); } if (this.LineTypeMethod == colorMethodType.byEntity) { data.RenderContext.SetLineStipple(3, Stipple, data.Viewport.Camera); data.RenderContext.EnableLineStipple(true); } // Draw edges foreach (var curve in ContourList) { Entity ent = (Entity) curve; if (ent.Vertices == null) ent.Regen(_myTol); data.RenderContext.DrawLineStrip(ent.Vertices); }     data.RenderContext.EndDrawBufferedLines(); data.RenderContext.EnableLineStipple(false);
data.RenderContext.SetLineSize(currentLineWidth, true);


Region star = new PolygonalRegion(new[]
    new Point2D(0, -10),
    new Point2D(15, -20),
    new Point2D(7.5, -2.5),
    new Point2D(20, 7.5),
    new Point2D(5, 7.5),
    new Point2D(0, 20),
    new Point2D(-5, 7.5),
    new Point2D(-20, 7.5),
    new Point2D(-7.5, -2.5),
    new Point2D(-15, -20)
MyRegion r = new MyRegion(star);
r.LineWeightMethod = r.LineTypeMethod = colorMethodType.byEntity;
r.LineWeight = 3;
viewportLayout1.Entities.Add(r, 0, Color.Gold);

 This will be the result:

starRegion1.PNG   starRegion2.PNG

 Note: This trick requires OpenGL renderer or Direct3D renderer with feature level greater than 9.3. (it can be seen in viewportLayout.RendererVersion).

Previous versions of this article: Eyeshot 5

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request


1 comment
  • How can I create a Zoom Independent Text entity?


Please sign in to leave a comment.