123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- Attribute VB_Name = "CutLines"
- Public Function Batch_CutLines()
- If 0 = ActiveSelectionRange.Count Then Exit Function
- API.BeginOpt
- Bleed = API.GetSet("Bleed")
- Line_len = API.GetSet("Line_len")
- Outline_Width = API.GetSet("Outline_Width")
-
- Dim s1 As Shape, OrigSelection As ShapeRange, sr As New ShapeRange
- Set OrigSelection = ActiveSelectionRange
- For Each s1 In OrigSelection
- lx = s1.LeftX: rx = s1.RightX
- By = s1.BottomY: ty = s1.TopY
- cx = s1.CenterX: cy = s1.CenterY
- sw = s1.SizeWidth: sh = s1.SizeHeight
-
-
- Dim s2, s3, s4, s5, s6, s7, s8, s9 As Shape
- Set s2 = ActiveLayer.CreateLineSegment(lx - Bleed, By, lx - (Bleed + Line_len), By)
- Set s3 = ActiveLayer.CreateLineSegment(lx, By - Bleed, lx, By - (Bleed + Line_len))
- Set s4 = ActiveLayer.CreateLineSegment(rx + Bleed, By, rx + (Bleed + Line_len), By)
- Set s5 = ActiveLayer.CreateLineSegment(rx, By - Bleed, rx, By - (Bleed + Line_len))
- Set s6 = ActiveLayer.CreateLineSegment(lx - Bleed, ty, lx - (Bleed + Line_len), ty)
- Set s7 = ActiveLayer.CreateLineSegment(lx, ty + Bleed, lx, ty + (Bleed + Line_len))
- Set s8 = ActiveLayer.CreateLineSegment(rx + Bleed, ty, rx + (Bleed + Line_len), ty)
- Set s9 = ActiveLayer.CreateLineSegment(rx, ty + Bleed, rx, ty + (Bleed + Line_len))
-
- ActiveDocument.AddToSelection s2, s3, s4, s5, s6, s7, s8, s9
- ActiveSelection.group
- sr.Add ActiveSelection
- Next s1
-
- sr.SetOutlineProperties Outline_Width
- sr.SetOutlineProperties Color:=CreateRegistrationColor
- sr.AddToSelection
-
- API.EndOpt
- End Function
- Sub test_MarkLines()
- Dimension_MarkLines cdrAlignLeft, True
- End Sub
- Public Function Dimension_MarkLines(Optional ByVal mark As cdrAlignType = cdrAlignTop, Optional ByVal mirror As Boolean = False)
- If 0 = ActiveSelectionRange.Count Then Exit Function
- API.BeginOpt
- Bleed = API.GetSet("Bleed")
- Line_len = API.GetSet("Line_len")
- Outline_Width = API.GetSet("Outline_Width")
-
- Dim s As Shape, s1 As Shape, OrigSelection As ShapeRange, sr As New ShapeRange
- Set OrigSelection = ActiveSelectionRange
- For Each s1 In OrigSelection
- lx = s1.LeftX: rx = s1.RightX
- By = s1.BottomY: ty = s1.TopY
-
-
- Dim s2, s6, s7, s8, s9 As Shape
-
- If mark = cdrAlignTop Then
- Set s7 = ActiveLayer.CreateLineSegment(lx, ty + Bleed, lx, ty + (Bleed + Line_len))
- Set s9 = ActiveLayer.CreateLineSegment(rx, ty + Bleed, rx, ty + (Bleed + Line_len))
- sr.Add s7: sr.Add s9
- Else
- Set s2 = ActiveLayer.CreateLineSegment(lx - Bleed, By, lx - (Bleed + Line_len), By)
- Set s6 = ActiveLayer.CreateLineSegment(lx - Bleed, ty, lx - (Bleed + Line_len), ty)
- sr.Add s2: sr.Add s6
- End If
- Next s1
-
-
- px = OrigSelection.LeftX
- py = OrigSelection.TopY
- mpx = OrigSelection.RightX
- mpy = OrigSelection.BottomY
-
-
- For Each s In sr
- If mark = cdrAlignTop Then
- s.TopY = py + Line_len + Bleed
- Else
- s.LeftX = px - Line_len - Bleed
- End If
- Next s
-
-
- RemoveDuplicates sr
-
-
- sr.SetOutlineProperties Outline_Width
- sr.SetOutlineProperties Color:=CreateCMYKColor(80, 40, 0, 20)
- sr.AddToSelection
-
- If mirror Then
- If mark = cdrAlignTop Then
- sr.BottomY = mpy - Line_len - Bleed
- Else
- sr.RightX = mpx + Line_len + Bleed
- End If
- End If
-
- API.EndOpt
- End Function
-
- Private Function RemoveDuplicates(sr As ShapeRange)
- Dim s As Shape, cnt As Integer, rms As New ShapeRange
- cnt = 1
-
- #If VBA7 Then
- sr.Sort " @shape1.Top * 100 - @shape1.Left > @shape2.Top * 100 - @shape2.Left"
- #Else
-
- #End If
- For Each s In sr
- If cnt > 1 Then
- If Check_duplicate(sr(cnt - 1), sr(cnt)) Then rms.Add sr(cnt)
- End If
- s.Name = "DMKLine"
- cnt = cnt + 1
- Next s
-
- rms.Delete
- End Function
-
- Private Function Check_duplicate(s1 As Shape, s2 As Shape) As Boolean
- Check_duplicate = False
- Jitter = 0.1
- X = Abs(s1.CenterX - s2.CenterX)
- Y = Abs(s1.CenterY - s2.CenterY)
- w = Abs(s1.SizeWidth - s2.SizeWidth)
- h = Abs(s1.SizeHeight - s2.SizeHeight)
- If X < Jitter And Y < Jitter And w < Jitter And h < Jitter Then
- Check_duplicate = True
- End If
- End Function
- Public Function SelectLine_to_Cropline()
- If 0 = ActiveSelectionRange.Count Then Exit Function
-
- Application.Optimization = True
- ActiveDocument.Unit = cdrMillimeter
-
- ActiveDocument.BeginCommandGroup
-
-
- px = ActiveDocument.Pages.First.CenterX
- py = ActiveDocument.Pages.First.CenterY
- Bleed = API.GetSet("Bleed")
- Line_len = API.GetSet("Line_len")
- Outline_Width = API.GetSet("Outline_Width")
-
- Dim s As Shape
- Dim line As Shape
-
-
- For Each s In ActiveSelection.Shapes
-
- lx = s.LeftX
- rx = s.RightX
- By = s.BottomY
- ty = s.TopY
-
- cx = s.CenterX
- cy = s.CenterY
- sw = s.SizeWidth
- sh = s.SizeHeight
-
-
- If sh <= sw Then
- s.Delete
- If cx < px Then
- Set line = ActiveLayer.CreateLineSegment(0, cy, 0 + Line_len, cy)
- Else
- Set line = ActiveLayer.CreateLineSegment(px * 2, cy, px * 2 - Line_len, cy)
- End If
- End If
-
-
- If sh > sw Then
- s.Delete
- If cy < py Then
- Set line = ActiveLayer.CreateLineSegment(cx, 0, cx, 0 + Line_len)
- Else
- Set line = ActiveLayer.CreateLineSegment(cx, py * 2, cx, py * 2 - Line_len)
- End If
- End If
- line.Outline.SetProperties Outline_Width
- line.Outline.SetProperties Color:=CreateRegistrationColor
- Next s
-
- ActiveDocument.EndCommandGroup
-
- Application.Optimization = False
- ActiveWindow.Refresh
- Application.Refresh
- End Function
|