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 Extras
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
Calendar Thread Tools Search this Thread Display Modes
Hi there!

Is there a plugin or any other possibility, to create an calendar in OmniGraffle?
I mean to get all Dates automatically and maybe a layout structure ... it's a lot of work to do everything "by hand".
 
You could try running "cal" in the terminal, which will give you the calendar of the current month. "cal 7 2006" will give you next month's calendar. Just copy and paste into OG.
 
That's a nice workaround :-)
But I'm missing a calendar functionallity like magic draw has it.
But I guess it's hard to satisfy every special need ..
 
my workaround solution for this need is to use iCal to display a blank (I had to first uncheck all my calendars) month view (though this could be done in any other view as well), and "Print" to a PDF. Then I simply open the PDF in OmniGraffle and have a nicely formatted calendar to work with as a base for my diagrams/charts/what have you.

Cheers!

Luke
 
Copy and paste the code below into Script Editor, compile and save as application. You will likely want to modify the code to suit your needs but I declare it public domain so have at it.


(* Written by T.K.Egan
* 12 Feb 2007
* inspired by need and http://forums.omnigroup.com/
*
* updated by T.K.Egan
* 14 Feb 2007
* added headers and "editing cells"
*
* requires bsd subsystem and Omnigraffle to be installed
*)

-- preferences (you might edit these...)
property kHorizontalPadding : 10
property kVerticalPadding : 10
property kTitleTextSize : 24
property kHeaderTextSize : 18
property kNormalTextSize : 12
property kUseShortDayNames : true


