Get lenght of a curve

I would like to find out  - without a macro from other programmers :-) the lenght of curve's

In corel i select a simple shape.

Why this not work?

1
2
3
4
5
6
7
8
9
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            corel.Shape selectedShape = corelApp.ActiveSelection;
            if (selectedShape.Type == corel.cdrShapeType.cdrCurveShape)
            {
              double l = selectedShape.Curve.Length;
              TB_LineLenght.Text = l.ToString();
            }
        }
Parents
No Data
Reply
  • In my case on selection of different types i got a problem since i need to count also the "A" as 2 objects.
    In my text if request i need to count up the selection from 4 to 5 as example, but how i can do this?

    The problem is on line 1509 -> foreach (corel.Shape sh in sr) because the the shape range of the "A" in break appart is now 2 objects.
    But the shape range is still 4 instead 5



      


     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
            private void Button_Click_1(object sender, RoutedEventArgs e)
            {
                corelApp.ActiveDocument.Unit = corelApp.ActiveDocument.Rulers.HUnits;
                int numOfObjects = 0;
                double totalLengt = 0;
                corel.ShapeRange sr;
    
                sr = corelApp.ActiveSelectionRange; // we have 4 shapes
    
                foreach (corel.Shape sh in sr)
                {
                    if (sh.Type == corel.cdrShapeType.cdrTextShape)
                    {
                        sr.ConvertToCurves();
                        sr.BreakApart(); // now we have 5 shapes
                    }
                }
    
                foreach (corel.Shape sh in sr) // but it still only 4 in range
                {
                    Debug.WriteLine(sh.DisplayCurve.Length.ToString());
                    totalLengt += sh.DisplayCurve.Length;
                    numOfObjects++;
                }
                corelApp.ActiveDocument.Undo();
                totalLengt /= 10;
                TB_LineLenght.Text = totalLengt.ToString("N0") + " cm";
                TB_CountObjects.Text = numOfObjects.ToString();
    
            }
    
Children