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

 
How can I extract Omnigraffle's object attributes to CSS? Thread Tools Search this Thread Display Modes
I'm UI designer and I have a bunch of omnigraffle's mockup files.
I would like to extract some information such as page/object dimension, background color, size etc. Basically, I want to obtain this information in order to convert to CSS. I'm wondering if anyone has ever done this before.

Do you have any suggestion how I can extract Omnigraffle's object attributes?
 
The Applescript interface should expose all of the properties you need.
 
Quote:
Originally Posted by RobTrew View Post
The Applescript interface should expose all of the properties you need.
The rest is left as an exercise for the reader :-)
 
:-)

but if you are unfamiliar with Applescript want to give an example of what you're doing, I'm sure that one of us could sketch some lines of illustrative code ...
 
Post an example mockup file and hoped-for output, and the likelihood of the Applescript Fairy bringing you something that will help you get started cannot help but increase...
 
Sample Mockup File
Its exceeds the forum's limit

please download here
MediaFire
 
An important limitation of the OmniGraffle scripting interface is that it doesn't know how to look inside groups, and doesn't know how to temporarily disassemble them either, so I think you would have to manually ungroup all your groups before your could read the properties of their components with Applescript.

Having done this, the following snippet illustrates some elements of how you might assemble a text listing of some of the properties of the shapes on a canvas, and place that listing in the clipboard.

Code:
-- Simple illustration of generating a text which lists 
-- some of the properties of the shapes on an OmniGraffle canvas

on run
	set {dlm, my text item delimiters} to {my text item delimiters, tab}
	set strReport to ""
	
	tell application id "OGfl"
		tell canvas of front window
			repeat with oShape in (shapes where its text ≠ "")
				tell oShape
					set {strFont, rSize, lstColor, eAligned} to 
						{font, size, color, alignment} of ((properties of its text) as record)
					set strReport to ((strReport & "
Text:" & tab & "\"" & its text & "\"  
Posn:" & tab & origin as text) & "
Dimensions:" & tab & size as text) & "
Font:" & tab & strFont & "
Size:" & tab & rSize & "
Color:" & tab & lstColor & "
Alignment:" & tab & eAligned & "
"
				end tell
			end repeat
		end tell
	end tell
	
	set my text item delimiters to dlm
	
	set the clipboard to strReport
	return strReport
end run

Last edited by RobTrew; 2012-03-20 at 04:38 AM.. Reason: adjusted code for simplicity
 
A completely different approach might be to gunzip the .graffle file, read its XML text directly, and transform it with XSLT, or simply mine it with a scripting language like Perl or Python. This would obviously bypass the problem of manual ungrouping ...
 
wowww.... thank you very much.

about applescript
is that mean it work for 1 object?
i can't convert the element (table, combobox) that come from many objects ,right?

Last edited by mupinkz; 2012-03-20 at 12:10 AM..
 
Quote:
Originally Posted by mupinkz View Post
about applescript
is that mean it work for 1 object?
i can't convert the element (table, combobox) that come from many objects ,right?
That's right - you can get some basic properties of groups (position, size, incoming and outgoing lines, etc), but Omnigraffle can only give you full details (text and color properties etc) for the component objects.
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Object Resizing - Scaling Attributes mpsalisbury OmniGraffle General 4 2013-04-30 11:33 AM
What use, exactly, does OmniGraffle's PSD export serve? Audacitor OmniGraffle General 5 2013-04-05 08:19 PM
Extract Data?? msalzberg OmniGraffle General 0 2008-03-20 10:08 PM
Export or Extract All Data dhm2006 OmniFocus 1 for Mac 6 2007-11-22 03:34 AM
Unable to find extract script PatriciaW OmniFocus 1 for Mac 4 2007-10-23 02:37 PM


All times are GMT -8. The time now is 01:38 AM.


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