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(); } }
perhaps the selected shape is not a curve (cdrCurveShape), but a rectangle (cdrRectangleShape). And these are different types
You should use `ActiveShape` instead of `ActiveSelection` and `DisplayCurve.Length`...
no need to convert to and from a curve, you can just use Shape.DisplayCurve.Length with any simple shapes
Corect, I will delete the answer...
I cannot delete my own answer. Something has been changed here since my last attempt...
Many thanks.And how i can in case i have more shapes selected calculate or select the shape on index?
1 2 3 4 5 6 7 8 9 10 11 12 13
private void Button_Click_1(object sender, RoutedEventArgs e) { int numOfObjects = corelApp.ActiveSelection.Shapes.Count; double totalLengt = 0; for (int i = 0; i < numOfObjects; i++) { corel.Shape sh; sh = corelApp.ActiveShape. // at index i ? Debug.WriteLine(sh.DisplayCurve.Length.ToString()); totalLengt += sh.DisplayCurve.Length; } }
do not use ActiveShape.
Dim s As Shape
For Each s ActiveSelectionRange
Debug.Print s.DisplayCurve.Length
Next