Hi all, very new to Macro programming, so please be patient.
I am trying to record a series of steps that include, creating a boundary, adding multiple contours to that boundary, deleting the boundary and then moving the contours back to the original image. I can get the boundary and one contour line, but when I try to break the contour apart, things stop working. I am more than willing to share what I am seeing, or discussing privately. Any help would be greatly appreciated. Also, I am not a programmer, so theres that to contend with also.
Thanks
Troy
TroyCutchens said:Any help would be greatly appreciated.
Some of the things that you can do in CorelDRAW cannot be recorded in a macro.
If I try recording a macro of breaking apart a contour group, the macro code looks like this:
Sub Macro3() ' Recorded 2018-07-28 Dim OrigSelection As ShapeRange Set OrigSelection = ActiveSelectionRange ActiveSelection.Separate ' Recording of this command is not supported: SplitDualSpotObject End Sub
any suggestions on how to code or write this particular action?
OK, assuming that you have just created a Boundary from those shapes, then what?
Do you make one multi-step Contour to create those closed curves? Or do you make more than one single-step Contour (e.g., one being a single-step 3 mm Contour of the original Boundary, the other one being a 5 mm single-step Contour of the original Boundary)?
I think I am following you. after the boundary is made, i move it up to clear the image. then I make a single contour on the boundary. I break it apart and make another contour outside the first contour line. Then I have to separate the two.
Here is something that:
The size of the contour steps are in there as constants, so it's easy to find them and change the values. Right now they are set to 3 mm and 5 mm, respectively, for the first and second contours.
Sub Two_Sequential_Contours() Dim sOriginal As Shape Dim srTemp As ShapeRange Dim e As Effect Dim sContourCurve_1 As Shape Dim sContourCurve_2 As Shape Const dblContour_1_stepsize_in_mm As Double = 3 Const dblContour_2_stepsize_in_mm As Double = 5 On Error GoTo ErrHandler ActiveDocument.BeginCommandGroup "Two Sequential Contours" If ActiveSelectionRange.Count = 0 Then MsgBox "Nothing is selected." GoTo ExitSub Else If ActiveSelectionRange.Count > 1 Then MsgBox "More than one object is selected." GoTo ExitSub End If End If 'get original shape as a shape Set sOriginal = ActiveSelectionRange(1) 'from original shape, create contour effect; use outline color of original Set e = sOriginal.CreateContour(, ConvertUnits(dblContour_1_stepsize_in_mm, cdrMillimeter, ActiveDocument.Unit), , , sOriginal.Outline.Color.GetCopy) 'separate contour group Set srTemp = e.Separate 'get Contour Curve 1 as a shape Set sContourCurve_1 = srTemp(1) 'name Contour Curve 1 sContourCurve_1.Name = "Contour Curve 1 - " & dblContour_1_stepsize_in_mm & " mm" 'from Contour Curve 1, create contour effect; use outline color of original Set e = sContourCurve_1.CreateContour(, ConvertUnits(dblContour_2_stepsize_in_mm, cdrMillimeter, ActiveDocument.Unit), , , sOriginal.Outline.Color.GetCopy) 'separate contour group Set srTemp = e.Separate 'get Contour Curve 2 as a shape Set sContourCurve_2 = srTemp(1) 'name Contour Curve 2 sContourCurve_2.Name = "Contour Curve 2 - " & dblContour_2_stepsize_in_mm & " mm" 'delete the original Curve sOriginal.Delete ExitSub: ActiveDocument.EndCommandGroup Refresh Exit Sub ErrHandler: MsgBox "Error occurred: " & Err.Description Resume ExitSub End Sub
Thanks, I will give it a go and see how it works. is there a document someplace that defines or explains the different statements? want to get smarter. thanks again.
One place to start is the Developer Area; a number of resources there.
You might also have a look at some of the content provided by Sub GDG_John( ) - GDG Macros VBA Lessons; lots of good stuff there.