Sub test() Dim sr As ShapeRange, s1 As Shape, s2 As Shape Set sr = ActiveSelectionRange If sr.Count <> 3 Then MsgBox "3 shapes must be selected": Exit Sub Set s1 = sr(3).Intersect(sr(1), False, True) Set s2 = sr(2).Intersect(sr(1), False, True)End Sub
EDIT: sorry 2nd step should be TRIM
Sub test() Dim sr As ShapeRange, s1 As Shape, s2 As Shape Set sr = ActiveSelectionRange If sr.Count <> 3 Then MsgBox "3 shapes must be selected": Exit Sub Set s1 = sr(3).Intersect(sr(1), False, True) Set s2 = sr(2).Trim(sr(1), False, True)End Sub
I understand step one easy enough. Here is how you can quickly short the shapes in ZOrder. I then Intersect the back and front shapes, deleting the front. I am a little confused on step 2. It would be help if you attached a .cdr file that showed the results after each step.
Here is this code to get you started:
Sub IntersectMe() Dim s As Shape Dim sr As ShapeRange Set sr = ActiveSelectionRange sr.Sort "@shape1.com.zOrder < @shape2.com.zOrder" Set s = sr(1).Intersect(sr(3), False, True) End Sub
Hope that helps,
-Shelby
Thanks Mek, This worked somewhat. What I didn't realize was that after the intersect another shape was created isn't in the original SelectionRange. There are now 4 objects in the Object Manager instead of 3. i now need the trim to happen with the 4th and 2nd object. Do I create a new SelectionRange and then trim?
Hope this isn't too confusing.
3 objects selecsted and macro applied left 3 objects (2 deleted and two created).
What should be the result?
Best regards
Mek
I've uploaded to small videos that can probably explain it better. I hope. Here's what I see happening when I step through the code.
1. The 3 objects are selected
2. The 2 shapes are intersected deleting the source but the intersection creates another shape so there are still 3 shapes
3. The next step in the code is Trim but its trimming the new shape and the back layer.