how i can calculate in c# the square mm from a graphic?
i think we can create a bounding box outside the selected items, and get the area in mm2
If you're doing this like Fane's bounding box example, try this:
<CODE>
Sub outlineAreaFromBoundingBox() Dim sh As ShapeRange, sq As Double, rect As Shape Dim x As Double, y As Double, w As Double, h As Double Application.Unit = cdrMillimeter: ActiveDocument.Unit = cdrMillimeter Set sh = ActiveSelectionRange sh.GetBoundingBox x, y, w, h, True Set rect = ActiveLayer.CreateRectangle2(x, y, w, h) sq = rect.DisplayCurve.Area Debug.Print sq End Sub
</CODE>
You can account for the outline by setting True for the UseOutline parameter on the GetBoundingBox method.
Sorry for no formatting of code.
Sorry i am not clarify what i do it wrong ?
1 2 3 4 5 6 7 8 9 10 11 12 13
private void Button_Click_2(object sender, RoutedEventArgs e) { corel.ShapeRange sh; double sq; corel.Shape rect; double xWay; double x, y, w, h; corelApp.ActiveDocument.Unit = corelApp.ActiveDocument.Rulers.HUnits; sh = corelApp.ActiveSelectionRange; sh = corelApp.ActiveSelectionRange.GetBoundingBox(x, y, w, h, true); rect = corelApp.ActiveLayer.CreateRectangle2(x, y, w, h, 0, 0, 0, 0);
double x =0,y=0,w=0,h=0;
sh = corelApp.ActiveSelectionRange.GetBoundingBox(out x, out y, out w, out h, true);
GetBoundingBox does not return a ShapeRange, so you need to remove the "sh =". Also you just set sh to the ActiveSelectionRange so you should do it like this:
I also declare the variables in the same line, so you would not longer need the double x = 0, y = 0...etc.
Happy Coding,
-Shelby