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

 
Am I using Applescript's "duplicate" wrong? Thread Tools Search this Thread Display Modes
I'm trying to duplicate an object from one Omnigraffle document into another. I can get it to duplicate and place the copy in the same spot, but when I try to place the copy in a different file, I get an error: "OmniGraffle 5 got an error: Can’t make or move that element into that container."

The script is below. Any suggestions would be greatly appreciated.

Code:
set myDocument to "[the pathname of my file]"

tell application "OmniGraffle 5"
	set oDoc to open myDocument
	set canvasCount to count of canvases of oDoc
	
	set allGroups to {}
	repeat with theCanvas in every canvas of the first document
		repeat with theLayer in every layer in theCanvas
			set allGroups to allGroups & every group in theLayer
		end repeat
	end repeat
	
	set groupcount to length of allGroups
	
	set allDocNames to {}
	
	repeat with currentGroup in allGroups
		set currentID to id of currentGroup
		set currentName to "test" & currentID & ".graffle"
		set allDocNames to allDocNames & currentName
		set preNewDoc to (make new document at end of documents with properties {name:currentName})
		save the front window
		set newDoc to the front window
		
		duplicate currentGroup to newDoc -- causes error!
		
		(*
		in new document, select all
		ungroup
		keep list of origins
		export as psd
		in illustrator
		import each component to the location specified by its origins
		*)
		
	end repeat
end tell
 
Quote:
Originally Posted by Daria View Post
when I try to place the copy in a different file, I get an error: "OmniGraffle 5 got an error: Can’t make or move that element into that container."


set preNewDoc to (make new document at end of documents with properties {name:currentName})
save the front window
set newDoc to the front window

duplicate currentGroup to newDoc -- causes error!
Hi Daria-

I didn't try your script, but doesn't "make" return a reference to a DOCUMENT, but you need a reference to a CANVAS to contain the graphic group?

Best, Charles
 
Charles,

You're right. Thanks for helping me!

- Daria
 
Glad I could. Have fun!

Charles
 
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
"Jump to specific canvas" action wrong in exported PDF? [A: Bug, fixed in 5.4.1] Georgy OmniGraffle General 4 2012-07-31 03:44 PM
Varying "Duplicate Canvas" behaviors. dekdekdek OmniGraffle General 4 2010-10-26 07:34 AM
Weird dates... "today" is wrong date --> 2059, 2084 etc.! electroglodyte OmniFocus 1 for Mac 0 2009-11-03 09:39 AM
"No context" has completely wrong count jasong OmniFocus 1 for Mac 4 2007-11-23 08:27 PM


All times are GMT -8. The time now is 11:48 PM.


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