OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Corel User Forums > CorelDRAW > Macros/Add-ons

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-02-2010, 07:40
iceage3
Guest
 
Posts: n/a
Question A bug i found recently when use GetPointPositionAt Method

Code first (I use X4, this problem also happens in 12,X3):

Code:
Sub Test123()
    dim i#,x#,y#
    for i=1 to 1000
        activeselection.shapes(1).curve.subpaths(1).GetPointPositionAt x,y,i/1000
    next
End Sub
When i=998, we'll get an error "Invalid offset value"
but in the vba help document, the offset parameter of GetPointPostionAt method can be numbers less than 1, but what's wrong here?

When I want to get the above x,y values of a long curve, the 998th value should not reach the end of the curve obviously, so I think this is a bug!

I finally use On Error Resume Next to solve this problem, guys, help!
Reply With Quote
  #2  
Old 03-02-2010, 09:59
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi,
I tried it on a closed path and open path and I didn't get any error.
-John
Reply With Quote
  #3  
Old 03-02-2010, 10:58
iceage3
Guest
 
Posts: n/a
Default

Hi John, thanks!
I tried on two computers and the problem continue.
So what's your CorelDRAW version? It's wired really
Reply With Quote
  #4  
Old 03-02-2010, 11:05
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Hi.
x4 701

Can you attach the cdr file your testing with?

-John

Last edited by runflacruiser; 03-02-2010 at 11:06. Reason: change wording
Reply With Quote
  #5  
Old 03-02-2010, 11:12
iceage3
Guest
 
Posts: n/a
Default

Here's the cdr file.
I found the left curve got no problem with the code, but the right curve got error. Hope you can see it.
test.cdr
Reply With Quote
  #6  
Old 03-02-2010, 11:19
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Yep.
Got the error at 973.
I'll dig into this a little more.
-John
Reply With Quote
  #7  
Old 03-02-2010, 11:26
iceage3
Guest
 
Posts: n/a
Default

OK I got it at 973 too
We can get errors at different "i" values, this is depend on the curves.
I think this problem could have some relationship with the curvature of the curve. When the curve's curvature is large enough, we can always get the errors.
Really late at night in China, time to sleep
Have a nice day, John!
Reply With Quote
  #8  
Old 03-02-2010, 11:32
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

The initial x and y does not start at the beginning.
Here's an example for debugging purposes.
You should be able to see what's happening more clearly and make the fix.

Code:
Sub Test123()
Dim s As Shape
Dim v As Double
Set s = ActiveSelection.Shapes.First
    Dim i#, x#, y#
    For i = 1 To 1000
        v = Round(i / 1000, 5)
        s.Curve.SubPaths(1).GetPointPositionAt x, y, v
        ActiveLayer.CreateEllipse2 x, y, 0.01
    Next i
End Sub
Let me know if this helps. I gotta go and didn't have much more time at the moment.
-John
Reply With Quote
  #9  
Old 03-02-2010, 11:33
runflacruiser's Avatar
runflacruiser runflacruiser is offline
Senior Member
 
Join Date: Jun 2009
Location: Pigeon Forge, TN USA
Posts: 811
Default

Quote:
Originally Posted by iceage3 View Post
Really late at night in China, time to sleep
Have a nice day, John!
Will do, and you have a good night.
-John
Reply With Quote
  #10  
Old 12-04-2010, 00:14
LeonoCoder LeonoCoder is offline
Junior Member
 
Join Date: Nov 2006
Posts: 10
Default bug GetPointPositionAt Method

Code:
Sub Test123()
    dim i#,x#,y#
    for i=1 to 1000
        activeselection.shapes(1).curve.subpaths(1).GetPointPositionAt x,y,i/1000
    next
End Sub
I have found this in the right curve:

- The code works well under CorelDRAW 11 and CorelDRAW 12
- The code fails when i/1000 > 0.972 (CorelDRAW X4 and X5)
- The subpaths(1).length= 619.056 mm. (Under CorelDRAW 11 and 12)
- The subpaths(1).length= 636.7634 mm. (Under CorelDRAW X4 and X5)
- 636.056/619.7634 = 0.97219 (the code under X4 and X5 fails when i/1000 > 0.97219)
- The code fails if the length is > 619.056 mm. (cdrAbsoluteSegmentOffset) (X4 and X5)
- The command subpaths(1).AddNodeAt has the same bug under X4 and X5

So, I think the Subpath object has this bug since CorelDRAW X3 (or X4) version after a change made in the length property.

Last edited by LeonoCoder; 13-04-2010 at 09:40.
Reply With Quote
Reply


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
What is the CQL method derasje Macros/Add-ons 7 08-05-2010 00:20
Looking for info on method... ddonnahoe CorelDRAW/Corel DESIGNER VBA 7 30-08-2009 19:14
recently moved to x3 xombie Macros/Add-ons 1 05-02-2008 12:33
Method to do INSERT PAGE in VB.NET ? ljesus7 CorelDRAW/Corel DESIGNER VBA 0 12-02-2007 19:03
Some answers found, others not... mapcar Corel Photo-Paint VBA 0 06-11-2003 12:16


All times are GMT -5. The time now is 11:05.


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