I try adding selected text frame to existing assignment
I can get properties of assigned story in manually created assignment with simple script:
tell application "Adobe InDesign CS4"
tell document 1
tell assignment "sample"
get properties of every assigned story
end tell
end tell
end tell
InDesign AS Dictionary said: Acces to assigned story (as elements of assignment) is: get (OK, this work), make and delete.
Ok. But when I call (document is saved):
make new assigned story with properties {story reference:story id 5812 of document "02.indd" of application "Adobe InDesign CS4", parent:assignment id 7985 of document "02.indd" of application "Adobe InDesign CS4", file path:"Macintosh HD:Users:aaa:Desktop:Assigments studies:02.icml", name:"02.icml", label:"sample"}
I have been stuck with the same problem, but now found a solution with the help from a friend.
Two and a half years later it might not help the original forum poster. But if anyone else have the same problem, here is the solution:
You can’t just make a new assigned story from nothing. You have to do it like this:
Export the story as an Incopy markup file. When doing that, the story will automatically be added to “Unassigned InCopy Content” (the name of this is language dependent, take a look in the assignment panel)
Then move the assigned story to the assignment where you want to have it.
Example code:
-- Prerequisite for this demonstration: An open and saved Indesign document containing one (unassigned) text frame
tell application "Adobe InDesign CS5.5"
activate
tell document 1
save
-- Define variables:
set theStory to parent story of text frame 1
set docFileParent to file path as string
set assignmentName to "newAssigment"
set assignmentPath to docFileParent & assignmentName & ".icma"
set icmlName to "assignedStory.icml"
set icmlPath to docFileParent & icmlName
-- Create the assignment, if not already created:
try
set newAssignment to assignment assignmentName
on error
set newAssignment to (make new assignment with properties {name:assignmentName, file path:assignmentPath})
save
end try
-- Export the story:
tell theStory to export format InCopy markup to icmlPath
-- Move the assigned story:
-- NOTE: The name "Unassigned InCopy Content" is language dependent. Replace it with the name in your language version if not english “ see Assignments panel.
tell assignment "Unassigned InCopy Content" to move last assigned story to newAssignment
tell newAssignment to update
save
end tell
end tell
Besides: It’s a sad thing that Adobe doesn’t mention this in its documentation.
It isn’t obvious is it?