Good Day All.
I need to regularly draw an inside contour in a rectangle that has different spacing on at least 3 of the 4 sides. Also needs to be on a separate layer.
For instance, in a 48 inch wide by 36 inch high box I need an inner contour with 8.5" bottom, 12" top, 4" left and 6" right spacing. I can do the math and work it all out but chances are that when doing 50 different ones, I will make at least one mistake. Likely 2 or 3. Since these are for parts that will be CNC cut and sent out, an error is expensive.
What are my best options for this? If it's a macro, where do I find a place that can write one for me?
Thanks in advance.
Myron said:A macro can create a rectangle according to your set size of 36 x 48 , the instructions wouldn't work for another rectangle of different dimensions.
I am thinking of a VBA form with textboxes for entering the top, bottom, left, and right inset distances, and a commandbutton for "create inset rectangle".
Select the target rectangle or rectangles, then click the button.
Dropout said:Sounds perfect - how do I do it?
I could look at it this evening.
I'm no expert at macros in CorelDraw, but I think this falls within my limited skill set, and I did something closely related to this a while back.
OK, here's something to look at.
Rectangles before:
Rectangles after:
Here' s the .GMS file:
inset_rectangles_v2.gms
As it sits now, I've made no attempt to make it handle rotated rectangles correctly.
Save
Good job Eskimo! Perhaps you could take a look here. See my macro gibberish at the end, Ideally one could hit the macro and input a value to adjust the contour then apply. Also couldn't figure out how to incorporate the "MyContour" into just the "AutoTrim" macro instead of using the Call function.
Had to add this code to the macro for my use.[:D]
ActiveDocument.Unit = cdrInch
OK, I've updated the .GMS file in my previous post, so it now appears as "inset_rectangles_v2.gms".
After seeing Myron's useful comment about units, I've changed things in the v2 version so that the macro uses the same units as the document (as picked up from the units for the horizontal ruler). It checks this every time the "Create Inset Rectangles(s)" command button is used, so it's easy enough to change the document units - even if only temporarily - to whatever one wishes to use for the creation of the insets.
Another change is that the v2 version does not create (incorrect!) insets for rectangles rotated to angles other than 90, 180, or 270°. Instead, it shows a message box letting the user know that the rectangle is rotated, and how close it is to being rotated at an acceptable angle. It's easy enough to see that a rectangle is at 15°, but not so easy to see that it's at 0.1° - but such a rectangle would still create a bogus inset, the way I am creating them. The tolerance for how close this angle thing has to be is defined through a constant, so it's not difficult to change; currently set to 0.0001°.
A few comments:
If anybody finds ways that this macro fails to work as intended, or finds ways to "break" it, then please let me know so that I can learn something (and perhaps fix it).