2 Replies Latest reply on Apr 26, 2017 12:46 AM by robertm43450875

    Apply tag to frame

    robertm43450875

      Hi

       

      I need to create tag apply tag to frame using javascript.

       

      tags.PNG

       

      Thanks

        • 1. Re: Apply tag to frame
          Loic.Aigon Adobe Community Professional

          Have you even tried to do something out of your hands ?

           

          var main = function() {
            var doc = app.properties.activeDocument, 
            sel, n, p, t, xe, item;
            if ( !doc || !app.selection.length) return;
            sel = app.selection;
            n = app.selection.length;
          
          
            p = prompt ( "Let's set some name for our tag…" , 'yo', 'Create a tag' );
          
          
            if ( !p ) return;
          
            //one should check for tag name validity
          
            t = doc.xmlTags.itemByName ( p );
            !t.isValid && t = doc.xmlTags.add( p );
          
            while ( n-- ) {
            //Normally would avoid try/catch and inspect items but being lazy here
            item = sel[n];
            try {
            item.autoTag();
            xe = item.properties.associatedXMLElement;
            !xe && xe = item.properties.associatedXMLElements[0];
            xe.markupTag = t;
            }
            catch(err) {
          
            }
            }
          }
          
          
          main();
          
          • 2. Re: Apply tag to frame
            robertm43450875 Level 1

              var doc = app.activeDocument;

              var frame = app.selection[0];

              var xmlElement = doc.xmlElements[0].xmlElements.add("send");

              frame.markup(xmlElement);