Creating Links to Files : is there a script?
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 [/code] 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}}[/CODE] Simon |
[QUOTE=Simon Knight;106189]Any idea why the text "MyNote" is repeated twice in the code produced by "copy as applescript"?
[/QUOTE] Harmless bug? |
[QUOTE=whpalmer4;106177]
set notes to last item of labeltext -- must be a better way, but what is it? [/code] [/QUOTE] 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[/CODE] best wishes Simon |
All times are GMT -8. The time now is 10:33 PM. |
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.