Quantcast
Channel: Adobe Community : Popular Discussions - Adobe FrameMaker
Viewing all articles
Browse latest Browse all 23442

NewElementInHierarchy() - Adding New Elements, progressively takes longer when adding multiple siblings

$
0
0

With my ESTK script, users select model numbers from a list and then the script inserts an element with a model number entered into an attribute, one element for each model selected.

 

When adding a large number of elements, each additional sibling element takes a little longer to add then the previous element. Adding 250 elements can take upwards of 3-1/2 minutes or more. While adding 20, 50, or 75 elements happens quickly, without any noticeable duration. It’s somewhere above 110 is where it starts to be noticeable.

 

I even used $.hiresTimer and wrote the value to the console for each time a model was added. Since the timer is reset back to zero (0) each time it's called, it was easier to notice that the amount it incremented from one element to the next got progressively larger.

 

Any thoughts as to why it’s taking so long or thoughts on what I could do to speed it up?

 

The structure looks like this:

<PartModels>
      <NoteText>Text</NoteText>
      <Model ModelNumber=”ABC01”/>
      <Model ModelNumber=”ABC02”/>
      <Model ModelNumber=”DEF03”/>
      <Model ModelNumber=”DEF04”/>
      …
      …
      <Model ModelNumber=”XYZ01-A”/>
      <Model ModelNumber=”XYZ*B”/>
      <Model ModelNumber=”XYZ500”/>
</PartModels>

 

The script is somewhat straight forward: cycle through an array of the model numbers selected, add a new element for each model number and set it's attribute value to the model number. This is the short version:

 

Function InsertModelElements (modelsToIns, insElemLoc, GVdoc) {

     var newEleId;

     var newElemLoc = insElemLoc;

     var elemDef = GVdoc.GetNamedElementDef(“Model”);

     for(var i = 0; i < modelsToIns.length; i++){ // modelsToIns is the array of models selected

          newEleId = elemDef.NewElementInHierarchy(newElemLoc); //ElementLoc based on NoteText first, last, or not present

          SetAttribute(newEleId, "ModelNumber", null, modelsToIns[i]); //more robust function to set attribute

         

          /*Which also works for setting attribute*/

          //var vattributes = newEleId.GetAttributes();

          //vattributes[0].values[0] = modelsToIns[i];

          //newEleId.Attributes = vattributes;


          /*At one point I tried using a new element location from the last inserted element, no change*/

          //var newElemRange = setElementSelection(GV_doc, EleId); //function that returns range

          //newElemLoc = newNewElemRange.end;

                }

}

Any help is appreciated.

 

Sincerely,

Trent


Viewing all articles
Browse latest Browse all 23442

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>