-- constant data... With so much built in to Applescript these seem like odd omissions
set kMonths to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
set kFullDayNames to {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
set kShortDayNames to {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"}

-- program body begins... Editing the below will almost certainely change the program's behavior
if kUseShortDayNames then
set myDays to kShortDayNames
else
set myDays to kFullDayNames
end if
display dialog "What year is this calendar for:" default answer (year of (current date))
set myYear to text returned of result
set myMonth to (choose from list kMonths with prompt "Now choose the month:" without empty selection allowed and multiple selections allowed)
set myDocumentName to myMonth & " " & myYear as string
set myArgs to (listIndex(myMonth, kMonths) as string) & " " & myYear
set myCalendar to (do shell script "cal " & myArgs)
set AppleScript's text item delimiters to ASCII character 13
set myLines to every text item of myCalendar
set AppleScript's text item delimiters to "" -- always restore delimiters
--first two lines are trash the third line has the day numbers
set myInterestingLine to item 3 of myLines
set myLeadingDayBoxWidthMultiplier to countLeadingSpaces(myInterestingLine) div 3
-- the last line is blank, the next to last line has the last date
set myInterestingLine to item -2 of myLines
set myLastDay to ((characters (length of myInterestingLine) through -2 of myInterestingLine) as string) as number
set myTrailingDayBoxWidthMultiplier to 7 - ((myLeadingDayBoxWidthMultiplier + myLastDay) mod 7)
tell application "OmniGraffle"
activate
make new document with properties {name:myDocumentName}
end tell

set myDayCounter to 0
set myVerticalCursor to kVerticalPadding
set myHeaderCellHeight to kNormalTextSize * 1.5
tell document myDocumentName of application "OmniGraffle"
set myCanvasSize to canvasSize of first canvas
end tell
set myFullWidth to (first item of myCanvasSize as number) - 2 * kHorizontalPadding
set myCalendarDayBoxWidth to myFullWidth div 7
set myCalendarDayBoxHeight to ((second item of myCanvasSize as number) - (2 * kVerticalPadding + myHeaderCellHeight + kTitleTextSize * 1.5)) div ((count myLines) - 3) -- first two and final lines are bogus
tell document myDocumentName of application "OmniGraffle"
--make header
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding, myVerticalCursor}, size:{myFullWidth, kTitleTextSize * 1.5}, draws shadow:false, draws stroke:false, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{size:kTitleTextSize, alignment:center, text:myDocumentName}}
set myVerticalCursor to myVerticalCursor + kTitleTextSize * 1.5
repeat with theDay in myDays
make new shape at end of graphics of first canvas with properties {origin:{myDayCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth, myHeaderCellHeight}, draws shadow:false, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{size:kHeaderTextSize, alignment:center, text:theDay}}
set myDayCounter to myDayCounter + 1
end repeat
set myVerticalCursor to myVerticalCursor + myHeaderCellHeight
-- make leader
if myLeadingDayBoxWidthMultiplier is greater than 0 then
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth * myLeadingDayBoxWidthMultiplier, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{size:kNormalTextSize}}
end if
set myDayCounter to 0
set myDayOfWeekCounter to myLeadingDayBoxWidthMultiplier
-- make normal calendar day boxes
repeat while myDayCounter is less than myLastDay
repeat while myDayOfWeekCounter is less than 7 and myDayCounter is less than myLastDay
--make a calendar day box
make new shape at end of graphics of first canvas with properties {origin:{myDayOfWeekCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor + kHeaderTextSize + 1}, size:{myCalendarDayBoxWidth, myCalendarDayBoxHeight - (kHeaderTextSize + 1)}, draws shadow:false, name:"Rectangle", text placement:top, fill color:{65535, 65535, 65535}, text:{size:kNormalTextSize, alignment:left}}
make new shape at end of graphics of first canvas with properties {origin:{myDayOfWeekCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", text placement:top, fill color:{65535, 65535, 65535}, text:{size:kHeaderTextSize, alignment:right, text:myDayCounter + 1 as string}}
set myDayCounter to myDayCounter + 1
set myDayOfWeekCounter to myDayOfWeekCounter + 1
end repeat
set myDayOfWeekCounter to 0
set myVerticalCursor to myVerticalCursor + myCalendarDayBoxHeight
end repeat
-- make trailing box
if myTrailingDayBoxWidthMultiplier is greater than 0 then
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding + (7 - myTrailingDayBoxWidthMultiplier) * myCalendarDayBoxWidth, myVerticalCursor - myCalendarDayBoxHeight}, size:{myCalendarDayBoxWidth * myTrailingDayBoxWidthMultiplier, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{size:kNormalTextSize}}
end if
end tell

on listIndex(theItem, theList)
repeat with i from 1 to the count of theList
if item i of theList as string = theItem as string then return i
end repeat
return -1
end listIndex

on countLeadingSpaces(theLine)
set myCounter to 1
set myOldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ""
set myLineAsCharList to every text item of theLine
set AppleScript's text item delimiters to myOldDelimiters
repeat while item myCounter of myLineAsCharList is " "
set myCounter to myCounter + 1
end repeat
return myCounter - 1
end countLeadingSpaces

Last edited by T.K.Egan; 2007-02-14 at 07:25 PM.. Reason: Updated Source with Headers and More
 
T.K.,

I tried out your script. Really really nice. Thank you for the effort!

Cheers,

Tom
 
Thanks!

Note if you are using Omnigraffle Professional like me I found I had to change the tell statements to tell "Omnigraffle Professional" rather than "Omnigraffle"

Dan
 
I've got the script to work fine, but I don't really know how to use AppleScripting.

Here's 2 things I'd like to change in the script:

1. The page orientation is landscape (and so all the parameters fit best on
this type of page).

2. Setting default font/size for various sections of the calendar.

Any hints on what specifically I change in the wonderful script provided? Of the two, the most time consuming fix is setting for landscape mode as this realistically changes probably some font size settings and so on.
 
2. The font sizes are set in the "preferences" at the top of the script:

Code:
property kTitleTextSize : 24
property kHeaderTextSize : 18
property kNormalTextSize : 12
To change the font used in the cells, add font:"your font name here", to the text:{} syntax, throughout the script. E.g.
Code:
text:{font:"Gill Sans", size:kHeaderTextSize, alignment:right, text:myDayCounter + 1 as string}

Last edited by JKT; 2007-02-24 at 03:43 PM..
 
E.g. in this version, I have changed the font of the title to Trebuchet MS, the day names and numbers to Gill Sans, and added some shading to the boxes:

(* Written by T.K.Egan
* 12 Feb 2007
* inspired by need and http://forums.omnigroup.com/
*
* updated by T.K.Egan
* 14 Feb 2007
* added headers and "editing cells"
*
* requires bsd subsystem and OmniGraffle Professional to be installed
*)

-- preferences (you might edit these...)
property kHorizontalPadding : 10
property kVerticalPadding : 10
property kTitleTextSize : 24
property kHeaderTextSize : 18
property kNormalTextSize : 12
property kUseShortDayNames : true


-- constant data... With so much built in to Applescript these seem like odd omissions
set kMonths to {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}
set kFullDayNames to {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
set kShortDayNames to {"Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"}

-- program body begins... Editing the below will almost certainely change the program's behavior
if kUseShortDayNames then
set myDays to kShortDayNames
else
set myDays to kFullDayNames
end if
display dialog "What year is this calendar for:" default answer (year of (current date))
set myYear to text returned of result
set myMonth to (choose from list kMonths with prompt "Now choose the month:" without empty selection allowed and multiple selections allowed)
set myDocumentName to myMonth & " " & myYear as string
set myArgs to (listIndex(myMonth, kMonths) as string) & " " & myYear
set myCalendar to (do shell script "cal " & myArgs)
set AppleScript's text item delimiters to ASCII character 13
set myLines to every text item of myCalendar
set AppleScript's text item delimiters to "" -- always restore delimiters
--first two lines are trash the third line has the day numbers
set myInterestingLine to item 3 of myLines
set myLeadingDayBoxWidthMultiplier to countLeadingSpaces(myInterestingLine) div 3
-- the last line is blank, the next to last line has the last date
set myInterestingLine to item -2 of myLines
set myLastDay to ((characters (length of myInterestingLine) through -2 of myInterestingLine) as string) as number
set myTrailingDayBoxWidthMultiplier to 7 - ((myLeadingDayBoxWidthMultiplier + myLastDay) mod 7)
tell application "OmniGraffle Professional"
activate
make new document with properties {name:myDocumentName}
end tell

set myDayCounter to 0
set myVerticalCursor to kVerticalPadding
set myHeaderCellHeight to kNormalTextSize * 1.5
tell document myDocumentName of application "OmniGraffle Professional"
set myCanvasSize to canvasSize of first canvas
end tell
set myFullWidth to (first item of myCanvasSize as number) - 2 * kHorizontalPadding
set myCalendarDayBoxWidth to myFullWidth div 7
set myCalendarDayBoxHeight to ((second item of myCanvasSize as number) - (2 * kVerticalPadding + myHeaderCellHeight + kTitleTextSize * 1.5)) div ((count myLines) - 3) -- first two and final lines are bogus
tell document myDocumentName of application "OmniGraffle Professional"
--make header
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding, myVerticalCursor}, size:{myFullWidth, kTitleTextSize * 1.5}, draws shadow:false, draws stroke:false, name:"Rectangle", fill color:{65535, 65535, 65535}, text:{font:"Trebuchet MS", size:kTitleTextSize, alignment:center, text:myDocumentName}}
set myVerticalCursor to myVerticalCursor + kTitleTextSize * 1.5
repeat with theDay in myDays
make new shape at end of graphics of first canvas with properties {origin:{myDayCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth, myHeaderCellHeight}, draws shadow:false, name:"Rectangle", fill color:{55535, 55535, 55535}, text:{font:"Gill Sans", size:kHeaderTextSize, alignment:center, text:theDay}}
set myDayCounter to myDayCounter + 1
end repeat
set myVerticalCursor to myVerticalCursor + myHeaderCellHeight
-- make leader
if myLeadingDayBoxWidthMultiplier is greater than 0 then
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth * myLeadingDayBoxWidthMultiplier, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", fill color:{50000, 50000, 50000}, text:{font:"Gill Sans", size:kNormalTextSize}}
end if
set myDayCounter to 0
set myDayOfWeekCounter to myLeadingDayBoxWidthMultiplier
-- make normal calendar day boxes
repeat while myDayCounter is less than myLastDay
repeat while myDayOfWeekCounter is less than 7 and myDayCounter is less than myLastDay
--make a calendar day box
make new shape at end of graphics of first canvas with properties {origin:{myDayOfWeekCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor + kHeaderTextSize + 1}, size:{myCalendarDayBoxWidth, myCalendarDayBoxHeight - (kHeaderTextSize + 1)}, draws shadow:false, name:"Rectangle", text placement:top, fill color:{60000, 60000, 60000}, text:{font:"Gill Sans", size:kNormalTextSize, alignment:left}}
make new shape at end of graphics of first canvas with properties {origin:{myDayOfWeekCounter * myCalendarDayBoxWidth + kHorizontalPadding, myVerticalCursor}, size:{myCalendarDayBoxWidth, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", text placement:top, fill color:{65535, 65535, 65535}, text:{font:"Gill Sans", size:kHeaderTextSize, alignment:right, text:myDayCounter + 1 as string}}
set myDayCounter to myDayCounter + 1
set myDayOfWeekCounter to myDayOfWeekCounter + 1
end repeat
set myDayOfWeekCounter to 0
set myVerticalCursor to myVerticalCursor + myCalendarDayBoxHeight
end repeat
-- make trailing box
if myTrailingDayBoxWidthMultiplier is greater than 0 then
make new shape at end of graphics of first canvas with properties {origin:{kHorizontalPadding + (7 - myTrailingDayBoxWidthMultiplier) * myCalendarDayBoxWidth, myVerticalCursor - myCalendarDayBoxHeight}, size:{myCalendarDayBoxWidth * myTrailingDayBoxWidthMultiplier, myCalendarDayBoxHeight}, draws shadow:false, name:"Rectangle", fill color:{50000, 50000, 50000}, text:{font:"Gill Sans", size:kNormalTextSize}}
end if
end tell

on listIndex(theItem, theList)
repeat with i from 1 to the count of theList
if item i of theList as string = theItem as string then return i
end repeat
return -1
end listIndex

on countLeadingSpaces(theLine)
set myCounter to 1
set myOldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to ""
set myLineAsCharList to every text item of theLine
set AppleScript's text item delimiters to myOldDelimiters
repeat while item myCounter of myLineAsCharList is " "
set myCounter to myCounter + 1
end repeat
return myCounter - 1
end countLeadingSpaces

Last edited by JKT; 2007-02-24 at 04:03 PM..
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't find my calendar in the preference list [A: sync to a local calendar.] roblevin12 iCal Sync 42 2012-07-13 03:47 AM
New calendar view and calendar syncing question psidnell OmniFocus for iPad 1 2011-05-18 07:18 AM
Sync tasks with due-dates to iCal-calendar? [See "Replacing Calendar Sync" thread.] tkaufmann iCal Sync 34 2011-02-10 03:25 PM
Bug with calendar? villageboy OmniFocus 1 for Mac 1 2008-02-26 12:35 PM
Calendar...??? duotone OmniOutliner 3 for Mac 0 2008-02-26 04:41 AM


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


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