![]() |
|
![]() |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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
|
||||
|
||||
![]()
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
|
|||
|
|||
![]()
Thank you, Alex.
![]() 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
|
||||
|
||||
![]()
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) | |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
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 |