OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-09-2009, 16:19
thayne
Guest
 
Posts: n/a
Default 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...
They are really funny but I think I will hang on to my money.

Last edited by thayne; 01-09-2009 at 16:35.
Reply With Quote
  #2  
Old 01-09-2009, 23:13
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,769
Blog Entries: 9
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Area

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.

-Shelby
Reply With Quote
  #3  
Old 03-09-2009, 15:33
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,940
Blog Entries: 4
Default

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...

?Curve.Contour(0).Area

I hope this helps
Reply With Quote
  #4  
Old 09-09-2009, 16:36
thayne
Guest
 
Posts: n/a
Default Didn't work but have bulky solution

Quote:
Originally Posted by Alex View Post
?Curve.Contour(0).Area
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:

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... (which is in fact the case as I just tested it).

Code:
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
    donut.Delete
    
End Function
Reply With Quote
Reply

Tags
area, coreldraw, vba


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Selecting shapes in rectangle area lukswa CorelDRAW/Corel DESIGNER VBA 2 07-10-2008 02:13
area paul lantz General 2 03-09-2008 17:49
Delete All Nodes in Selected Area JudyHNM CorelDRAW/Corel DESIGNER VBA 8 09-05-2007 17:50
Constant area macro or VB? Chester Macros/Add-ons 3 26-11-2006 22:10
macro for break curve and join curve mgmcs Macros/Add-ons 2 26-05-2006 22:01


All times are GMT -5. The time now is 15:48.


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