The Omni Group
These forums are now read-only. Please visit our new forums to participate in discussion. A new account will be required to post in the new forums. For more info on the switch, see this post. Thank you!

Go Back   The Omni Group Forums > OmniGraffle > OmniGraffle General
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Creating Links to Files : is there a script? Thread Tools Search this Thread Display Modes
Hi,
I am using OmniGraffle Pro as a visual file manager come note book. At present if I wish to add a link to a file I have two options.

Option 1 is to create a graphic, select it open the inspector and drag the target file from the finder to the inspector; it works but is a little slow especially if the inspector hides and OG has the reselected.

Option 2 is to use the Folder Import option which is started by dragging a folder from the finder to the Omnigraffle icon, I accept the option of a new canvas and after a moment a folder map is added with nice icon based graphics all linked back to the original files and labeled with the original file names. Next I select all the connection lines and delete them, then I add the file graphics to my diagram.

While option 2 works I would like to be able to create the graphics, without the linking lines, based on files I have selected in a dialog. I would also like the file names to be added as notes rather than labels. In short I need an AppleScript script. Does anyone have one I could use as the basis of a new script to save me starting from scratch?

best wishes

Simon
 
Rather than building this structure from the ground up, maybe converting the output of option 2 would be quicker.

This fragment should remove the connecting lines and set the notes field to have the label string. It's worth about what you paid for it :-)

Code:
tell application "OmniGraffle Professional 5"
	tell canvas of front window
		set myGraphics to every graphic
		repeat with myGraphic in myGraphics
			tell myGraphic
				if class is shape then
					set myProps to properties
					set labeltext to myProps's text
					set notes to last item of labeltext -- must be a better way, but what is it?
				else if class of myGraphic is line then
					delete myGraphic
				end if
			end tell
		end repeat
	end tell
end tell
You could use the choose file with multiple selections allowed construct to prompt you for the files you want to keep or exclude, then go down the list deleting the unwanted ones.
 
Many Thanks, you may be right about working with what is already provided.

I have been playing/learning about the finders file icons and it looks like some of the OS 9 scripting commands have not been implemented (yet?) in OS X. Also I have no idea how a file link is set as the standard technique of copy as Applescript does not reveal anything. The icon issue could be overcome by having the script hold the data of a number of icons and set them according to file type (a bit of a kludge) and I am working on how to set a link by script.

Thanks again for your script.

Simon
 
Any idea why the text "MyNote" is repeated twice in the code produced by "copy as applescript"?

Code:
make new shape at end of graphics with properties 
{size: {128.000000, 73.000000}, origin: {91.000000, 123.000000}, 
text: {text: "MyNote", text: "MyNote", font: "ArialMT", alignment: center}}
Simon
 
Quote:
Originally Posted by Simon Knight View Post
Any idea why the text "MyNote" is repeated twice in the code produced by "copy as applescript"?
Harmless bug?
 
Quote:
Originally Posted by whpalmer4 View Post
set notes to last item of labeltext -- must be a better way, but what is it?

[/code]
I'm not sure if this is better but I've ended up with a key value filename being filled with the value of text.

Code:
(* Script that is designed to process the graphics that result from a finder item being dropped on the
OG icon.  The script adds two data fields FileName and URL to each graphic and then populates them.  

It also deletes all the lines leaving just the icons.  If you want the lines just comment out the delete below

Most of the script was written by whpalmer4, I just fiddled a little.

Simon Knight Jan 2012

*)



tell application "OmniGraffle Professional 5"
	tell canvas of front window
		set myGraphics to every graphic
		repeat with myGraphic in myGraphics
			tell myGraphic
				if class is shape then
					
					--set myProps to properties  -- useful if uncommented to examine the prop list in script debugger
					
					set tFileName to text of myGraphic
					set tURL to url of myGraphic
					
					make new user data item with properties {name:"FileName", value:tFileName}
					make new user data item with properties {name:"URL", value:tURL}
				else if class of myGraphic is line then
					delete myGraphic
				end if
			end tell
		end repeat
	end tell
end tell
best wishes
Simon

Last edited by Simon Knight; 2012-01-14 at 12:35 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Links to files - OG seems unique Simon Knight OmniGraffle General 0 2012-01-26 12:09 PM
Creating a dated OF action with links to DevonThink record(s) RobTrew OmniFocus Extras 0 2011-02-13 01:21 PM
Creating Icon Files (.icns .ico) Simon Knight OmniGraffle General 1 2011-01-27 10:53 AM
Need help creating a script for creating a next action gcrump OmniFocus Extras 9 2009-02-21 06:10 PM
Creating File Links rather than embedding ssanchez OmniOutliner 3 for Mac 1 2006-10-17 07:03 AM


All times are GMT -8. The time now is 12:59 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2019, vBulletin Solutions, Inc.