Like many people here, I believe I am on the right path but I am missing a few minor things to get my script to work. Also, I am pretty new to ASOC and recently purchased Shane Stanleys ASOC Explored book. Excellent resource but I am still struggling with one part.
In brief, I am build a script where the user input data into text fields that will write data to a Text Edit document. The text edit will be read by Adobe After Effects to change lower thirds and other text within the AE project. I have had no issues with that. After the Text Edit document is written, I have a shell script that sends the document to aerender via in the command line. No problem there either. Since other people will be using this, I want there to be a progress bar to show that something is happening so they dont quit the application or start monkeying on the keyboard. I can’t figure out how to feed the render progress to a progress indicator. The aerender has a stdout which it defaults to errors and progress with a verbose argument as seen here:
http://help.adobe.com/en_US/aftereffects/cs/using/WS3878526689cb91655866c1103a4f2dff7-79a3a.html
The progress bars binding are set in IB with is maxVal to the maxVal variable set in outlets and its value set to getProgress. usesThreadedAnimation is also set under User Defined Runtime Attributes.
All of my code is inside a single handler where a button is clicked (this may be my problem). I imagine I am doing something way off but I could but I could be close. Here is my code (sorry for the length but Im hoping more info will be better):
script AppDelegate
property parent : class "NSObject"
-- IBOutlets
property clientName : ""
property spotName : ""
property isciCode : ""
property director : ""
property producer : ""
property spotFrameRate : missing value
property spotLength : missing value
property resolution : missing value
property leader : missing value
property barsTone : true
property renderText : missing value
property progressBar : missing value
property getProgress : missing value
property myWindow : missing value
property maxVal : 100
on applicationWillFinishLaunching_(aNotification)
-- Insert code here to initialize your application before any files are opened
end applicationWillFinishLaunching_
on applicationShouldTerminate_(sender)
-- Insert code here to do any housekeeping before your application quits
return current application's NSTerminateNow
end applicationShouldTerminate_
-- IBActions (button clicks)
on spotFrameRateUsed_(sender) -- connected to combobox in IB
log sender's stringValue()
end spotFrameRateUsed_
on spotLengthUsed_(sender) -- connected to combobox in IB
log sender's stringValue()
end spotLengthUsed_
on leaderUsed_(sender) -- connected to combobox in IB
log sender's stringValue()
end leaderUsed_
on resolutionUsed_(sender) -- connected to combobox in IB
log sender's stringValue()
end resolutionUsed_
on barsToneUsed_(sender)
log sender's integerValue()
end barsToneUsed_
on create_(sender)
tell my myWindow to displayIfNeeded()
set clientName to clientName's stringValue() as text
set spotName to spotName's stringValue() as text
set isciCode to isciCode's stringValue() as text
set director to director's stringValue() as text
set producer to producer's stringValue() as text
set slateText to "Users:home:Desktop:aeText.txt"
tell application "TextEdit"
activate
make new document
save document as slateText
set clientName to do shell script "echo var clientName = [\\\"" & quoted form of clientName & "\\\"]\\;"
set spotName to do shell script "echo var spotName = [\\\"" & quoted form of spotName & "\\\"]\\;"
set isciCode to do shell script "echo var isciCode = [\\\"" & quoted form of isciCode & "\\\"]\\;"
set director to do shell script "echo var director = [\\\"" & quoted form of director & "\\\"]\\;"
set producer to do shell script "echo var producer = [\\\"" & quoted form of producer & "\\\"]\\;"
set sourceText to clientName & return & spotName & return & isciCode & return & director & return & producer
set slateText to open for access file "Users:home:Desktop:aeText.txt" with write permission
write sourceText to slateText
close access slateText
quit application "TextEdit"
end tell
--This shell sends to aerender
set renderText to POSIX path of "/Users/home/sendToRenderer.sh"
do shell script renderText
getProgress's setString_("")
set currentTask to NSTask's alloc's init()
set outputpipe to NSPipe's pipe()
currentTask's setStandardOutput_(outputpipe)
currentTask's setStandardError_(outputpipe)
currentTask's setLaunchPath_("/Users/home/sendToRenderer.sh")
currentTask's setArguments_({"-v"})
NSNotificationCenter's defaultCenter()'s addObserver_selector_name_object_(me, "readPipe:", "NSFileHandleReadCompletionNotification", currentTask's standardOutput()'s fileHandleForReading())
NSNotificationCenter's defaultCenter()'s addObserver_selector_name_object_(me, "endPipe:", "NSTaskDidTerminateNotification", currentTask)
currentTask's standardOutput()'s fileHandleForReading()'s readInBackgroundAndNotify()
currentTask's |launch|()
progressBar's incrementBy_(1)
progressBar's displayIfNeeded()
end create_
on readPipe_(aNotification)
set dataString to aNotification's userInfo's objectForKey_("NSFileHandleNotificationDataItem")
set newstring to ((NSString's alloc()'s initWithData_encoding_(dataString, current application's NSUTF8StringEncoding)))
getProgress's setString_((getProgress's |string|() as integer) & newstring as integer)
aNotification's object()'s readInBackgroundAndNotify()
end readPipe_
on endPipe_(aNotification)
NSNotificationCenter's defaultCenter()'s removeObserver_(me)
end endPipe_
end script
And for reference the shell script I am calling is in my home directory and has been made executable through the terminal. This is what the shell script contains:
/Applications/Adobe\ After\ Effects\ CS5/aerender -project /Users/home/Desktop/lowerThirds.aep
Thanks for any direction or help you can lend.