MACRO help! How to find widest distance ACROSS various objects?

Since I'm not proficient in writing VBA code, I may use the wrong terminology to describe what I need to accomplish. However, I put together graphic to help with a visual representation. After searching like mad for days on every Corel-related macro site, youtube videos and forums to find a solution to this, I'm at a dead-end.

Here's the basic summary:

I have a ton of vector objects (one object per page) of varying shapes and sizes that all need to have an exact uniform maximum width. That is to say that the maximum size of each object must match other, even with wildly different shapes. A very basic example is a 1" square compared to a 1" circle. Both are initially 1" wide and tall, however when rotated 45 degrees, the maximum width of the square is now 1.4142", while the circle remains the same regardless of rotation. So now that the square has been rotated to its widest point, it can be scaled to 1" wide to match that of the circle. When the square is then rotated back 45 degrees to it's original starting point, it is now only 0.7071" tall and wide. But that is exactly perfect, because there is no part of that square that is greater than 1" across no matter how it is positioned. That's an oversimplified example, but the shapes and sizes that need to be worked through on this project are not that simple. Each object is totally different from each other in size and shape.

(This may be where the graphic below will be helpful to illustrate.)

To be clear, there is no need for the length of the total path of an object (I've seen a few macros for that), but instead the longest distance across it. Once that is achieved, each object can then be set to a uniform size horizontally (maintaining proportions), which will result in the same maximum width for all. I feel like there's a very well known mathematical equation that should be slapping my face, but nothing is jarring my memory.

Hope that all made sense. I will gladly be made to feel a fool if the solution is super easy, but I'm burned out!  Thanks for considering this puzzle!

GFXCA

Parents Reply
  • OK, I don't have X4, but I do have X5.

    I used the same code in the macro editor there, and the subroutines appear to work fine in X5.

    Here's the .GMS file from X5:

    scalemaxdimension.gms

    That GMS file includes the subroutines that "do the work", and also the two subroutines that I used to call the other ones for testing.

    You are not going to see the "do the work" subroutines in the CorelDraw Macro Manager because they are subroutines that use arguments (i.e., the stuff between the parentheses after the name of the subroutine).

    The subroutines you do see in the Macro Manager are the ones that don't use arguments - the ones with just an empty () after the subroutine name.

    Here's how they look in the X5 Macro Manager:

    When I select one or more objects in CorelDraw, then double-click on "test_scale_for_max_dimension", then the subroutine "test_scale_for_max_dimension" runs.

    That subroutine gets the shaperange from the active selection, then goes through all of the shapes in it.

    Each time it gets to a new shape, it "calls" the subroutine "scale_for_max_dimension" and gives that subroutine the necessary arguments (the shape to be worked on, and the maximum dimension that is to be used).

    After "scale_for_max_dimension" has finished, control comes back to "test_scale_for_max_dimension", picking up right after the line that called the other sub.

    Save

Children