9 Replies Latest reply on Jul 28, 2014 10:23 AM by RanaVision

    Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???

    RanaVision Level 1

      We are forced to port a Illustrator plugin from AS to c++.

      We convert / extract elements from Illustrator to InDesign (using IDML), heavily depending on data (both tags and variables)

      We're looking into the tags, but no clue where to look for the equivalent of textFrame.contentVariable ???

       

      Is it somewhere in a dictionary? On the textframe?

       

      This is embarassingly urgent, any help is welcome....

        • 1. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
          A. Patterson Level 4

          I'm not quite sure what you mean. What would be in contentVariable? Does that represent the text content of a text frame?

           

          As for tags, us AIDictionary instead. Tags are the old, old version. Dictionaries are a superset of tags, and the tag API is just creating & reading string entries from the underlying dictionary behind the scenes.

          • 2. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
            RanaVision Level 1

            Thanks for your input. I was not clear, but I'm a bit new to this:

            In illustrator, you have the variables palette, where variables are defined, and then linked to make text-elements "dynamic".

             

            We used to parse this as a simple "property" of the textframe, my_text.contentvariable,

            import com.adobe.illustrator.Variable;

            import com.adobe.illustrator.VariableKind;

             

            var variable:Variable = textFrame.contentVariable as Variable;

             

            and calling getType(variable.kind) and variable.name and the like...

             

            We basically need to reconstruct the "save variable library" XML....

            • 3. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
              A. Patterson Level 4

              Ah, the Variables panel. I'll admit, I know very little about that as its not something any of our users have asked for.

               

              I have a debug dump tool but it doesn't reveal anything in the dictionaries. A search through the SDK reveals nothing as well.

               

              Fortunately, I just remembered that the debug dump tool has the capacity to dump the document's dictionary & meta data. And the variable information is all stored in the document meta data! Its an XML-like structure attached to a root node on the document. If you build the above too, you can dump it with ALT + <click>.

               

              The header you want to use is AIEXMLElement.h, specifically the AIXMLDocumentSuite. Start by calling GetDocumentMetadata(), and then iterate the node you get back. From the looks of it, they're pretty much storing exactly what gets exported when you save out the variable library.

               

              Hope that helps!

              • 4. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                RanaVision Level 1

                Thx. It appears there simply is no public API for this, then? (there is no emoticon available to express my feelings)

                The debug tool looks fun, but porting it to Mac, and beyond the now obsolete ADM is going to take some time.

                I'll poke around a bit in the doc dictionary, hoping it contains not just the variables, but also the actual textareas that are linked to them.

                 

                You wouldn't have a sample document-with-variables and its matching datadump lying around, would you?

                • 5. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                  A. Patterson Level 4

                  No, there doesn't seem to be any public SDK header. There very well might be an internal one, but unless someone at Adobe knows & likes you, you're not likely to see it

                   

                  The debug tool shouldn't require an ADM, its a tool. As I said in a follow-up post on that thread, 99% of the work is done in one cpp file, so if you take one of the existing tool samples, you can probably get it working with very little effort. Basically you just need to make sure my code is fired from the 'on mouse up' selector/caller combination.

                   

                  I can probably rig up an example document, just give me a few minutes. I'm currently running CC 2014 but I can back-save the version (I assume CS6 is good since you mentioned that the ADM is obsolete).

                  • 6. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                    RanaVision Level 1

                    I'm on CC 2014 alright. And I'll dig into the debug-tool then.

                    I don't mind poking around and 'discover', it's just a bit scary to rely on non-public features as they may change.

                    What does it take to get to know someone at Adobe & get them to like me? Or should I start a new thread for that?

                    • 7. Re: Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                      A. Patterson Level 4

                      Here's what's in the document meta data (approximated as XML). My tool takes the node's name and makes sticks it in angle brackets. Plus it adds all the attributes.

                       

                           <variableSets xmlns= &ns_vars;>
                                <variableSet locked= nonevarSetName= binding1>
                                     <variables>
                                          <variable docRef= category= &ns_flows;varName= Variable1trait= textcontent/>
                                          <variable docRef= category= &ns_vars;varName= Variable2trait= visibility/>
                                     </variables>
                                     <v:sampleDataSets xmlns:v= &ns_vars;xmlns= &ns_custom;i:activeDataSet= Data Set 1>
                                          <v:sampleDataSet dataSetName= Data Set 1>
                                               <Variable1>
                                                    <p>
                                                         <#text>
                                                              <![CDATA[Test]]/>
                                                         </#text>
                                                    </p>
                                               </Variable1>
                                               <Variable2>
                                                    <#text/>
                                               </Variable2>
                                          </v:sampleDataSet>
                                     </v:sampleDataSets>
                                </variableSet>
                           </variableSets>
                      
                      

                       

                      Note: the weird spacing on the attributes & their values is me. I should probably tidy that up sometime.

                       

                      Here's the file: http://speedy.sh/Yswnj/ranavision.ai

                      • 8. Re: Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                        A. Patterson Level 4

                        Adobe folks do read this forum from time to time, you kind of have to hope they notice and take pity (assuming there's something to even send you). I've only seen a private header once, and it was years ago. The main reason they hold back on the headers is that the API isn't ready for public consumption. The one I saw has never been made public, probably because there's never been much interest. I'm not actually sure how something transitions form private to public. Lately, anything new is added to the SDK, but Variables goes back a ways I guess.

                         

                        The good news is this can probably be used to fairly easily replicate the save library option. I actually don't know what would happen if you altered the metadata. It's possible the Variables panel watches and would notice that the relevant metadata has changed, but it just as likely wouldn't. I don't see anything that directly connects the variables & the art objects, but there must be something. It's not the UID because I can see from the debug dump tool that the text in my example file doesn't have a UID.

                        • 9. Re: Illustrator plugin rewrite from AS to C++, where to look for the equivalent of textFrame.contentVariable ???
                          RanaVision Level 1

                          You have left me

                          • speechless
                          • overflowing with gratitude
                          • with no other choice than to mark this question as abundantly 'answered correct'

                           

                          Plenty of information to crunch and spend a sleepless night. Thx.