Re: Bulk replacement of text from spreadsheet or text file
Mark Barclay <[email protected]>
| Newsgroups | gmane.comp.graphics.omnigraffle.user |
|---|---|
| Message-ID | <C58A187D.1251%[email protected]> |
Thanks so much, Wim. Those are great suggestions! I especially like the DOT
import idea - that opens up a lot of possibilities for getting some
hierarchical formatting almost for free.
Now for some of my more programmatic needs in the near term (for example: I
plan on parsing arbitrary data and populating an OG doc based on the data),
since I know Python pretty well and like it very much (but have not used it
on the Mac), I think I'll try the Python way. I have XCode installed and
have looked briefly at its Python support. So...
Can anyone please point me to some python sample code that connects through
AppleScript, to a running instance of OmniGraffle, and creates a rectangle
with the word "foo" as it's text? In fact any sample code at all that talks
to OG would be a great starting point - I'm sure I could figure out the
specifics of creating objects easily from there.
I'm just looking for something in the flavor of...
(note: this is a fictitious API, just to show the kind level at which I
expect to be dealing with things)
from omnigraffle import attach
og = attach('OmniGraffle')
c = og.getCanvas()
r = c.add_rect(20,20,400,400)
r.setText('foo')
...
Or more likely it would be importing an AppleScript interface module and
attaching through that, but you can see where I'm going with this.
Thanks in advance.
P.S. -- OG rocks!
On 1/6/09 6:24 PM, "Wim Lewis" <[email protected]> wrote:
>
> On Jan 5, 2009, at 8:30 PM, Mark Barclay wrote:
>> Does anyone know of a somewhat automated way to create a bunch of
>> text objects in OmniGraffle with text from cells in an Excel
>> spreadsheet (or from a text file, if that is easier)? By automated,
>> I only mean I don¹t want to re-type each item in manually not kcopy
>> and paste each one separately. e.g. I might like to have 64
>> contiguous cells in a spreadsheet have their text used to replace
>> the text in 64 selected items in an OmniGraffle drawing.
>
> OmniOutliner can import from a number of spreadsheet formats, and
> OmniGraffle can import OmniOutliner documents --- so that would be one
> way to import a bunch of spreadsheet rows into an OmniGraffle document.
>
> Alternatively, if the text file's format is simple enough to parse
> with AppleScript, you could write a script which reads items and
> creates graphics in whatever style you want. The most complex, but
> most powerful, approach is probably to parse the data file using
> Python or Perl and use Appscript (an applescript-compatible
> AppleEvents module) to send the information to OmniGraffle.
>
> Another fairly effective way to get outside data into OmniGraffle is
> to convert it into graphviz DOT format, which is a pretty simple text
> format, and import it into OmniGraffle. (OG doesn't support the
> entirely of the DOT language, just the basic stuff.)
>
Mark Barclay
Mishawaka, Indiana
[email protected]