Added 2019-09-28: If you want to find the macro discussed in this thread, you can find it in Eskimo's blog: #14 - Macro - "Zoom to Selection Plus".
In a recent thread in the X7 section - zOOM TO SELECTION FOR TO THE NODES SELECTION - FEATURE REQUEST - there was some discussion about having the ability to zoom to selected nodes. Some VBA approaches to that were posted, and the discussion expanded to include other types of "zoom to selection" that might be useful. I've tried to address some of those with a macro.
"Zoom to Selection Plus" can, depending on the situation:
From a user standpoint, ZTSP is only one command. What happens when it is run depends on what the current selection is - or, if nothing is selected, what visible objects are present on the page.
For each of those types of zoom, to the rectangular area that bounds the selection, some "padding" can be added to the height and width. How much padding? That can be set by the user, as a percentage of the bounding dimension, with independent values for each of the types of zoom listed above. In addition to that padding, there is a user-settable "minimum view dimension" - because one might not wish to zoom "all the way in" on very small selections.
In addition to the core "Zoom to Selection Plus" capability, a "Zoom to Page Plus" capability is made available as a second command. Again, the padding for that is user-settable, so the amount of white space around the page border can be smaller (or larger) than what CorelDRAW produces with its standard "zoom to page".
Here's the .GMS file: JQ_Zoom_to_Selection_Plus_2018_09_10_0855.
With the .GMS file in place, ZTSP looks like this in the Macro Manager:
The top four subs seen there are associated with the user form that is used to access the settings. At this point, we're interested in the bottom two subs.
In this video, I've assigned F4 to "Zoom to Selection Plus" and Shift+F4 to "Zoom to Page Plus".VIDEO: Zoom To Selection Plus - Demo 01
A later post will get into the user form.
There is another feature associated with the user form that hasn't been covered yet: the ability to show a red bounding rectangle to indicate the area that is being used as the basis for figuring out the view area. This is the rectangle before adding anything for padding or minimum view size. The layer that the red rectangle lives on is a layer created by the macro, and is deleted automatically when the user form is closed.
In addition to being useful as a tool for understanding what's going on with ZTSP, I've also included the ability to have the bounding box copied to the Active Layer (the copy will be a green rectangle).
When zooming to selected objects, those bounding boxes include the object outlines, not just wireframe geometry. I don't know if CorelDRAW has a built-in ability to create such bounding boxes without going through additional steps of converting the outlines to objects. If it does have such a capability, then I would like to know about it. In any case, that capability is there in the macro.
VIDEO: Zoom to Selection Plus - Demo 03
.
Hm, a very useful bonus feature.I like.
Ronny, are you aware of any shortcut in CorelDRAW to produce a bounding rectangle that includes object outlines? I know that Shift+double-clicking on the Rectangle tool in the Toolbox will produce one that bounds the wireframe geometry of the selection.
It would be very easy to write a simple, no-userform macro to do that, because the capability is right there in the API. I wouldn't do that, though, if it's already available!
Here's a couple of ideas for you to work with, when you feel inspired :How about a macro to show "true properties".Make it possible to create a bounding box rectangle that includes the outline(s) and also to set the page size based on all or selected objects including outlines (similar to the wOxxOm macro I mentioned).Add the ability to add a user set margin for both of these.
Ronny Axelsson said:How about a macro to show "true properties".
By "show true properties", do you mean "display true size of a selection, including outlines, effects, etc."? I already have a macro that does that. Better still, it allows the user to not just measure, but also to specify the desired "true size" of a selection.
I also have a "Fit Page To Selection" - with optional margin - that I wrote at the request of another forum member.
Great! Guess you can just sit back and relax then.
Both of those are on my (substantial!) list of macros that I plan to review and revise.
That's a price of "jumping in the middle" when getting started with writing macros. Code I wrote a year ago still works, but I've learned stuff since then that could be used to improve it.
Here are some ideas for an enhanced "Fit Page To Selection" macro:Two "modes", create Page or Rectangle (weed border for us sign makers).Use selected object(s) or if nothing is selected, use all.Two options, include outline or not.Adjustable margin.Selectable number of decimals or round up to full unit (OK = full unit, Shift+OK use decimals).When you get tired of just sitting back and relax.
I am very seriously considering, when "fitting page to selection", to do it by saving a copy of the document with just the selected content in it, and then performing the "fit page to content" on that document.
That would leave the original document unmodified, and I consider that to be A Good Thing.
I think that would be a much cleaner way to do it, and it fits in better with the idea that "fit page to selection" is often going to be associated with some sort of export operation. One might have multiple graphical assets in one document, and want to carry out FTPS on each of them individually.
I use wOxxOm's "sizePagetoFIT" macro to adjust the page to fit my objects, nothing more.An automated fit-page-to-objects-and-save-a-copy macro may be useful, even though I don't think I would personally use it much.Maybe it could help milosh2 to solve his problems in this thread.
Ronny Axelsson said:I use wOxxOm's "sizePagetoFIT" macro to adjust the page to fit my objects, nothing more.An automated fit-page-to-objects-and-save-a-copy macro may be useful, even though I don't think I would personally use it much.
As I noted earlier, I've already written a "fit page to selection" macro, and it does work. So, why would I be considering making a version that saves a new document with just the specified content?
To the best of my (limited!) knowledge, the "page" can't be located arbitrarily in CorelDRAW's 150 x 150 foot world. It it located at the center of that world. So, my FPTS macro changes the page size, and then "moves everything".
For a sufficiently simple document, that's no problem, but a document might contain:
In addition to that, the "world" could contain a large number of objects. if the user is performing a FPTS operation on just a small subset of them, that could mean a lot of unnecessary heavy lifting to "move the whole world".
To add to that, I have noticed some circumstances - involving Connector Lines, for one example - where an Undo does not completely restore things to the way they were before the operation that was being undone.
That's the motivation for saving the selected content into a new document; much less "intrusive" with respect to the original document.
Ronny Axelsson said:Maybe it could help milosh2 to solve his problems in this thread.
Yes! Anything that is based on the CorelDRAW page size could take advantage of this. My FPTS was originally written for someone who wanted to use it for exporting EPS, with the export based on the CorelDRAW page size.