In an attempt to automate a somewhat tedious manual procedure, I'd like to create a macro to add small triangle shapes around a variable number of boxes. Before i invest any time into this venture can anyone tell me if it is even possible? FWIW, we're still using CorelDRAW 2017 and have no immediate plans to upgrade.
The number and size of boxes will vary. I want to end up with a small triangle around the perimeter to indicate the through-cut location of each individual box.
Here is an example of what the end result should look like:
And here are the specifications for desired triangle shape and location:
This is the sort of thing I was thinking of when I suggested having a "create cut indicator" function:
Function create_cut_marker(ByVal Layer As Layer, ByVal PositionX As Double, ByVal PositionY As Double, ByVal Angle As Double, ByVal Width As Double, ByVal Length As Double) As Shape Dim curveThis As Curve Dim subPathThis As SubPath Dim transmatrix As New TransformMatrix On Error GoTo ErrHandler Set curveThis = CreateCurve(ActiveDocument) Set subPathThis = curveThis.CreateSubPath(PositionX, PositionY) subPathThis.AppendLineSegment PositionX - Length, PositionY - Width / 2 subPathThis.AppendLineSegment PositionX - Length, PositionY + Width / 2 subPathThis.Closed = True transmatrix.BindToDocument ActiveDocument transmatrix.RotateAround Angle, PositionX, PositionY curveThis.ApplyTransformMatrix transmatrix Set create_cut_marker = ActiveLayer.CreateCurve(curveThis) create_cut_marker.Fill.ApplyUniformFill Application.CreateCMYKColor(0, 0, 0, 100) create_cut_marker.Outline.SetNoOutline ExitFunc: Exit Function ErrHandler: MsgBox "Error occurred: " & Err.Description & vbCrLf & vbCrLf & "create_cut_marker()" Resume ExitFunc End Function
That can then be used in any particular type of placement operation. Here's a sub to create right-pointing cut markers at the top left corner of each selected shape. The marker width, marker length, and offset distance are constants defined elsewhere in the module.
Sub cut_markers_top_left_pointright() Dim sRef As Shape Dim srSelected As ShapeRange On Error GoTo ErrHandler Optimization = True EventsEnabled = False ActiveDocument.BeginCommandGroup "cut markers TL PR" Set srSelected = ActiveSelectionRange For Each sRef In srSelected create_cut_marker ActiveLayer, sRef.LeftX - dblOffset, sRef.TopY, 0, dblMarkerWidth, dblMarkerLength Next sRef srSelected.CreateSelection ExitSub: ActiveDocument.EndCommandGroup EventsEnabled = True Optimization = False Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description Resume ExitSub End Sub
A lot of stuff in there is essentially boilerplate - error handling, optimization, and to allow all of the operations to be in a command group to allow for a one-click Undo. The actual creation of the markers is one line of code in a for...next loop.
Even without creating a user form, it's possible to put a number of independent subs in a toolbar as commands with descriptive captions using regular CorelDRAW workspace customization.
Here's a demo:
Wow! That looks fabulous! I'll give it a go and see how it work.
I can't seem to figure out how to post code without is being part of the message text. Probably for the best. As I mentioned my macro coding skills are meager at best. I know enough to make a huge mess of things. My efforts so far have resulted in arrows at the corners and not much else.
At any rate, thank you very much! You've inspired me to improve my coding skills.
For posting code, you can use the hilite.me web site to convert your VBA code into formatted HTML. Copy that, and you can paste it into your forum post here after using Tools>Source Code in the editor to edit the post in HTML.
Here's a .ZIP archive with the .GMS file that includes the whole ball of wax that I showed in that demo video:
Cut_Markers.zip
.
Wow can you please let me how you are placing the designs? Manually or automatic through some macro. I am thinking to buy plotter cutter but not able to understand how i am going to mix my designs on the sheet? To reduce the wastage on the sheet?
We do the nesting part manually. In addition to a couple of long-forgotten macros we've tried eCut 6, and while it does sometimes give a head-start on a nesting layout, it doesn't often result in a perfect turn-key layout. Some manual repositioning is almost always required. It's faster for me to just do the layout so I don't even bother using it anymore. As with many other graphics related tasks I've found experience and natural ability to visualize to be valuable when nesting parts.
I do know that some RIP software provides a nesting function so that may worth investigating.