Advertisement
wahabzizokaak

Untitled

May 5th, 2023
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub CommandButton13_Click()
  2.  ' Recorded 2022-03-18
  3. Dim sh As shape
  4. Dim sr As ShapeRange
  5. Dim i As Integer
  6. Dim p As Page
  7. Dim s1 As ShapeRange
  8. Dim X As Double
  9. Dim Y As Double
  10.  
  11. Dim s As shape
  12. Dim sOriginal As shape
  13. Dim sDuplicate As shape
  14. Dim sr_from_contour As ShapeRange
  15. Dim e As Effect
  16. Set sOriginal = ActiveShape
  17. Dim srTemp As ShapeRange
  18. Dim sContourCurve_1 As shape
  19. Dim sContourCurve_2 As shape
  20. Dim shapesss As shape
  21.  
  22. ActiveDocument.Unit = cdrMillimeter
  23.  
  24. Set sr = ActivePage.Shapes.FindShapes(Type:=cdrTextShape)
  25.  
  26. Set sh = sr.Shapes(1)
  27. sh.Text.Story.Font = "khalil liss font"
  28. X = 0
  29. Y = 0
  30.  
  31.  
  32.  
  33.  
  34. Set e = sh.CreateContour(cdrContourOutside, ConvertUnits(0.26, cdrMillimeter, ActiveDocument.Unit), , , , , , , , , 2)
  35.  
  36. sh.GetSize X, Y
  37.  
  38.  
  39.  
  40. 'sh.SetSize 38, 38 * y / x
  41. sh.Text.FontPropertiesInRange(1, 1, cdrWordIndexing).RangeKerning = 100
  42.  
  43.  
  44.  
  45.  
  46.  
  47. 'sh.Text.FontPropertiesInRange(1, 1, cdrWordIndexing).RangeKerning = 0
  48. Set srTemp = e.Separate
  49. Set sContourCurve_2 = srTemp(2)
  50. sContourCurve_2.Delete
  51.  
  52.  
  53. ' get alphabet close to each other
  54. srTemp(1).BreakApart
  55.  
  56.  
  57.  
  58. 'Dim sh As Shape
  59. Dim prevvX As Double
  60. Dim prevvY As Double
  61. Dim nexttX As Double
  62. Dim nexttY As Double
  63. Dim prevvX2 As Double
  64. Dim prevvY2 As Double
  65. Dim nextXt2 As Double
  66. Dim nexttY2 As Double
  67. Dim combineshapes(20, 20) As Variant
  68. Dim starttab As Integer
  69. starttab = 2
  70.  
  71. Dim j As Integer
  72.  
  73. Dim ss As Shapes
  74. Dim kk As Integer
  75. Set ss = ActiveLayer.Shapes
  76. kk = 1
  77.  
  78. Dim lengthh As Integer
  79. ' fill the matrice with zero
  80. lengthh = ss.count
  81.  
  82. 'For i = 1 To lengthh
  83. '    For j = 1 To lengthh
  84. '
  85. '        combineshapes(i, j) = 0
  86. '
  87. '    Next
  88. 'Next
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.  
  96.  
  97. For i = 1 To ss.count
  98.     starttab = 2
  99.    
  100.     ss(i).GetPositionEx cdrMiddleRight, prevvX, prevvY
  101.     ss(i).GetPositionEx cdrMiddleLeft, nexttX, nexttY
  102.     For j = 1 To ss.count
  103.       If i <> j Then
  104.      
  105.        
  106.        
  107.        
  108.        
  109.         ss(j).GetPositionEx cdrMiddleRight, prevvX2, prevvY2
  110.         ss(j).GetPositionEx cdrMiddleLeft, nextXt2, nexttY2
  111.        
  112.        
  113.         If (prevvX > prevvX2) And (nexttX < nextXt2) Then
  114.               'ActiveDocument.CreateSelection ss(i), ss(j)
  115.              'ActiveSelection.Group
  116.              
  117.               'combineshapes(i, 1) = ss(i).StaticID
  118.              If (IsInArray(ss(i).StaticID, combineshapes)) = False Then
  119.                 combineshapes(i, 1) = ss(i).StaticID
  120.                 ss(i).Outline.width = 0.1 * i
  121.               End If
  122.               If (IsInArray(ss(j).StaticID, combineshapes)) = False Then
  123.                 combineshapes(i, starttab) = ss(j).StaticID
  124.                  ss(j).Outline.width = 0.1 * i
  125.                  starttab = starttab + 1
  126.               End If
  127.              
  128.              
  129.        
  130.         End If
  131.       End If
  132.     Next
  133.     'ss(i).SetPosition i * 10, i * 10
  134.    starttab = 2
  135. kk = kk + 1
  136. Next
  137. Dim G As Integer
  138. Dim d As Integer
  139.  
  140.    
  141.  
  142. Set ss = ActiveLayer.Shapes
  143. ss.All.BreakApart
  144.  
  145. Dim w As Integer
  146.  
  147. lengthh = ss.count
  148. Dim shapeToCombine As shape
  149. Dim ShapeRangeTocombine As ShapeRange
  150. Set shapeToCombine = ss.First
  151.  
  152. 'For w = 1 To lengthh
  153. '    For g = 1 To lengthh
  154. '
  155. '        If Not combineshapes(w, g) = Empty Then
  156. ''            shapeToCombine = ActivePage.FindShape(StaticID:=combineshapes(w, g))
  157. ''            ShapeRangeTocombine.Add shapeToCombine
  158. '                ActiveDocument.ActivePage.FindShape(StaticID:=combineshapes(w, g)).Move 0#, 20
  159. '                MsgBox (combineshapes(w, g))
  160. '
  161. '
  162. '        End If
  163. '
  164. '
  165. '    Next
  166. ''    If Not ShapeRangeTocombine Is Nothing Then
  167. ''        ShapeRangeTocombine.CreateSelection
  168. ''        ShapeRangeTocombine.Move 10, 0#
  169. ''
  170. ''    End If
  171. '
  172. '
  173. '    Dim s2 As Shape
  174. ''    'ssss.CreateSelection
  175. '    Set s2 = ActiveSelection.Combine
  176. 'Next
  177. Dim done As Boolean
  178. done = False
  179. For w = 1 To lengthh
  180.  
  181.    
  182.     If done = False Then
  183.         If w = 1 Then
  184.             done = True
  185.         End If
  186.         ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  187.        
  188.        
  189.     End If
  190.     If w > 1 Then
  191.         ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  192.     End If
  193.    
  194.    
  195.     For G = 1 To lengthh
  196.        
  197.         If combineshapes(w, G) > 0 Then
  198.             ActiveDocument.AddToSelection ActivePage.FindShape(StaticID:=combineshapes(w, G))
  199.         End If
  200.     Next
  201.     If ActivePage.SelectableShapes.count > 1 Then
  202.         ActiveSelection.Combine
  203.     End If
  204.     ActiveSelectionRange.RemoveFromSelection
  205.  
  206.    
  207. Next
  208.  
  209.  
  210.  
  211. 'For w = 1 To lengthh
  212. ''    If w = 3 Then
  213. ''    If combineshapes(w, 1) <> 0 Then
  214. ''            'ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  215. '''            Set sss = ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  216. '''            sss.CreateSelection
  217. ''            ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  218. ''
  219. ''    End If
  220. ''    Else
  221. '        'If ActivePage.FindShape(StaticID:=combineshapes(w, 1)).IsSimpleShape Or combineshapes(w, 1) > 0 Then
  222. '        'If combineshapes(w, 1) > 0 Then
  223. '            'Set shapeToCombine = ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  224. '            'ActivePage.FindShape(StaticID:=combineshapes(w, 1)).CreateSelection
  225. '            'ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  226. '            'shapeToCombine.CreateSelection
  227. '
  228. '            Dim srs As New ShapeRange
  229. '            srs.Add ActivePage.FindShape(StaticID:=combineshapes(w, 1))
  230. '        'End If
  231. ''    End If
  232. '
  233. '
  234. '    For g = 1 To ss.count
  235. '            If combineshapes(w, g + 1) > 0 Then
  236. '
  237. '            'ActiveDocument.RemoveFromSelection
  238. '
  239. '            ''ActiveDocument.AddToSelection ActivePage.FindShape(StaticID:=combineshapes(w, g + 1))
  240. '
  241. '            srs.Add ActivePage.FindShape(StaticID:=combineshapes(w, g + 1))
  242. '            'For d = 2 To 8
  243. '
  244. '
  245. '            'ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=combineshapes(i, g))
  246. '
  247. '            End If
  248. '            'ActivePage.FindShape(StaticID:=combineshapes(i, g)).Move 0#, i * 1
  249. '
  250. ''            Set sss = ActivePage.FindShape(StaticID:=combineshapes(i, g))
  251. ''            If Not sss Is Nothing Then ssss.Add ssss
  252. '
  253. '
  254. '
  255. '
  256. '
  257. '
  258. '
  259. '
  260. '            'ActiveSelection.Combine
  261. '            'ActivePage.FindShape(StaticID:=combineshapes(i, g)).Move 0#, i * 10
  262. '
  263. '
  264. '
  265. '    Next
  266. '    Dim s2 As Shape
  267. '    'ssss.CreateSelection
  268. '    Set s2 = ActiveSelection.Combine
  269. 'Next
  270. ''srTemp(1).SetSize 38, 38 * y / x
  271. ''get Contour Curve 2 as a shape
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280. 'make all the shapes in table
  281. Dim length As Integer
  282.  
  283.  
  284. length = ss.count
  285. Dim arrayorder(20) As Integer
  286. Dim shtreat As shape
  287. Dim ii As Integer
  288.  
  289. ii = 0
  290. Set ss = ActiveLayer.Shapes
  291. For Each shtreat In ss
  292.     arrayorder(ii) = shtreat.StaticID
  293.     ii = ii + 1
  294. Next shtreat
  295. Dim Test As Integer
  296.  
  297.  
  298. ' test if alphabet ordered in right manner
  299.  
  300.  
  301.  
  302.  
  303.  
  304. Dim min As Integer
  305. 'order the shapes
  306. For i = 0 To ii - 1
  307.     For j = i + 1 To ii
  308.         If ActivePage.FindShape(StaticID:=arrayorder(i)).PositionX > ActivePage.FindShape(StaticID:=arrayorder(j)).PositionX Then
  309.            
  310.             Test = arrayorder(i)
  311.             arrayorder(i) = arrayorder(j)
  312.             arrayorder(j) = Test
  313.            
  314.         End If
  315.     Next j
  316. Next i
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324. Dim incr As Integer
  325.  
  326. 'get shapes close to each other
  327. 'Dim combinedShape As Shape
  328. 'Set ss = ActiveLayer.Shapes
  329. 'ActiveDocument.CreateSelection ActivePage.FindShape(StaticID:=arrayorder(0))
  330. 'Set combinedShape = ActiveDocument.ActiveShape
  331. '
  332. 'Dim maxsteps As Integer
  333. '
  334. 'For i = 0 To (UBound(arrayorder) - LBound(arrayorder)) - 1
  335. '
  336. ''for loop
  337. '    For incr = 0 To 50
  338. '
  339. '        If Not (combinedShape.DisplayCurve.IntersectsWith(ActivePage.FindShape(StaticID:=arrayorder(i + 1)).DisplayCurve)) Then
  340. '            combinedShape.Move 0.3, 0#
  341. '        Else
  342. '            Exit For
  343. '        End If
  344. '
  345. '    Next
  346. '
  347.  
  348.  
  349.  
  350. '    Do While Not (combinedShape.DisplayCurve.IntersectsWith(ActivePage.FindShape(StaticID:=arrayorder(i + 1)).DisplayCurve)) ' And (maxsteps < 10)
  351. '
  352. '        combinedShape.Move 0.3, 0#
  353. '        maxsteps = maxsteps + 1
  354. '
  355. '    Loop
  356.    
  357.  
  358. '    For maxsteps = 0 To 10
  359. '        If Not combinedShape.DisplayCurve.IntersectsWith(ActivePage.FindShape(StaticID:=arrayorder(i + 1)).DisplayCurve) Then
  360. '                    combinedShape.Move 0.3, 0#
  361. '
  362. '        End If
  363. '
  364. '    Next maxsteps
  365.  
  366.  
  367.    
  368.  
  369.  
  370.  
  371.  
  372.     'combinedShape.Move 0.2, 0#
  373.  
  374.  
  375.     'Set combinedShape = combinedShape.Weld(ActivePage.FindShape(StaticID:=arrayorder(i + 1)), False, False)
  376.  
  377.  
  378.     'ActiveDocument.CreateSelection combinedShape, ActivePage.FindShape(StaticID:=arrayorder(i + 1))
  379.  
  380.     'Set combinedShape = ActiveSelection.Combine
  381.    'ActivePage.FindShape(StaticID:=arrayorder(i)).SetPosition i * 10, i * 10
  382.  
  383.  
  384.  
  385. 'Next i
  386.  
  387.  
  388. Dim shape As shape
  389.  
  390.  
  391.  
  392. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement