Drawing arc with C# using Autocad infos


This Content is from Stack Overflow. Question asked by Gokhan

I have winform project in c#. There is arc shape created in Autocad. I want to create the same shape on form with the paint event. I get the coordinates, radius and angles infos of the shapes with autocad List command.

The DrawArc method takes 4 parameters: 1-The pen. 2-Rectangle to draw in. 3-Start angle. 4-Sweep angle.

I could not match these parameters with the information you see on the right side of the picture below.

This is the shape and infos

enter image description here

These are my codes:

private void Form1_Paint(object sender, PaintEventArgs e)
            float X1 = 73.7153F;
            float Y1 = 36.0911F;
            float X2 = 271.4735F;
            float Y2 = 315.4934F;
            float width = X2 - X1;
            float height = Y2 - Y1;

            // Changes the coordinates Y axis accrording to form coordinates
            Y2 = 36.0911F;
            Y1 = 315.4934F;
            // Create pen.
            Pen blackPen = new Pen(Color.Black, 3);

            // Create start and sweep angles on ellipse.
            float startAngle = 195.0F;
            float sweepAngle = 95.0F;

            // Draw arc to screen.
            e.Graphics.DrawArc(Pens.Black, 0, 0, width, height, startAngle, sweepAngle);

This is the result:

enter image description here


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?