The Omni Group Forums

The Omni Group Forums (http://forums.omnigroup.com/index.php)
-   OmniGraffle General (http://forums.omnigroup.com/forumdisplay.php?f=10)
-   -   How can I extract Omnigraffle's object attributes to CSS? (http://forums.omnigroup.com/showthread.php?t=23737)

mupinkz 2012-03-19 03:27 AM

How can I extract Omnigraffle's object attributes to CSS?
 
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?

RobTrew 2012-03-19 03:50 AM

The Applescript interface should expose all of the properties you need.

whpalmer4 2012-03-19 09:06 AM

[QUOTE=RobTrew;108539]The Applescript interface should expose all of the properties you need.[/QUOTE]

The rest is left as an exercise for the reader :-)

RobTrew 2012-03-19 11:49 AM

:-)

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 ...

whpalmer4 2012-03-19 12:04 PM

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...

mupinkz 2012-03-19 09:30 PM

Sample Mockup File
Its exceeds the forum's limit

please download here
[URL="http://www.mediafire.com/?4hnuq3i2cuu928r:"]MediaFire[/URL]

RobTrew 2012-03-19 10:45 PM

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
[/CODE]

RobTrew 2012-03-19 10:49 PM

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 ...

mupinkz 2012-03-19 11:42 PM

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?

RobTrew 2012-03-20 01:45 AM

[QUOTE=mupinkz;108587]
about applescript
is that mean it work for 1 object?
i can't convert the element (table, combobox) that come from many objects ,right?[/QUOTE]

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.


All times are GMT -8. The time now is 03:55 PM.

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