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

 
Defining global variables. Thread Tools Search this Thread Display Modes
Hi all,

I've just started exploring beyond it's very basic feature-set and have stumbled across variables. Oh, how much work could I have save, had I known earlier about this! (Yes, I'm a newbie to the program.) Anyways, there are predefined system variables and then there's the possibility to create custom variables la <%UserData myvariablename%>.

My problem is, that I can't seem to find a way to define the "data key" and "data value" globally for the whole document, but just locally for one specific object at a time. Wouldn't it make sense, to set up all variables (e.g. customer, projectname, etc.) just once and then call the variable whenever I need it. I've found several threads discussing variables, but nothing on this problem. Or am I completely missing something here?

UPDATE: To be a bit more specific. Say I'm working on a website for a product and mid-project the name of the product is changed. It would be great, to just have this one location, where I'd have to change said name, and it then is updated throughout the whole document.

Thanks for any input!

cheers.

Last edited by dekdekdek; 2010-11-10 at 03:33 AM..
 
I am looking for the very same thing - has anyone been able to accomplish this? I'd love to use "Client Name" in multiple places in my file as well, throughout canvases.
 
Welcome to the forums, Floatgraphics! We all browse the forums as we're able on top of our other duties, but in this case, the person that saw your post has Graffle-fu that is insufficient to provide an answer.

That said, if you send email to our support ninjas, you're guaranteed an answer from someone who'll know more than I do. Hope that still helps. :-)
 
Here's a little script that will prompt for a key name and value and add them to the user data of every object in your document. Then you can put things like

Code:
Document prepared for <%userdata ClientName%>
in your document, and update them whenever needed by simply running the script again. Note: user data keys cannot have spaces in them, so "Client Name" won't work, but "ClientName" will.

Thanks to RobTrew for showing the way to someone so unwilling to actually sit down and learn Applescript properly :-)

Code:
tell application id "OGfl"
	set MykeyName to my PromptKeyInfo("Name of key to create/set", "MyKey", false)
	set MydataVal to my PromptKeyInfo("Value of data to set", "<None>", true)
	
	
	set MyScript to "
tell application id \"OGfl\"
	repeat with aCanvas in every canvas of document of front window
		set canvas of front window to aCanvas
		
		repeat with aGraphic in every graphic of aCanvas
			if (count of user data of aGraphic is not 0) then
			    set user data of aGraphic to {" & MykeyName & ":\"" & MydataVal & "\"} & user data of aGraphic
			else
			    set user data of aGraphic to {" & MykeyName & ":\"" & MydataVal & "\"}
			end if
		end repeat
	end repeat
end tell
"
	
	run script MyScript
end tell

on PromptKeyInfo(Prompt, DefaultAnswer, SpacesAllowed)
	set Successful to false
	repeat while (Successful is not true)
		set recReturned to display dialog Prompt default answer DefaultAnswer buttons {"OK", "Cancel"} default button {"OK"}
		set retVal to (text returned of recReturned)
		set Successful to true
		if (not SpacesAllowed) then
			set tid to AppleScript's text item delimiters
			set AppleScript's text item delimiters to " "
			set wordCount to count of every text item of retVal
			if (wordCount is not 1) then
				display dialog "Key names may not contain spaces"
				set Successful to false
			end if
		end if
	end repeat
	return retVal
end PromptKeyInfo
Attached Files
File Type: zip Populate user data.zip (3.8 KB, 229 views)
 
There is a simple way to store something that applies to the whole document.

In the same way that you can add a user data key for an object you can do so for the drawing canvas itself. Click on the canvas background and add, say a key called 'approvedBy' and enter a value.

All you then need to do is in any graphic shape that needs the value you enter the string:

Code:
<%UserData approvedBy%>
It really is that simple. It also works for the standard keys for each document by using a slightly different form:

Code:
<%Authors%>, <%Organizations%>, <%CreationDate%>
to give:

 
Quote:
Originally Posted by trouble clef View Post
There is a simple way to store something that applies to the whole document.

In the same way that you can add a user data key for an object you can do so for the drawing canvas itself. Click on the canvas background and add, say a key called 'approvedBy' and enter a value.

All you then need to do is in any graphic shape that needs the value you enter the string:

Code:
<%UserData approvedBy%>
It really is that simple. It also works for the standard keys for each document by using a slightly different form:

Code:
<%Authors%>, <%Organizations%>, <%CreationDate%>
to give:
Actually, this doesn't work.

https://img.skitch.com/20111108-fxb5...4ykbd772iy.png
 
There's a very helpful post by john.gersh on approaches to this problem.

A Help > Send Feedback request for the extension of user data items from shapes, lines and subgraphs to layers, canvases and documents might also be worth a try.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Defining new root level michaelaye OmniPlan General 2 2012-01-25 11:17 AM
Defining OmniFocus sub-contexts for computer-based work RobTrew OmniFocus 1 for Mac 0 2010-12-29 08:21 AM
Defining the right perspective madnil OmniFocus 1 for Mac 2 2010-12-12 11:41 AM
Defining Review intervals by Folder garoda OmniFocus 1 for Mac 4 2010-11-06 07:21 PM
Defining Custom Colors gvegastiger OmniGraffle General 2 2010-05-02 12:37 PM


All times are GMT -8. The time now is 07:20 PM.


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