5 Replies Latest reply on Aug 31, 2011 7:53 AM by John Hawkinson

    Adding selection to assignment via AppleScript?

      When I try add story to assignment, I have error: "Cant make class assigned story"

      This is my code: "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"}

      Document was saved.

      Please, help...
        • 1. Re: Adding selection to assignment via AppleScript?
          sstanleyau Level 4
          Where were you trying to make it? I've never scripted assigned stories, but<br />it looks like you have to make them at an assignment.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Sessions <a href=http://scriptingmatters.com/aspro>
          • 2. Re: Adding selection to assignment via AppleScript?
            Level 1
            I want group set of text boxes in short article on current page (i.e. title, subtitle i text box) in one assignment by script.
            The first step of my script (OK, its work) identifies the boxes by script labels, and select it. As result of this portion of script, I have 3 selected boxes. OK.

            Manually, create assignment of this is simple menu Edit, and InCopy, and Add to assignment, then New...

            But, how create assignment with my selected boxes by Apple script? Or, how add selected boxes to existing assignment?

            I apologize for my English, of course :)
            • 3. Re: Adding selection to assignment via AppleScript?
              Jostify

              I have been stuck with the same problem, but now found a solution with the help from a friend.

              So if anyone 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:

              1. 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")

              2. 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 – ee Assignments panel.

              tell assignment "Unassigned InCopy Content" to move last assigned story to newAssignment

              tell newAssignment to update

               

               

              save

              end tell

              end tell

               

               

               

              • 4. Re: Adding selection to assignment via AppleScript?
                Jostify Level 1

                Besides: It's a sad thing that Adobe doesn't mention this in its documentation.

                It isn't obvious is it?

                • 5. Re: Adding selection to assignment via AppleScript?
                  John Hawkinson Level 5
                  -- 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 – ee Assignments panel.

                  In JavaScript, you would call app.translateKeyString("$ID/UnassignedInCopy") to return the string in the current locale. Though there is also a key "$ID/Unassigned InCopy Content" which might conceivably be the right one (but I don't think so). Check for the AS equivalent...