I'm new to all this, so apologies if I'm doing something daft. I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents. I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby. I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign. I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test: #!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge' # I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport' appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument puts doc.name pgph = doc.allParagraphStyles pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari). I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same. Is there something I am missing here? Thanks in advance for any help you can offer. Fb
On Friday, December 16, 2011 at 10:17 AM, Stephen Horne wrote:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name (http://doc.name)
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name (http://style.name)}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
I am afraid I don't have a copy of InDesign, so I cannot test your specific situation. However, it would be interesting to know what part of your script is slow. Specifically, I would be interested in seeing some benchmarking to indicate whether your script is wasting more time on the "load_bridge_support_file" line or the "SBApplication.applicationWithURL" line. (I suppose calls through to InDesign could be the bottle neck as well, but that would be rather unexpected I should think.) You can probably start off with Ruby's Benchmark library (with some decent documentation here: http://rubydoc.info/stdlib/benchmark/frames , though honestly you only really need "Benchmark.measure"). From there it might be interesting to look at other profiling results, but best to start simple. - Josh
Hi Josh.
Joshua Ballanco <mailto:jballanc@gmail.com> 22 December 2011 15:04 On Friday, December 16, 2011 at 10:17 AM, Stephen Horne wrote:
I am afraid I don't have a copy of InDesign, so I cannot test your specific situation. However, it would be interesting to know what part of your script is slow. Specifically, I would be interested in seeing some benchmarking to indicate whether your script is wasting more time on the "load_bridge_support_file" line or the "SBApplication.applicationWithURL" line. (I suppose calls through to InDesign could be the bottle neck as well, but that would be rather unexpected I should think.)
You can probably start off with Ruby's Benchmark library (with some decent documentation here: http://rubydoc.info/stdlib/benchmark/frames , though honestly you only really need "Benchmark.measure"). From there it might be interesting to look at other profiling results, but best to start simple.
I've had a look at benchmark, and it seems it is the bit that creates the link to InDesign that's the bottleneck. Here's the code I used: #!/usr/local/bin/macruby framework 'ScriptingBridge' require 'benchmark' Benchmark.bm(7) do |x| x.report("load_BSF: ") { load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'} x.report("Create NSURL:") { @appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app")} x.report("Link to ID: ") { @id = SBApplication.applicationWithURL(@appurl)} x.report("Link to doc1:") { @doc = @id.activeDocument} end and here's the report it returned: user system total real load_BSF: 0.130000 0.000000 0.130000 ( 0.109424) Create NSURL: 0.000000 0.000000 0.000000 ( 0.001404) Link to ID: 27.770000 1.270000 29.040000 ( 14.824474) Link to doc1: 0.000000 0.000000 0.000000 ( 0.000127) Fb
- Josh
On 16 Dec 2011, at 15:17, Stephen Horne wrote:
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here: http://appscript.sourceforge.net/status.html I've never attempted to use macruby-appscript, but it might be worth trying? https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk Al
If it is ScriptingBridge that is slowing things down, then this sounds like perfect fodder for a bug report to Apple. - Josh On Thursday, December 22, 2011 at 12:15 PM, Alan Skipp wrote:
On 16 Dec 2011, at 15:17, Stephen Horne wrote:
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same. I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
http://appscript.sourceforge.net/status.html
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Al
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org (mailto:MacRuby-devel@lists.macosforge.org) http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
I've filed a bug under Bug ID# 10623540 https://bugreport.apple.com/cgi-bin/WebObjects/RadarWeb.woa/15/wo/EhDys34ihf... Fb
Joshua Ballanco <mailto:jballanc@gmail.com> 23 December 2011 07:10 If it is ScriptingBridge that is slowing things down, then this sounds like perfect fodder for a bug report to Apple.
- Josh
On Thursday, December 22, 2011 at 12:15 PM, Alan Skipp wrote:
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel Alan Skipp <mailto:al_skipp@fastmail.fm> 22 December 2011 17:15
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
http://appscript.sourceforge.net/status.html
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Al
Stephen Horne <mailto:fatste@gmail.com> 16 December 2011 15:17 I'm new to all this, so apologies if I'm doing something daft.
I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents.
I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby.
I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign.
I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
Thanks in advance for any help you can offer.
Fb
Alan Skipp <mailto:al_skipp@fastmail.fm> 22 December 2011 17:15
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
I agree, a real shame. I read Matt Neuburg's book on rb-appscript, and within a couple of days I was solving problems that had long frustrated me with applescript, but I'd skip-read the appscript page so hadn't noticed that warning.
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Yes, perhaps you're right. I've looked into trying this several times, but I've always been scared off by the need to install ObjC-Appscript and build frameworks, but maybe I should just get a grip. Fb
Al
Stephen Horne <mailto:fatste@gmail.com> 16 December 2011 15:17 I'm new to all this, so apologies if I'm doing something daft.
I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents.
I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby.
I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign.
I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
Thanks in advance for any help you can offer.
Fb
I have used macruby-appscript and it works fine. I had developed quiet a few apps with rb-appscript and I was able to get them all working with the macruby version. A few things needed change but I was able to write apps that used either macruby or MRI versions of appscript. Only a few methods in my "library" code needed to check at runtime which version was being used. Steve On 23 Dec 2011, at 12:39, Stephen Horne wrote:
Alan Skipp 22 December 2011 17:15
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
I agree, a real shame. I read Matt Neuburg's book on rb-appscript, and within a couple of days I was solving problems that had long frustrated me with applescript, but I'd skip-read the appscript page so hadn't noticed that warning.
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Yes, perhaps you're right. I've looked into trying this several times, but I've always been scared off by the need to install ObjC-Appscript and build frameworks, but maybe I should just get a grip.
Fb
Al
Stephen Horne 16 December 2011 15:17 I'm new to all this, so apologies if I'm doing something daft.
I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents.
I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby.
I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign.
I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
Thanks in advance for any help you can offer.
Fb
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
Thanks Al, Steve. You've given me the push I needed to sort out MacRuby-Appscript. It's taken me four hours to finally understand how to do it, but at least I have it running now. Fb
Steve Clarke <mailto:steve@sclarkes.me.uk> 23 December 2011 13:04 I have used macruby-appscript and it works fine. I had developed quiet a few apps with rb-appscript and I was able to get them all working with the macruby version. A few things needed change but I was able to write apps that used either macruby or MRI versions of appscript. Only a few methods in my "library" code needed to check at runtime which version was being used.
Steve
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel Stephen Horne <mailto:fatste@gmail.com> 23 December 2011 12:39
Alan Skipp <mailto:al_skipp@fastmail.fm> 22 December 2011 17:15
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
I agree, a real shame. I read Matt Neuburg's book on rb-appscript, and within a couple of days I was solving problems that had long frustrated me with applescript, but I'd skip-read the appscript page so hadn't noticed that warning.
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Yes, perhaps you're right. I've looked into trying this several times, but I've always been scared off by the need to install ObjC-Appscript and build frameworks, but maybe I should just get a grip.
Fb
Al
Stephen Horne <mailto:fatste@gmail.com> 16 December 2011 15:17 I'm new to all this, so apologies if I'm doing something daft.
I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents.
I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby.
I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign.
I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
Thanks in advance for any help you can offer.
Fb
Alan Skipp <mailto:al_skipp@fastmail.fm> 22 December 2011 17:15
I can confirm the same problem with setting up a scripting bridge link to InDesign. In my experience rb-appscript is far superior to scripting bridge, it's a shame it can no longer be developed. Explained here:
http://appscript.sourceforge.net/status.html
I've never attempted to use macruby-appscript, but it might be worth trying?
https://github.com/dnagir/appscript/tree/master/macruby-appscript/trunk
Al
Stephen Horne <mailto:fatste@gmail.com> 16 December 2011 15:17 I'm new to all this, so apologies if I'm doing something daft.
I'm trying to create a MacRuby GUI application to parse a load of information from InDesign documents.
I've previously made this application using applescriptObjC, but I was constantly bouncing off the walls of applescript and getting seemingly random bad_exec errors if I ran it too many times without a reboot, so I've decided to try with MacRuby.
I'm only at the stage of probing MacRuby to see how to do it, and I've immediately hit a problem; it seems to take a very long time to set up the link to InDesign.
I found some code in correspondence between Matt Aimonetti and Spencer Rose that I am using to test:
#!/usr/local/bin/macruby framework 'Foundation' framework 'ScriptingBridge'
# I followed Matt's instructions for making the bridge support file, but I wasn't sure where it needs to go, so I did this for a quick fix. load_bridge_support_file '/Users/fatboy/inDesign.bridgesupport'
appurl = NSURL.fileURLWithPath("/Applications/Adobe Indesign CS5/Adobe InDesign CS5.app") @id = SBApplication.applicationWithURL(appurl) doc = @id.activeDocument
puts doc.name
pgph = doc.allParagraphStyles
pgph.each do |style| puts "#{style.name}" puts style.properties["appliedFont"].name end
This code works, but it takes 15+ seconds to set up the link to InDesign (similar stuff with safari takes about 1 second, and in applescript or rb-appscript it takes about a tenth of a second for either InDesign or safari).
I also tried SBApplication.applicationWithBundleIdentifier("com.adobe.indesign"), and this was just the same.
Is there something I am missing here?
Thanks in advance for any help you can offer.
Fb
participants (4)
-
Alan Skipp
-
Joshua Ballanco
-
Stephen Horne
-
Steve Clarke