• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: scripting for Adobe Illustrator error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: scripting for Adobe Illustrator error


  • Subject: Re: scripting for Adobe Illustrator error
  • From: Jake Rowlands <email@hidden>
  • Date: Tue, 18 Oct 2016 12:36:49 -0400

Posting the entire script. Error now is error "The variable WindowPosition is not defined." number -2753 from "WindowPosition" of line 71.

  1. tell application "Adobe Illustrator"
  2. set clicker to {23, 46}
  3. --set user interaction level to interact with all
  4. try
  5. if contents of selection is not "Client" then

  6. error number -128
  7. end if
  8. on error
  9. display dialog "Please select the word \"Client\"" giving up after 1.5
  10. error number -128
  11. end try

  12. activate
  13. set x to properties of selection
  14. delay 0.15
  15. tell application "System Events"
  16. keystroke "a" using command down
  17. end tell
  18. redraw
  19. set y to properties of selection
  20. set TheContent to contents of y
  21. set TheSize to size of x
  22. set TheSelection to item 1 of selection of y
  23. set TheContainer to container of y
  24. set selection to {}
  25. --set selection to page item 1 of document 1
  26. redraw



  27. tell document 1
  28. set TheFrame to every text frame whose contents is TheContent
  29. end tell


  30. --say "window"

  31. tell application "System Events"
  32. tell process "Adobe Illustrator"
  33. --beep
  34. set frontmost to true
  35. my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
  36. set Sizes1 to size of every window
  37. my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
  38. set Sizes2 to size of every window
  39. --beep
  40. if length of Sizes1 is not length of Sizes2 then
  41. if length of Sizes1 is greater than length of Sizes2 then
  42. set TheSize to item 1 of my RemoveComonList(Sizes1, Sizes2)
  43. else
  44. set TheSize to item 1 of my RemoveComonList(Sizes2, Sizes1)
  45. end if
  46. --beep
  47. set TOOLS to every window whose size is TheSize
  48. if TOOLS is {} then
  49. my do_submenu("Adobe Illustrator", "Window", "Tools", "Default")
  50. set TOOLS to every window whose size is TheSize
  51. end if
  52. --beep
  53. tell item 1 of TOOLS
  54. set WindowPosition to position
  55. set item 1 of WindowPosition to (item 1 of WindowPosition) + (item 1 of clicker)
  56. set item 2 of WindowPosition to (item 2 of WindowPosition) + (item 2 of clicker)
  57. end tell
  58. end if
  59. end tell
  60. end tell
  61. --say "Click"

  62. my MouseClick(item 1 of WindowPosition, item 2 of WindowPosition, 1)
  63. delay 1
  64. set TheContent to contents of the selection

  65. --beep

  66. set TheContent to my stringtolist(TheContent, return)


  67. set TheResult to {}

  68. set eventDate to current date
  69. set dayInteger to day of eventDate as integer as string
  70. set monthInteger to month of eventDate as integer as string
  71. set yearInteger to year of eventDate as integer as string
  72. if (count of every character of dayInteger) is 1 then
  73. set dayInteger to "0" & dayInteger
  74. end if
  75. if (count of every character of dayInteger) is 1 then
  76. set dayInteger to "0" & dayInteger
  77. end if
  78. if (count of every character of monthInteger) is 1 then
  79. set monthInteger to "0" & monthInteger
  80. end if
  81. set yearInteger to (items 3 through 4 of every character of yearInteger) as string
  82. set dateString to monthInteger & "." & dayInteger & "." & yearInteger
  83. --beep
  84. ----PRINT SCALE

  85. set SlugContents to my stringtolist(TheContent, return)
  86. set SlugBlack to {cyan:0.0, magenta:0.0, yellow:0, black:100}
  87. set AutoSlugList to {"xscalex", "xdateLRx", "xfilex", "xjobdescx", "xjobx", "xdateAx", "xdiex", "xdiesizex"}
  88. --set user interaction level to interact with all
  89. set ArtboardDims to artboard rectangle of artboard 1 of document 1
  90. set theWidth to width of document 1
  91. set theHeight to height of document 1
  92. set ThePath to file path of document 1
  93. set Parentfolder to item 2 of my FolderPathtoList(ThePath, 0, 1)
  94. --set xjobx to items 1 thru 10 of every item of Parentfolder as string
  95. set xjobx to item 1 of my stringtolist(Parentfolder, " ")

  96. set xjobdescx to items ((count of every item of xjobx) + 2) thru (count of every item of Parentfolder) of every item of Parentfolder as string
  97. set xfilex to name of document 1
  98. if theWidth is greater than theHeight then
  99. set ScaleV to round (776 / theHeight * 100)
  100. set scaleH to round (1198 / theWidth * 100)
  101. if scaleH is greater than ScaleV then
  102. set PrintScale to ScaleV
  103. else
  104. set PrintScale to scaleH
  105. end if
  106. else
  107. set ScaleV to round (1198 / theHeight * 100)
  108. set scaleH to round (776 / theWidth * 100)
  109. if scaleH is greater than ScaleV then
  110. set PrintScale to ScaleV
  111. else
  112. set PrintScale to scaleH
  113. end if
  114. end if

  115. if PrintScale > 99 then
  116. set PrintScale to 100
  117. end if

  118. set xscalex to PrintScale & "%"

  119. --beep
  120. set this_text to name of document 1
  121. set THE_TEXT to this_text as string






  122. -----------------------------Name Switch

  123. set userName to long user name of (system info)
  124. set userName to my name_switch(userName, "afelch", "AF")
  125. set userName to my name_switch(userName, "jrowlands", "JR")
  126. set userName to my name_switch(userName, "bpope", "BP")
  127. set userName to my name_switch(userName, "rbaer", "RB")
  128. set userName to my name_switch(userName, "bkoski", "BK")
  129. set userName to my name_switch(userName, "jelkins", "JE")
  130. set xdateLRx to dateString & " " & userName as string

  131. (*
  132. set thedisplay to {"Job: ", xjobx as string, return, "Description: ", xjobdescx, return, "File: ", xfilex, return, "Artist: ", xdateAx, return, "Last Rev: ", xdateLRx, return, "Print Out Date: ", xdatePOx, return, "Proof Scale: ", xscalex}

  133. display dialog (thedisplay as string) buttons {"Cancel", "Continue"} default button 2
  134. *)
  135. ------------




  136. (*
  137. repeat with fr from 1 to count of AutoSlugList
  138. try
  139. set fill color of every character of every word of text frame (item fr of AutoSlugList) of current document to SlugBlack
  140. on error
  141. set xfilex to false
  142. end try
  143. end repeat

  144. *)

  145. --beep
  146. set prejob to "Job#: "
  147. set prefile to "File Name: "
  148. set predatelr to "Last Revision: "
  149. set prescale to "ART IS: 100%  PROOF IS: "
  150. set end of TheResult to item 1 of TheContent
  151. set end of TheResult to return
  152. set end of TheResult to prejob & xjobx
  153. set end of TheResult to return
  154. set end of TheResult to xjobdescx
  155. set end of TheResult to return
  156. set end of TheResult to "File Name: " & xfilex
  157. set end of TheResult to return
  158. set end of TheResult to item 5 of TheContent
  159. set end of TheResult to return
  160. set end of TheResult to "Last Revision: " & xdateLRx
  161. set end of TheResult to return
  162. set end of TheResult to item 7 of TheContent
  163. set end of TheResult to return
  164. set end of TheResult to item 8 of TheContent
  165. set end of TheResult to return
  166. set end of TheResult to item 9 of TheContent
  167. set end of TheResult to return
  168. set end of TheResult to item 10 of TheContent
  169. set end of TheResult to return
  170. set end of TheResult to item 11 of TheContent
  171. set end of TheResult to return
  172. set end of TheResult to prescale & xscalex
  173. set TheResult to TheResult as string
  174. display alert TheResult

  175. set contents of item 1 of TheFrame to TheResult
  176. my ChangeFont(1, length of TheResult, "HelveticaNeueLTStd-Cn", index of TheContainer)
  177. set theStart to 1
  178. set theEnd to 7
  179. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  180. set theStart to (length of item 1 of TheContent) + 1
  181. set theEnd to theStart + (length of prejob)
  182. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  183. set theStart to theEnd + (length of xjobdescx) + (length of xjobx) + 2
  184. set theEnd to theStart + (length of prefile)
  185. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  186. set theStart to theEnd + (length of xfilex) + 2
  187. set theEnd to theStart + 13
  188. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  189. set theStart to theEnd + (length of item 5 of TheContent) - 13
  190. set theEnd to theStart + (length of predatelr)
  191. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  192. set theStart to theEnd + (length of xdateLRx) + 1
  193. set theEnd to theStart + (15)
  194. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  195. set theStart to theEnd + (length of item 7 of TheContent) - 14
  196. set theEnd to theStart + 6
  197. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  198. set theStart to theEnd + (length of item 8 of TheContent) - 5
  199. set theEnd to theStart + 6
  200. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  201. set theStart to theEnd + (length of item 9 of TheContent) - 5
  202. set theEnd to theStart + (length of item 10 of TheContent) + 13
  203. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)

  204. set theStart to theEnd + (length of item 11 of TheContent) - 11
  205. set theEnd to theStart + 8
  206. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)
  207. set theStart to theEnd + 5
  208. set theEnd to theStart + 10
  209. my ChangeFont(theStart, theEnd, "HelveticaNeueLTStd-HvCn", index of TheContainer)

  210. --------------







  211. --display dialog "Please select the word \"Client\"" giving up after 0.5


  212. end tell



  213. on RemoveComonList(list1, list2)

  214. set list3 to {}
  215. set templist1 to {}
  216. set templist2 to {}
  217. repeat with fr from 1 to count of list1
  218. set end of templist1 to item fr of list1 as string
  219. end repeat
  220. --set templist1 to reverse of templist1
  221. repeat with fr from 1 to count of list2
  222. set end of templist2 to item fr of list2 as string
  223. end repeat
  224. --set templist2 to reverse of templist2
  225. repeat with x from 1 to count of items of list1


  226. repeat with y from 1 to count of list1
  227. set n to item y of templist1
  228. if n is not in templist2 then set end of list3 to item y of list1
  229. end repeat
  230. end repeat

  231. return list3
  232. end RemoveComonList


  233. on do_submenu(app_name, menu_name, menu_item, submenu_item)
  234. try
  235. -- bring the target application to the front

  236. tell application "System Events"
  237. tell process app_name
  238. set frontmost to true
  239. tell menu bar 1
  240. tell menu bar item menu_name
  241. tell menu menu_name
  242. tell menu item menu_item
  243. tell menu menu_item
  244. click menu item submenu_item
  245. end tell
  246. end tell
  247. end tell
  248. end tell
  249. end tell
  250. end tell
  251. end tell
  252. return true
  253. on error error_message
  254. return false
  255. end try
  256. end do_submenu

  257. on FolderPathtoList(myPath, TrimFront, TrimBack)
  258. set FolderPath to {}
  259. ----beep
  260. set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
  261. ----beep
  262. set AppleScript's text item delimiters to {":"}
  263. set pathItems to text items of (myPath as text)
  264. ----beep
  265. set TF to (TrimFront as number) + 1
  266. set TB to ((count of pathItems) - TrimBack as integer) as integer
  267. set AppleScript's text item delimiters to oldDelimiters
  268. return items TF thru TB of pathItems as list
  269. end FolderPathtoList

  270. on name_switch(theVariable, Old, new)
  271. if theVariable is Old then
  272. set theVariable to new
  273. else
  274. set theVariable to theVariable
  275. end if
  276. end name_switch

  277. on stringtolist(TheString, TheDelimiter)
  278. set theList to {}
  279. set oldDelimiters to AppleScript's text item delimiters -- always preserve original delimiters
  280. set AppleScript's text item delimiters to TheDelimiter as list
  281. set theList to text items of (TheString as text)

  282. set AppleScript's text item delimiters to oldDelimiters
  283. return theList
  284. end stringtolist

  285. on ChangeFont(CharStart, CharEnd, TheFont, TheStory)
  286. tell application "Adobe Illustrator"
  287. set text font of text from character CharStart to character CharEnd of story TheStory of document 1 to text font TheFont
  288. end tell
  289. end ChangeFont

  290. on MouseClick(x, y, MouseButton)
  291. do shell script "
  292. /usr/bin/python <<END
  293. import sys
  294. import time
  295. from Quartz.CoreGraphics import *
  296. def mouseEvent(type, posx, posy):
  297.           theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
  298.           CGEventPost(kCGHIDEventTap, theEvent)
  299. def mousemove(posx,posy):
  300.           mouseEvent(kCGEventMouseMoved, posx,posy);
  301. def mouseclick(posx,posy):
  302.           mouseEvent(kCGEventLeftMouseDown, posx,posy);
  303.           mouseEvent(kCGEventLeftMouseUp, posx,posy);
  304. ourEvent = CGEventCreate(None);
  305. currentpos=CGEventGetLocation(ourEvent);             # Save current mouse position
  306. mouseclick(" & x & "," & y & ");
  307. mousemove(int(currentpos.x),int(currentpos.y));      # Restore mouse position
  308. END"
  309. end MouseClick

On Mon, Oct 17, 2016 at 12:18 PM, Steve Mills <email@hidden> wrote:
Nothing you have posted provides enough information for anyone to help. You've given us small hunks of scripts that don't provide enough information. The last hunk you provide doesn't even attempt to get any "item 1" of any object, but you say the error is:

error "Can’t get item 1 of {}." number -1728 from item 1 of {}


The previous hunk you gave doesn't include the functions do_submenu or RemoveComonList, so we can't test it. If you really expect any kind of real help, you need to post the entire script.

Sent from iCloud's ridiculous UI, so, sorry about the formatting

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (applescript-users@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: scripting for Adobe Illustrator error
      • From: Yvan KOENIG <email@hidden>
References: 
 >Re: scripting for Adobe Illustrator error (From: Jake Rowlands <email@hidden>)
 >Re: scripting for Adobe Illustrator error (From: Steve Mills <email@hidden>)

  • Prev by Date: Re: ASOC warning messages
  • Next by Date: Re: scripting for Adobe Illustrator error
  • Previous by thread: Re: scripting for Adobe Illustrator error
  • Next by thread: Re: scripting for Adobe Illustrator error
  • Index(es):
    • Date
    • Thread