1 2 Previous Next 42 Replies Latest reply on Apr 27, 2016 2:28 AM by Laubender

    Auto adding text frame besides a circle shape placed usingc content placer tool

    henum87248073

      Hello to all...

       

      This is my first question in this forum.... to which I am looking for a solution

       

      I need to create a document with 500 dots and I need to number them all starting from 1 like showing in the image below.

       

       

      Now what i want is there any script possible so that as soon as i add a circle shape a new text frame automatically created beside the shape with the number one or with a number that i add in the script. For this i am suppose to use the content placer tool to place circle in the document.

       

      As of now I am adding numbers manually and this is taking a lot of time...

       

      If there is any simple script possible please help me... as it will save my lots of time...

       

      thanx,,,

        • 1. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
          henum87248073 Level 1

          Between I also want that these text frames can also be linked as threaded, so that if i delete a dot and a number..... all these number automatically adjusts accordingly.

           

           

           

          Thanx...

          • 2. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
            Laubender Adobe Community Professional & MVP

            Hi henum,

            would it help, if you would simply duplicate a selected text frame ( ALT+drag on Mac OSX ), that is holding:

             

            1. A paragraph with a numbered list plus a paragraph return character

            2. Start paragraph options: Next Frame

            2. A dot anchored to the paragraph

             

            And running a script that is threading the duplicate to the story of the text frame you duplicated?

             

            1. A couple of text frames threaded.

             

            You already duplicated text frame 3 and want to thread it between frame 3 and frame 4.
            The duplicate is currently showing the number 1.

             

            1-AddTextFrameToStory-Scenario.png


            The duplicate is selected, currently showing number 1, because the list cannot continue over different stories.

             

            2-AddTextFrameToStory-DuplicateSelected.png


            2. Select frame 3 by holding the SHIFT key to add it to your selection as the second item.

            3-AddTextFrameToStory-Duplicate-plus-TextFrame-Selected.png

             

            3. Run the ExtendScript script below to add the duplicate to the story:

             

            // addTextFrameToStory_2FramesSelected.jsx
            // Uwe Laubender
            
            /**
            * @@@BUILDINFO@@@ addTextFrameToStory_2FramesSelected.jsx !Version! Mon Apr 25 2016 09:10:46 GMT+0200
            */
            
            
            app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
            
            app.doScript
                (
                
                addTextFrameToStory, 
                ScriptLanguage.JAVASCRIPT, 
                [],
                UndoModes.ENTIRE_SCRIPT, 
                "Add Text Frame to Story | SCRIPT"
                
                );
            
            function addTextFrameToStory()
            {
                
                if(doSomeChecks() === false){return};
                
                var tf1 = app.selection[1];
                var tf2 = app.selection[0];
                
                tf1.nextTextFrame = tf2;
                
                function doSomeChecks()
                {
                    if(app.documents.length == 0){return false};
                    if(app.selection.length !== 2){return false};
                    if(app.selection[0].constructor.name !== "TextFrame"){return false};
                    if(app.selection[1].constructor.name !== "TextFrame"){return false};
                    return true;
                }
                
            }
            

             

            4. Result:

            4-AddTextFrameToStory-ResultAfterScript.png

             

            Hope that helps,

            Uwe

            • 3. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
              henum87248073 Level 1

               

               

               

              Content placer box

               

               

               

              • 4. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                Laubender Adobe Community Professional & MVP

                Why do you have to use the Content Placer tool, if it's much easier to duplicate a prepared text frame with a dot anchored?
                Do you have several colored dots that should go into one numbering scheme? I'll have to see the bigger picture what you like to accomplish here…

                 

                Instead of the Content Placer tool you could use an InDesign Library (not the CC Library) to store several versions of a text frame with an anchored dot and place them from the library. However duplicating with the mouse is easier.

                 

                A script that is reacting to an AFTER_PLACE event is much more complex to write.
                And one would have to identify the right text frame in the story on the page to link to (geometrical the next one?) automatically.

                 

                Uwe

                • 5. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                  henum87248073 Level 1

                  Uwe ,  actually we are creating a dot-to-dot book in which there are specific location where I need to place the dots over the image and then need to number them. This is why i need to place the dots first and then the specific number corresponding  to the design like the one attached...

                   

                  For this I have first placed all the dots and then run the script I have found over the internet (added it in the last) to place the first ab text around all the dots and then modifying the text to numbers i need accordingly. Though the script i am adding here have slight modification as it was originally created to add the size of the shape box besides the dots instead of ab characters.

                   

                   

                  //

                  // SizeLabels.jsx

                  //

                  // Version 0.0.4

                  //

                  // (C) 2012 Rorohiko Ltd.

                  // All rights reserved.

                  // By Kris Coppieters

                  // kris@rorohiko.com

                  //

                  //

                  // Installing:

                  //

                  // Unzip this .zip and move the .jsx file into your Scripts Panel folder inside your

                  // Scripts folder inside your InDesign application folder.

                  //

                  // For more info see:

                  //

                  // http://indesignsecrets.com/how-to-install-scripts-in-indesign.php

                  //

                  // How it works:

                  //

                  // This script adds printing info labels to every frame. The labels are on a separate layer

                  // named "SizeLabels" so all of these added labels can be deleted again by simply deleting

                  // the layer.

                  //

                  // If you move or resize items, simply re-run the script to update the labels.

                  //

                  // Before (re)running the script, you can define a paragraph style "SizeLabelStyle".

                  // This style will be applied to all the contents of the labels.

                  //

                  // Before (re)running the script, you can define an object style "SizeLabelObjectStyle".

                  // This object style will be applied to all label frames - so if you want a specific background

                  // fill or frame, do it via this object style.

                  //

                  // You can change the units of the size labels. I've set it to inches. Change the line below that has

                  // kUnitToUse - you can use:

                  // MeasurementUnits.CENTIMETERS

                  // MeasurementUnits.CICERO

                  // MeasurementUnits.INCHES

                  // MeasurementUnits.MILLIMETERS

                  // MeasurementUnits.PICAS

                  // MeasurementUnits.PIXELS

                  // MeasurementUnits.POINTS

                  //

                  // By default the script will not attempt to label 'nested' frames. If you want to also label

                  // nested frames (e.g. inline frames, anchored frames, frames pasted into frames,...) change the line

                  // below to read:

                  // kLabelNestedItems = 1

                  //

                  // If you want a specific frame to remain unlabeled, you can use the Script Label palette to

                  // assign a script label "ignore" to this frame. The script will then not label this frame until

                  // the script label is removed again.

                  //

                  // Change the lines with kDontLabelImageFrames, kDontLabelTextFrames, kDontLabelOtherFrames

                  // below if you want to limit the labeling to only certain types of frames: change the '0'

                  // into '1' to enable these options.

                  //

                  // Change the line with kShowImageFileName if you want to also show image names in addition to the

                  // size for image frames.

                  //

                  // Small frames are not labeled - the cut off point is currently any frame less than 0.1 inch high

                  // or 0.1 inch wide. You can change the cutoff point by adjusting the lines with kDontLabelBelowWidth

                  // or kDontLabelBelowHeight below.

                  //

                  // For debugging:

                  //

                  // To de-instrument (comment LogEntry/LogExit): do a global find change and

                  // replace pattern       /**///      with pattern    /**///

                  // To instrument (uncomment LogEntry/LogExit): do a global find change and

                  // replace pattern       /**///      with pattern    /**///

                  //

                   

                   

                  //#targetengine "com.rorohiko.indesignscripts.SizeLabels2"

                   

                   

                  var gErr;

                  var gScriptFile;

                  var gCaches;

                   

                   

                  try

                  {

                      if (app.activeScript instanceof File)

                      {

                          var gScriptFile = app.activeScript;

                      }

                  }

                  catch (gErr)

                  {

                  }

                   

                   

                  if (typeof(kLogLevel) == "undefined")

                  {

                      const kLogLevel = 5;

                      const kMaxLogNestLevel = 5;

                      const kLogToMessageBox = 0;

                      const kLogToConsole = 0;

                      const kLogToFile = 0;

                      const kLogFileName = "SizeLabels.log";

                      const kIgnoreFrameLabel = "ignore";

                      const kSizeLabelLayerName = "SizeLabels";

                      const kLabelNestedItems = 1;

                      const kDontLabelImageFrames = 0;

                      const kDontLabelTextFrames = 0;

                      const kDontLabelOtherFrames = 0;

                      const kUnitToUse = MeasurementUnits.INCHES;

                      const kShowImageFileName = 0; // Set this to 1 to prepend the image file name to the label

                      // All measurements below are expressed in kUnitToUse (e.g. inches if MeasurementUnits.INCHES is used)

                      const kRoundToDecimals = 2;

                      // Separators to use between items - e.g. MyImage.jpg - 7.22 x 9.34

                      const kSeparatorBetweenNameAndSize = " - ";

                      const kSeparatorBetweenWidthAndHeight = " x ";

                      const kDontLabelBelowWidth = 0; // Expressed in kUnitToUse

                      const kDontLabelBelowHeight = 0; // Expressed in kUnitToUse

                      const kLabelStyleName = "SizeLabelStyle";

                      const kLabelObjectStyleName = "SizeLabelObjectStyle";

                      const kLabelHeight = 0.1; // Expressed in kUnitToUse

                      const kLabelWidth = .16; // Expressed in kUnitToUse (e.g. inch).

                  }

                   

                   

                  var gRunState =

                  {

                      logToMessageBox: kLogToMessageBox,

                      logToConsole: kLogToConsole,

                      logToFile: kLogToFile,

                      functionNestLevel: 0,

                      logFunctionEntry: true,

                      logFunctionExit: true,

                      logLevel: kLogLevel,

                      logFileName: kLogFileName

                  };

                   

                   

                  Main();

                   

                   

                  // ****************

                   

                   

                  function ConvertToFrame(thePageItem)

                  {

                      /**///LogEntry("ConvertToFrame");

                      var retVal = thePageItem.getElements()[0];

                      /**///LogExit("ConvertToFrame");

                    

                      return retVal;

                  }

                   

                  // ****************

                   

                   

                  function CollectionToArray(theCollection)

                  {

                      /**///LogEntry("CollectionToArray");

                      var retVal = theCollection.everyItem().getElements().slice(0);

                      /**///LogExit("CollectionToArray");

                    

                      return retVal;

                  }

                   

                   

                  // ****************

                   

                   

                  function GetImageFile(pageItem)

                  {

                      /**///LogEntry("GetImageFile");

                   

                   

                      var imageFile = null;

                      do

                      {

                          try

                          {

                              pageItem = ConvertToFrame(pageItem);

                   

                   

                              if ( !("allGraphics" in pageItem))

                              {

                    break;

                              }

                    

                      var allGraphics = pageItem.allGraphics.slice(0);

                      if (allGraphics.length == 0)

                      {

                      break;

                      }

                    

                      var graphic = allGraphics[0];

                      var link = graphic.itemLink;

                      imageFile = new File(link.filePath);

                          }

                          catch (gErr)

                          {          

                          }

                      }

                      while (false);

                   

                   

                      /**///LogExit("GetImageFile");

                   

                   

                      return imageFile;

                  }

                   

                   

                  // ****************

                   

                   

                  function GetImageName(pageItem)

                  {

                      /**///LogEntry("GetImageName");

                   

                   

                      var imageName = "";

                      do

                      {

                          var imageFile = GetImageFile(pageItem);

                          if (imageFile == null)

                          {

                              break;

                          }

                   

                   

                          imageName = imageFile.displayName;

                      }

                      while (false);

                   

                   

                      /**///LogExit("GetImageName");

                   

                   

                      return imageName;

                  }

                   

                   

                  // ****************

                   

                   

                  function GetOuterPageItem(pageItem)

                  {

                      /**///LogEntry("GetOuterPageItem");

                    

                      var retVal = null;

                      do

                      {

                          try

                          {

                              retVal = pageItem.parent;

                              if (retVal instanceof Spread || retVal instanceof Page)

                              {

                                  retVal = pageItem;

                                  break;

                              }

                        

                              if (retVal instanceof Character)

                              {

                                  retVal = GetOuterPageItem(retVal.parentTextFrames[0]);            

                                  break;

                              }

                          }

                          catch (gErr)

                          {

                              retVal = null;

                          }

                      }

                      while (false);

                   

                   

                      /**///LogExit("GetOuterPageItem");

                    

                      return retVal;

                  }

                   

                  // ****************

                   

                   

                  function LogMessage(message,collapseLines)

                  {

                      if (gRunState.logToConsole)

                      {

                          $.writeln(message);

                      }

                      if (gRunState.logToFile)

                      {

                          var logFile = new File(gScriptFile.parent + "/" + gRunState.logFileName);

                          var now = new Date();

                          logFile.open("a");

                          logFile.write(now.toString() + ": " + message + "\n");

                          logFile.close();

                      }

                      if (gRunState.logToMessageBox)

                      {

                          alert(message);

                      }

                  }

                   

                   

                  // ****************

                   

                   

                  function LogEntry(message)

                  {

                      if (gRunState.logFunctionEntry)

                      {

                          if (gRunState.functionNestLevel < kMaxLogNestLevel) {

                              for (var idx = 0; idx < gRunState.functionNestLevel; idx++)

                              {

                                  message = "  " + message;

                              }

                              LogNote(message + "<",true);

                          }

                      }

                      gRunState.functionNestLevel++;

                  }

                   

                   

                  // ****************

                   

                   

                  function LogError(message)

                  {

                      if (gRunState.logLevel >= 1)

                      {

                          LogMessage("***ERROR***: "+message,false);

                      }

                  }

                   

                   

                  // ****************

                   

                   

                  function LogExit(message)

                  {

                      gRunState.functionNestLevel--;

                      if (gRunState.functionNestLevel < 0)

                      {

                          LogError("LogExit: unbalanced function nesting");

                      }

                      if (gRunState.logFunctionExit)

                      {

                          if (gRunState.functionNestLevel < kMaxLogNestLevel) {

                              for (var idx = 0; idx < gRunState.functionNestLevel; idx++)

                              {

                                  message = "  " + message;

                              }

                              LogNote(message + ">",true);

                          }

                      }

                  }

                   

                   

                  // ****************

                   

                   

                  function LogNote(message)

                  {

                      if (gRunState.logLevel >= 3)

                      {

                          LogMessage("Note: "+message,false);

                      }

                  }

                   

                   

                  // ****************

                   

                   

                  function LogWarning(message)

                  {

                      if (gRunState.logLevel >= 2)

                      {

                          LogMessage("WARNING: "+message,false);

                      }

                  }

                   

                   

                  // ****************

                   

                   

                  function Main()

                  {

                      /**///LogEntry("Main");

                    

                      var savedUserInteractionLevel = app.scriptPreferences.userInteractionLevel;

                      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

                    

                      do

                      {

                          try

                          {

                              var activeDocument = app.activeDocument;

                              if (! (activeDocument instanceof Document))

                              {

                                  LogError("Main: activeDocument is not a Document");

                                  break;

                              }

                            

                              var savedHorizontalMeasurementUnits = activeDocument.viewPreferences.horizontalMeasurementUnits;

                              activeDocument.viewPreferences.horizontalMeasurementUnits = kUnitToUse;

                              var savedVerticalMeasurementUnits = activeDocument.viewPreferences.verticalMeasurementUnits;

                              activeDocument.viewPreferences.verticalMeasurementUnits = kUnitToUse;

                              var savedRulerOrigin = activeDocument.viewPreferences.rulerOrigin;

                              activeDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;

                              do

                              {

                                  try

                                  {

                                      ProcessFrames(activeDocument);

                                  }

                                  catch (gErr)

                                  {

                                      alert("The script encountered a situation it does not know how to handle. The error it received into says '" + gErr + "' in Main()");

                                  }

                              }

                              while (false);

                              activeDocument.viewPreferences.rulerOrigin = savedRulerOrigin;

                              activeDocument.viewPreferences.horizontalMeasurementUnits = savedHorizontalMeasurementUnits;

                              activeDocument.viewPreferences.verticalMeasurementUnits = savedVerticalMeasurementUnits;

                          }

                          catch (gErr)

                          {

                              alert("The script encountered a situation it does not know how to handle. The error it received into says '" + gErr + "' in Main()");

                              LogError("Main throws " + gErr);

                          }

                      }

                      while (false);

                      app.scriptPreferences.userInteractionLevel = savedUserInteractionLevel;

                   

                   

                      /**///LogExit("Main");

                  }

                   

                   

                  // ****************

                   

                   

                  function ProcessFrames(doc)

                  {

                      /**///LogEntry("ProcessFrames");

                   

                   

                      var err;

                      do

                      {

                          if (! (doc instanceof Document))

                          {

                            LogError("ProcessFrames: doc should be a Document");

                            break;

                          }

                        

                          try

                          {

                              var existingLayer = doc.layers.itemByName(kSizeLabelLayerName);

                              existingLayer.id;

                              existingLayer.remove();

                          }

                          catch (err)

                          {

                          }

                        

                          if (kLabelNestedItems)

                          {

                              var pageItems = doc.allPageItems.slice(0);

                          }

                          else

                          {

                              var pageItems = CollectionToArray(doc.pageItems);

                          }

                        

                          var frameReferences = [];

                          for (var pageItemIdx = 0; pageItemIdx < pageItems.length; pageItemIdx++)

                          {

                              do

                              {

                                  var pageItem = pageItems[pageItemIdx];

                                  if (pageItem.itemLayer.name == kSizeLabelLayerName)

                                  {

                                      break;

                                  }

                   

                   

                                  var pageItem = ConvertToFrame(pageItem);

                                  if (pageItem instanceof TextFrame)

                                  {

                                      if (kDontLabelTextFrames)

                                      {

                                          break;

                                      }

                                  }

                                  else if (pageItem instanceof Graphic)

                                  {

                                      if (kDontLabelImageFrames)

                                      {

                                          break;

                                      }

                                  }

                                  else

                                  {

                                      if (kDontLabelOtherFrames)

                                      {

                                          break;

                                      }

                                  }

                                

                                  if (pageItem.label.toLowerCase() == kIgnoreFrameLabel)

                                  {

                                      break;

                                  }

                            

                                  var width = pageItem.geometricBounds[3] - pageItem.geometricBounds[1];

                                  var height = pageItem.geometricBounds[2] - pageItem.geometricBounds[0];

                   

                   

                                  if (width < kDontLabelBelowWidth)

                                  {

                                      break;

                                  }

                                  if (height < kDontLabelBelowHeight)

                                  {

                                      break;

                                  }

                   

                   

                                  frameReferences.push(pageItem);

                              }

                              while (false);

                          }

                        

                          var sizeLabelLayer = doc.layers.add({ name: kSizeLabelLayerName });

                        

                          for (var pageItemIdx = 0; pageItemIdx < frameReferences.length; pageItemIdx++)

                        

                           

                        

                          {

                            

                                      var docRef = app.documents.item(0);

                                      var layerRef = docRef.layers.itemByName("Layer 1");

                                      var theCount = docRef.ovals.count();

                                                       

                                     var  labelText1 = eval(theCount);

                                     

                            

                            

                              try

                              {

                                

                                                  

                                

                                

                                  var pageItem = frameReferences[pageItemIdx];

                                  var width = pageItem.geometricBounds[3] - pageItem.geometricBounds[1];

                                  var height = pageItem.geometricBounds[2] - pageItem.geometricBounds[0];

                                  var labelItem = doc.textFrames.add(null, LocationOptions.BEFORE, GetOuterPageItem(pageItem));

                                  labelItem.itemLayer = sizeLabelLayer;

                                

                               

                                  var labelText = "";

                                  if (kShowImageFileName)

                                  {

                                      var imageName = GetImageName(pageItem);

                                      if (imageName != "")

                                      {

                                          labelText += imageName + kSeparatorBetweenNameAndSize;

                                      }

                                  }

                                  labelText += RoundString(width, kRoundToDecimals) + kSeparatorBetweenWidthAndHeight + RoundString(height, kRoundToDecimals);

                   

                   

                                

                                

                                  var xPos = pageItem.geometricBounds[1];

                                  var yPos = pageItem.geometricBounds[0] - kLabelHeight;

                                  labelItem.geometricBounds = [ yPos, xPos, yPos + kLabelHeight, xPos + kLabelWidth ];

                                 

                                

                                  labelItem.contents = "ab";

                                

                                  try

                                  {

                                      labelItem.parentStory.characters.everyItem().appliedCharacterStyle = doc.characterStyles.item(0);

                                  }

                                  catch (err)

                                  {

                                  }

                            

                                  try

                                  {

                                      labelItem.parentStory.paragraphs.everyItem().appliedParagraphStyle = kLabelStyleName;

                                  }

                                  catch (err)

                                  {

                                  }

                                

                                  try

                                  {

                                      labelItem.appliedObjectStyle = doc.objectStyles.itemByName(kLabelObjectStyleName);

                                  }

                                  catch (err)

                                  {

                                  }

                              }

                              catch (err)

                              {

                              }         

                          }

                        

                      }

                      while (false);

                    

                      /**///LogExit("ProcessFrames");

                  }

                   

                   

                  // ****************

                   

                   

                  function RoundString(numVal, decimals)

                  {

                    

                      /**///LogEntry("Round");

                      var retVal = Math.round(numVal * Math.pow(10,decimals)) + "";

                      retVal = retVal.substring(0,retVal.length-decimals) + "." + retVal.substring(retVal.length-decimals);

                      /**///LogExit("Round");

                    

                      return retVal;

                  }

                   

                   

                   

                   

                   

                   

                  Hope now you understand what i Mean

                  • 6. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                    Laubender Adobe Community Professional & MVP

                    If you start from scratch I would create a text frame with automatic numbering and an anchored dot like already explained and use a script like the one below that would duplicate the selected text frame and add that duplicate to the story.

                     

                    // addTextFrameToStory_OneTextFrame_SELECTION.jsx
                    // Uwe Laubender
                    
                    /**
                    * @@@BUILDINFO@@@ addTextFrameToStory_OneTextFrame_SELECTION.jsx !Version! Mon Apr 25 2016 11:38:43 GMT+0200
                    */
                    
                    
                    app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;
                    
                    app.doScript    
                        (
                        
                        addTextFrameToStory, 
                        ScriptLanguage.JAVASCRIPT, 
                        [],
                        UndoModes.ENTIRE_SCRIPT, 
                        "Add Text Frame to Story | SCRIPT"
                        
                        );
                    
                    function addTextFrameToStory()
                    {
                        
                        if(doSomeChecks() === false){return};
                        
                        var original = app.selection[0];
                        var myDup = app.selection[0].duplicate();
                        
                        original.nextTextFrame = myDup;
                        myDup.move(undefined, [ myDup.geometricBounds[3]-myDup.geometricBounds[1] , 0 ] );
                        app.select(myDup);
                    
                        
                        function doSomeChecks()
                        {
                            if(app.documents.length == 0){return false};
                            if(app.selection.length !== 1){return false};
                            if(app.selection[0].constructor.name !== "TextFrame"){return false};
                            return true;
                        }
                        
                    }
                    

                     

                    1. We start out with the text frame selected.
                    Note: Close your Story Editor window before running the script!

                    1-BeforeRunningTheScript.png

                    2. After running the script:

                    2-AfterRunningTheScript.png

                    3. The duplicated frame after moving it with the mouse:

                     

                    3-AddedFrame-MovedByMouse.png

                     

                    I see no simpler solution…

                     

                    Uwe

                    • 7. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                      Laubender Adobe Community Professional & MVP

                      Note: I did not see your reply before posting my last one.

                       

                      Uwe

                      • 8. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                        henum87248073 Level 1

                        Hello Uwe

                        thankyou for all your support... but I think that duplicating the text frame won't work for me. As you can see in the picture i have the fix position for the dots and I have the text moving around it. But whit the anchored dot, it doubles my work as i need to first duplicate the whole thing and then moving the dot with the text frame to the correct position and then the dot... and it will be very difficult.

                         

                        It can work only if I have the dots fixed and text position flexible to move around... can this be possible in any way...

                         

                         

                        Rakesh

                        • 9. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                          Laubender Adobe Community Professional & MVP

                          Hi Rakesh,

                          how do you know the right position for the dots?

                          On your screenshot some of the dots seem to be positioned a bit arbitrarily…

                           

                          Uwe

                          • 10. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                            henum87248073 Level 1

                            Hello Uwe

                            good morning (it's here)

                             

                            Yes you see the dots placed arbitarily... but there is an order in which they all need to be placed and once placed they are supposed to fixed to that location. Now, if any other dot falls near them then we need to move the text frame so that the numbers don't clash.  This is why the mehtod you have suggested won't work for me. As if i move the text frame,  the dot being anchored also move.....

                             

                            Hope you understand my point....

                             

                            Thanks

                             

                            Rakesh

                            • 11. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                              Laubender Adobe Community Professional & MVP

                              Hi Rakesh,
                              Good morning to you!

                               

                              I think, I understand your point very well.

                              It's a complex issue for scripting.


                              I was trying something by exploiting the AFTER_SELECTION_CHANGED event. Every time you click a dot (you select a dot) a new text frame will be added to the chain of text frames and will be positioned next to the dot.


                              The problem is to control the chain of text frames, if one will make a mistake and selects the wrong dot and wants to undo the last step. Or if the user likes to pause in his work, comes back and starts again. Though I have already included a START and a STOP for following the selection events, this is not fully tested.

                               

                              Scripting event listeners is a hell to debug. This task is not done in a few hours.

                               

                              If I have time I will record a movie clip and post the link what my script in beta stage can already do.

                              I cannot promise anything, if this is leading to something valuable for you.

                               

                              Hm, there is this other thought:

                              If you create and position the dots in the right order, one by one, it should be possible to follow this chain of bread-crumbs and build a chain of text frames on top of it. The chain of text frames would be in creation order of the dots. To help the script identifying a dot you could name a dot like that:

                               

                              1. Renaming a dot

                              You see the Layers panel showing the generic name of the selected dot in German <Kreis> => <Circle> :

                              1-RenamingADot.png

                              Select the name with one click and rename it to a unique name:

                              2-RenamingADot.png

                              3-RenamingADot.png

                              Build the order of dots by adding one by one in the order you want to have the text frames:

                              4-RenamingADot-MoreThanOneDot.png

                               

                              2. Selecting an arbitrary dot to help the script identifying the objects that it should follow:

                              5-BeforeRunningScript-ArbitraryDotSelected.png

                               

                              3. After running a script that is building a chain of text frames in creation order of the dots:

                              6-AfterRunningTestScript.png

                               

                               

                              Could that be a solution for you?

                               

                              Uwe

                              • 12. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                henum87248073 Level 1

                                Thanx UWE this is actually what I want.

                                 

                                 

                                If you create and position the dots in the right order, one by one, it should be possible to follow this chain of bread-crumbs and build a chain of text frames on top of it. The chain of text frames would be in creation order of the dots.

                                 

                                 

                                All the dots that I will place will be in order starting from ONE. And i will add this dot to the content place link and from there I will click and place the dots in right order one by one according to the design. I also don't need that the dots and text linked with each other but what i need is the text frame should be threaded to each other in the order as i created the dots. So that later if i need to add a dot and a number in between then  i ONLY need to add threaded text in between the text frames. Same way a I can delete a text frame and dot also.

                                 

                                 

                                Thankyou very much for all your support

                                 

                                Rakesh

                                • 13. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                  Laubender Adobe Community Professional & MVP

                                  Hi Rakesh,
                                  1. What should be the distance of the upper left edge of the dot to the upper left edge of the text frame?
                                  2. What should be the width and the height of each text frame?
                                  3. What is your measurement system? Millimeters?

                                   

                                  Uwe

                                  • 14. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                    Laubender Adobe Community Professional & MVP

                                    Forgot some:

                                    4. Are all dots on the same page?
                                    5. Or should the scope of the script be expanded to the whole spread of pages (pasteboard included)?

                                     

                                    Uwe

                                    • 15. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                      henum87248073 Level 1

                                      Just give me a moment... giving you all the details...

                                      • 16. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                        Laubender Adobe Community Professional & MVP

                                        No problem.
                                        I will be out of lunch for an hour soon.

                                         

                                        Uwe

                                        • 17. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                          henum87248073 Level 1

                                          Hi UWE...

                                           

                                          1. Font size I am using  9 pt Century Gothic. The gap beween font and the dot I am maintaining around .4 mm (though this is varying as I am manually moving them around the dots).

                                          2. Width of the text  frame I have set to Auto size However we can set these to a fix width of 5.5 mm so that three characters can fit in the frame.

                                          3. Measurement is not an issue... mm or points I can manage.

                                          4. All these dots are placed on a single page... pastboard not included.

                                           

                                          Thankyou very much Uwe for your support and prompt replies. This will be really helpful.

                                           

                                          Rakesh

                                          • 18. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                            Laubender Adobe Community Professional & MVP

                                            Hi Rakesh,

                                            and here the most important question:
                                            What is your InDesign version and OS version?

                                             

                                            Btw.: "Auto size" would do nothing to threaded text frames.

                                            It just works for single frames.

                                             

                                            ( I'm out for lunch now. )

                                             

                                            Uwe

                                            • 19. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                              henum87248073 Level 1

                                              Oh thanx UWE, I have just checked Auto Size doesn't work.

                                               

                                              Indesign Version I am using is CS 6 and os is WIndows 8.

                                               

                                              Rakesh

                                              • 20. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                rob day Adobe Community Professional & MVP

                                                A different approach might be to add a script label to the text frame and use it for creating the numbered list text flow. So here I have the circle and a text frame with the numbered list grouped. The text frame has a label applied "n":

                                                 

                                                Screen Shot 2016-04-26 at 12.01.19 PM.png

                                                I add copies of the grouped graphic via the content placer tool:

                                                 

                                                Screen Shot 2016-04-26 at 12.02.01 PM.png

                                                 

                                                 

                                                and run the script:

                                                 

                                                Screen Shot 2016-04-26 at 12.02.21 PM.png

                                                 

                                                I can add additional items and run again:

                                                 

                                                Screen Shot 2016-04-26 at 12.02.36 PM.png

                                                Screen Shot 2016-04-26 at 12.02.46 PM.png

                                                 

                                                 

                                                 

                                                Here's the script as AppleScript with annotations:

                                                 

                                                --the script label

                                                set nlabel to "n"

                                                 

                                                tell application "Adobe InDesign CC 2014"

                                                  

                                                    --get all of the existing frames with a script label

                                                    set tf to (every text frame of all page items of active document whose label is nlabel)

                                                  

                                                    --get a list of labeled frame's ids

                                                    set framelist to {}

                                                    if tf is not {} then

                                                        --clear the text and links

                                                        repeat with x in tf

                                                            copy id of x to end of framelist

                                                            set contents of parent story of x to ""

                                                            set next text frame of x to nothing

                                                        end repeat

                                                    end if

                                                  

                                                    --order the id list

                                                    set olist to my listSort(framelist)

                                                  

                                                    --link the number frames in the order they were created

                                                    repeat with i from 1 to (count of olist) - 1

                                                        set theID to item i of olist as number

                                                        set nextID to item (i + 1) of olist as number

                                                        set a to text frame id theID of active document

                                                        set b to text frame id nextID of active document

                                                        set next text frame of a to b

                                                    end repeat

                                                  

                                                    --reset the numbers—a return for each text frame

                                                    set s to ""

                                                    repeat (count of tf) times

                                                        set s to s & return

                                                    end repeat

                                                try

                                                    set contents of parent story of a to s

                                                end try

                                                end tell

                                                 

                                                --function to order a list (the list to sort)

                                                on listSort(l)

                                                    set od to AppleScript's text item delimiters

                                                    set AppleScript's text item delimiters to {ASCII character 10}

                                                    set ls to (l as string)

                                                    set AppleScript's text item delimiters to od

                                                    return (paragraphs of (do shell script "echo " & quoted form of ls & " | sort -f"))

                                                end listSort

                                                1 person found this helpful
                                                • 21. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                  rob day Adobe Community Professional & MVP

                                                  os is WIndows 8.

                                                  Obviously my AS won't work, but the annotations should make a translation to JS easy

                                                  • 22. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                    Laubender Adobe Community Professional & MVP

                                                    Hi Rob,

                                                    in the meanwhile I sent Rakesh an ExtendScript for testing by mail.
                                                    I guess he's in a different time zone. So I would not expect to hear from him soon.

                                                     

                                                    Uwe

                                                    • 23. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                      Laubender Adobe Community Professional & MVP

                                                      I like your approach with the script label.

                                                       

                                                      Uwe

                                                      • 24. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                        rob day Adobe Community Professional & MVP

                                                        With the script label you can also Command-Option drag to make the clones, which is probably going to be faster the using the content placer

                                                        • 25. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                          Obi-wan Kenobi Adobe Community Professional

                                                          Hi all,

                                                           

                                                          If I have well understood!

                                                           

                                                          At the beginning:

                                                          Capture d’écran 2016-04-26 à 20.10.18.png

                                                          So, I select the "red" circle and duplicate it (drag and drop | alt+cmd).

                                                          [to follow the order of creation, see the "blue" squares with number (1 to 10), on "Num" locked layer]

                                                           

                                                          Capture d’écran 2016-04-26 à 20.14.14.png

                                                           

                                                          Note that each red circle has a small anchored text block with autonumbering  at "1"!

                                                           

                                                          The only thing to do now is to select all the red circles (on "Circles" layer) and launch this small [and so clever] script written by Vamitul* [ ] 4 years ago!

                                                           

                                                           app.doScript('linkster(app.activeDocument.selection)',undefined,undefined,UndoModes.entireScript,'Linkster');    
                                                            
                                                            
                                                          function linkster(mySelection){  
                                                          try {  
                                                          if ((mySelection.length>0)& (testConstr (mySelection)))  
                                                          {  
                                                              for (var i=0; i<mySelection.length; i++){  
                                                                  mySelection[i].insertionPoints.lastItem().contents=SpecialCharacters.FRAME_BREAK;    
                                                                      if (i>0){  
                                                                             if (mySelection[i].previousTextFrame==null)  
                                                                             mySelection[i].previousTextFrame=mySelection[i-1];  
                                                                                     }  
                                                                 }  
                                                          }  
                                                          }catch (e) {alert (e.message + "\r(line " + e.line + ")\rInvalid Selection")};  
                                                          }  
                                                          function testConstr(mySelect){  
                                                              for (var i=0; i<mySelect.length; i++){  
                                                                  if (mySelect[i].constructor.name!="TextFrame") return false;  
                                                                  }  
                                                              return true;  
                                                              }  
                                                          
                                                          

                                                           

                                                          Result:

                                                           

                                                          Capture d’écran 2016-04-26 à 20.16.27.png

                                                          Capture d’écran 2016-04-26 à 20.16.48.png

                                                          Capture d’écran 2016-04-26 à 20.28.25.png

                                                           

                                                           

                                                           

                                                          * link:  Two scripts for easier threading/unthreading text

                                                          • 26. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                            rob day Adobe Community Professional & MVP

                                                            Hi Obi, This is a similar approach to my AS. Using the Script Label has some advantages: you don't have to use layers or make a selection before running the script and the items could even be on multiple pages.

                                                             

                                                            I also found that if I wanted to add items and rerun the script, the numbering order would sometimes be wrong. So I'm taking the extra step of sorting the text frames by the ID property, which always seems to set the correct order. Haven't tested your script to see if that's a problem. The list of objects in a selection often is in order of creation, but not always.

                                                            • 27. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                              Laubender Adobe Community Professional & MVP

                                                              Hi Rob and Obi-wan,

                                                               

                                                              the creation order is guaranteed after a numeric sort of ID numbers.
                                                              If a new object is added to a document, a new ID number is applied to the object. This ID number is always higher than the one introduced before. Even if you remove an object, the ID number of the object is not reused. Fortunately!

                                                               

                                                              Uwe

                                                              • 28. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                Obi-wan Kenobi Adobe Community Professional

                                                                Rob, My apologizes: I've not tested your script and I just showed how I do until this topic! Sure! I'm going to play with your [AS] and give you comments (if comments!)!  ;-)

                                                                 

                                                                About script labels use, do you (Uwe too apparently!) that adding new items could be problematic?

                                                                E.g. insert an item between the number 5 and the number 6!

                                                                • 29. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                  rob day Adobe Community Professional & MVP

                                                                  Right, it could be  the way I'm getting the list via the label property, or maybe AS handles the list order differently, but I was having problems with the number ordering until I decided to sort by ID.

                                                                  • 30. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                    rob day Adobe Community Professional & MVP

                                                                    About script labels use, do you (Uwe too apparently!) that adding new items could be problematic?

                                                                     

                                                                    Al the label does is identify the items that should be in the text flow (so you don't have to make a selection). The numbering order would always be in the order items were added. So you could add 5 new items, run the script, add two new items, run the script, and the two new items would be numbered 6 & 7

                                                                    • 31. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                      Obi-wan Kenobi Adobe Community Professional

                                                                      I've just tested this point: In my sample, I have 10 circles threaded! I want to insert an eleventh, between the 5th and the 6th!

                                                                      No problem! … but to do it, I do it manually (but only 4 sec.) with Text Stitch ["Quick Stitch" menu] of our other great friend Kris Coppieters (from Rorohiko).

                                                                       

                                                                      Rob, a comment: using a "Circles" layer and doing Cmd-A to all select are simple things to play! 

                                                                      • 32. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                        rob day Adobe Community Professional & MVP

                                                                        Here's my test file—I'm using a group and not inserting the circle in the text flow:

                                                                         

                                                                        http://www.zenodesign.com/forum/OrderedNumbers.zip

                                                                        • 33. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                          Laubender Adobe Community Professional & MVP

                                                                          Basically I see two solutions to the problem:

                                                                          1. Working with threaded text frames and a numbering list

                                                                          2. Working with single text frames and do the numbering as part of a script

                                                                           

                                                                          My favourite is number 1.

                                                                           

                                                                          There are pros and cons in each of the two approaches.

                                                                           

                                                                          Algorithm 1:

                                                                          Pro: You could add some dots in between after running the script; the numbering will update automatically

                                                                          Con: The threaded "links" itself could be disturbing (no real con, but it should be mentioned)

                                                                          Con: Removing the text frames and starting the script after adding some dots in between would yield to a false order of text frames.
                                                                          But the same is true with algorithm 2.

                                                                           

                                                                          Algorithm 2:

                                                                          Pro: No threaded links that could disturb someone (that is a lame point, I know)

                                                                          Con: It's hard to impossible to add some dots in between after the script run.

                                                                           

                                                                          Note: If a bunch of objects are selected, you cannot take the order of selection as the order of creation; or the order, that is intended.
                                                                          If you add an object to a selection step by step holding the SHIFT key and clicking (I call it the click-order), the order of selection can be determined (InDesign CS5.5 and above): Then the app.selection collection is in click-order and can be looped easily.

                                                                           

                                                                          Uwe

                                                                          • 34. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                            Laubender Adobe Community Professional & MVP

                                                                            Oh, there is another algorithm.


                                                                            3. Create an eventlistening mechanism that will add a text frame to the page every time one of the dots is selected and the selection has changed.

                                                                             

                                                                            Uwe

                                                                            • 36. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                              Obi-wan Kenobi Adobe Community Professional

                                                                              Uwe,

                                                                               

                                                                              I don't think we need to complexify the matter! Of course, the real problem could be at a moment the items creation order!

                                                                              But, as I said, if (and only if "if") we need to add/insert new items, it's could be very quick to do it manually with Text Stitch!

                                                                              Note that if the items order creation and the op final order are very different, the game could be done very quickly, manually, with Text Stitch, selecting the item one by one in the good order! 

                                                                              • 37. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                                Laubender Adobe Community Professional & MVP

                                                                                Let's see what Rakesh has to say…

                                                                                I'll have to sleep it over now. :-)

                                                                                 

                                                                                Uwe

                                                                                • 38. Re: Auto adding text frame besides a circle shape placed usingc content placer tool
                                                                                  rob day Adobe Community Professional & MVP

                                                                                  You could manually insert new items in the text flow, but if you have to run the (my) script again the numbers would be wrong.

                                                                                   

                                                                                  Screen Shot 2016-04-26 at 4.57.24 PM.png

                                                                                  Screen Shot 2016-04-26 at 4.57.49 PM.png

                                                                                  1 2 Previous Next