OberonPlace.com Forums

OberonPlace.com Forums (http://forum.oberonplace.com/index.php)
-   CorelDRAW/Corel DESIGNER VBA (http://forum.oberonplace.com/forumdisplay.php?f=16)
-   -   Error in CURVE.AREA property (http://forum.oberonplace.com/showthread.php?t=6462)

thayne 01-09-2009 16:19

Error in CURVE.AREA property
The area reported by .SHAPE.CURVE.AREA is incorrect if there is a hole in it. Instead of subtracting the inside area from the outside it adds them together.

I reported this to Corel a while ago and they replied saying that this type of problem doesn't fall under "free" support... :confused:
They are really funny but I think I will hang on to my money.

shelbym 01-09-2009 23:13

I can confirm this is a bug. I will submit to Corel. Unfortunately I don't have a workaround at this time. If I can find one, I will be happy to post it here.


Alex 03-09-2009 15:33

Unfortunately Area method counts for curve direction. The curve for hole should go in the opposite direction than the outer curve. Also it doesn't handle the intersecting paths.

A way to work around this is to create a contour with offset of 0. This would get the same path visually but correct all those issues (proper curve direction, no overlapping areas, etc). And Area should work correctly on that...


I hope this helps

thayne 09-09-2009 16:36

Didn't work but have bulky solution

Originally Posted by Alex (Post 15212)

Thanks Alex. I tried it but it doesn't work (I may be missing something though). It is still reporting the area as the outer shape area + inner shape area. Here's the one line code:


donutArea = ActiveSelection.Shapes.First.Curve.Contour(0).Area
I did write some bulky code to accomplish it though by breaking the shape apart, getting the areas for each of the shapes, finding the largest and subtracting the smaller ones from it. This of course won't work though if there is an island that is part of the outer shape but located inside the donut hole as it would subtract it from the outershape instead of adding it...:icon_conf (which is in fact the case as I just tested it).


Public Function donutArea() As Double
    Dim donutShape As Shape, donut As ShapeRange
    Dim donutAreas() As Double, donutMax As Double
    Dim countShapes As Integer, i As Integer
    'copy the donut shape and break it apart into individual shapes
    Set donut = ActiveSelection.Duplicate(0, 0).BreakApartEx
    'get number of shapes and redimension the array
    countShapes = donut.Shapes.Count
    ReDim donutAreas(countShapes + 2)
    'get area of all shapes
    For i = 1 To countShapes
        donutAreas(i) = donut.Shapes(i).Curve.Area
    Next i
    'find largest shape and subtract smaller shapes from it
    donutAreas(countShapes + 1) = 0
    For i = 2 To countShapes + 1
        If donutAreas(i) > donutAreas(i - 1) Then donutMax = 2 * donutAreas(i)
        donutArea = donutArea + donutAreas(i - 1)
    Next i
    donutArea = donutMax - donutArea
    'clean up
End Function

All times are GMT -5. The time now is 02:23.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com