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 07-12-2004, 08:37
Jab
Guest
 
Posts: n/a
Default 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.
Reply With Quote
  #2  
Old 08-12-2004, 22:07
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default 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.
Reply With Quote
  #3  
Old 09-12-2004, 03:01
Jab
Guest
 
Posts: n/a
Default

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!
Reply With Quote
  #4  
Old 22-12-2004, 13:16
Alex's Avatar
Alex Alex is offline
Administrator
 
Join Date: Nov 2002
Posts: 1,941
Blog Entries: 4
Default

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.
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
Find only shapes with compound path zlatev CorelDRAW/Corel DESIGNER VBA 1 15-02-2005 07:05
Generic code to process all shapes in a document glennwilton CorelDRAW/Corel DESIGNER VBA 0 05-09-2003 03:13


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


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