OberonPlace.com Forums > VBA How can I find shortest distance between two curves, shapes?
 Blogs Gallery FAQ Members List Social Groups Calendar Search Today's Posts Mark Forums Read

#1
07-12-2004, 08:37
 Jab Guest Posts: n/a
How can I find shortest distance between two curves, shapes?

How can I find shortest distance between two primitives (subpath, shapes, curves)? How can I find the nearest shape one from other?

I use CD12 and CD10...

Thanks.
#2
08-12-2004, 22:07
 Alex Administrator Join Date: Nov 2002 Posts: 1,940 Blog Entries: 4
Re: How can I find shortest distance between two curves, sha

Jab,

There is no easy way. It also depends on your definition of "the closest shape". You can find the distance between the centers of the shapes quite easily. But if you really need to find the closest distance between actual edges of the shapes, then probably you should go through every subpath of each curve and create a list of points along the paths using Segment.GetPointPositionAt method. Then go and find the distance between each pair of points belonging to each two shape and find the pair with the smallest distance. That will be the distance between the shapes. Of course, you need to choose a small enough step interval for each segment (usually having about 50 points per Bezier segment seems enough)...

I hope this helps.
#3
09-12-2004, 03:01
 Jab Guest Posts: n/a

Thank you, Alex.

. Yes of course, if, I suggest, the center of the shape is the same that center of rectangle, bounding the shape, I can find distance easily.

In CD10/12 object model I find the track of solution - that is SelectShapesFromRectangle method, but it is not full. I think that CD have the method find the closest distance between shapes... Maybe is it not published in object model?

Document info from simplest my file:
Number of objects - 6569,
Number of points - 99331.
and the calculations, like your sheme, Alex, will takes the long time.

Good luck!
#4
22-12-2004, 13:16
 Alex Administrator Join Date: Nov 2002 Posts: 1,940 Blog Entries: 4

Jab,

I don't think that CorelDRAW even has such a function internally. I can't think of a single feature in the application which would need this functionality. However if it did have it, I'm sure it would be implemented in pretty much the same way as I suggested - go through curves, segment by segment, and finding the closest distance.

And I'm not convinced that VBA is all that much slower either. There are a few methods which allow you to get the whole curve information as VBA native array (Curve.GetCurveInfo()) and then you can process this info internally in VBA without going back and forth to CorelDRAW document.

You can also employ some optimizations such as first get bounding boxes of the objects and discard those which clearly are too far away from your target object and limit your scope to just the curves which are clearly near your object.

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

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home OberonPlace Discussion     Site News     Web site suggestions     Image Gallery     Testing Oberon Products     CurveWorks     SecuriDesign     Calendar Wizard     Oberon Function Plotter     Jigsaw Puzzle Creator     Other Oberon Commercial Products     New product ideas Corel User Forums     CorelDRAW         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel DESIGNER         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     Corel PHOTO-PAINT         General         Tutorials         FAQ         Feature requests/wishlist         Macros/Add-ons         Artwork Showcase     General         About Corel         Off-Topic Developer Forums     OberonPlace Development Portal     VBA         CorelDRAW/Corel DESIGNER VBA         Corel Photo-Paint VBA         Code Critique     Corel Script         CorelDRAW CS         Corel Photo-Paint CS

 Similar Threads Thread Thread Starter Forum Replies Last Post zlatev CorelDRAW/Corel DESIGNER VBA 1 15-02-2005 07:05 glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 03:13

All times are GMT -5. The time now is 09:07.

 OberonPlace.com - Archive - Top