3

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 .
            float startAngle = 195.0F;
            float sweepAngle = 95.0F;

            // Draw arc to screen.
            e.Graphics.DrawArc(blackPen , X1, Y1, width, height, startAngle, sweepAngle);
        }

This is the result:

enter image description here

Gokhan
  • 453
  • 4
  • 10
  • 2
    Why not look up the specs?? [Autcad](https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2020/ENU/AutoCAD-Core/files/GUID-30ECFD30-A1D6-4D60-9DD1-B487603F6772-htm.html) clearly states that the points are center, endpoint, start point. DrawArc is quite different: It has a Rectangle to bound the ellipse of which the arc would be part of. So you will have to use a bit of math.. – TaW Sep 19 '22 at 16:14
  • 2
    The first thing you should do is to transform the coordinates system to the cartesian plane in the 1st quadrant, since you probably have this type of coordinates. See [Coordinate Systems and Transformations](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/coordinate-systems-and-transformations), [Types of Coordinate Systems](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/types-of-coordinate-systems), [Global and Local Transformations](https://learn.microsoft.com/en-us/dotnet/desktop/winforms/advanced/global-and-local-transformations) – Jimi Sep 19 '22 at 16:33
  • 2
    [Graphics.TranslateTransform](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics.translatetransform), [Graphics.RotateTransform](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.graphics.rotatetransform) and / or use a [Matrix](https://learn.microsoft.com/en-us/dotnet/api/system.drawing.drawing2d.matrix) object, which can combine up coordinates translation and rotation at the same time. A few notes [here](https://stackoverflow.com/a/53182901/7444103) – Jimi Sep 19 '22 at 16:37
  • 2
    Many thanx for comments. I thought there is easy way for that but i should do some maths – Gokhan Sep 19 '22 at 17:15

0 Answers0