To clarify a bit, the "Coordinates" variable is a separate "Tabbed Text File" that is captured from the current "Template" file and parsed with RegEx (thanks, JMichaelTX) to get the current "Position" variables. I know there is MUCH potential for improvement, but I thrilled it's actually working now!
// Position Align Object
var idoc = app.activeDocument;
var myLayer = idoc.layers['FINGERPRINT'];
var mySubLayer = myLayer.layers['FINGERPRINTAlign'];
myLayer.visible = true;
mySubLayer.visible = true;
//var AlignObj = ilayer.pathItems;
var AlignObj = mySubLayer.pathItems.getByName('%Position%');
var AlignObjBounds = AlignObj.visibleBounds;
var topX = AlignObjBounds;
var topY = AlignObjBounds;
var botX = AlignObjBounds;
var botY = AlignObjBounds;
var mm = 2.83464567;
var deltaX = (botX-topX)/2*-1;
var deltaY = (botY-topY)/2*-1;
//Credit: Eric Moore - Calculate new center position for selection adjusting for current AI ruler setting.
AlignObj.position = [(%xRule%*mm+deltaX+(%FP_X%*mm)),(%yRule%*mm+deltaY-(%FP_Y%*mm))];
I have been thinking more about this and realize I may be complicating things.
In the solution you provided I was using a separate "positionArray" variable that is nothing more than the first tabbed column of variable "Coordinates". Is it possible to use a "For Each" loop that simply captures the string before the first tab of "Coordinates" and iterate through each line in "Coordinates"? I've added an Action that sets a sample "Coordinates" variable. I tried to set "Position" to the first string (R1_C1), but my RegEx does not work. What is wrong and is this approach feasible or is it better to work with a separate variable to parse "Coordinates"?
This animated gif illustrates the purpose of the macro. The objects being moved are "Alignment Objects" positioned based on the embedded "Coordinate Chart" that is saved by KM into "Coordinate" Variable. There are about 50 similar templates to maintain. The current process is to position each piece manually by keying in the coordinates. That stinks. The GIF is an exaggeration of the normal process of moving a few elements less than a mm.
The solution you showed me works fine. The only "downside" is I must capture a separate "positionArray" Variable. Since the first string in each line of "Coordinates" is what I'm keying on to set the "Position" xy coordinates I thought maybe there was a more direct way to take advantage of the "For loop".
I can share a simplified version of the Adobe Illustrator template if that would help, although I don't expect you use the program.
You can use the Search Variable action to map from the Coordinates variable to a specific set of R2_C2 (whatever) and fields in the line. You don't need a For Each action for that, just the Search action.
The "Coordinates" variable has from 6 to 12 lines. I need to capture the x/y coordinates on each line (R1_C1, etc.) and move the corresponding named elements to their assigned location. I am currently using a separate variable, "positionArray" to iterate each line of the "Coordinates" variable and move every element referenced in the "Coordinates" chart.
Thanks for helping me with this. I know I'm the one who is confused.
OK, so it sounds like you want to use a For Each action with the positionArray variable and a Lines In collection to iterate through the Coordinates variable. Then use a Search using Regular Expression action to search the positionArray variable and break it in to its component parts. And then move the appropriate element using those details.
It is not apparent to me that you even need to use KM.
What is the exact purpose/function you want to achieve with KM?
If you don't want/need to actually change the coordinates for each Alignment Object using KM, then what is its purpose in your workflow?
What is the purpose of writing the JXS scripts to file using KM?
I don't see any KM variables used in doing that.
Maybe it would help us better understand your workflow, and therefore be able to better help you, if you could list the specific steps in your workflow, clearly indicating where the source data is coming from, and how you want to change it.