Here is a 2-minute video that illustrates a basic scripting solution:
https://youtu.be/jXNOxYYZWhE
Here is the code I am using in the video:
main ();
function main () {
var doc, element;
doc = app.ActiveDoc;
// Make sure there is an active document.
if (doc.ObjectValid () === 1) {
element = doc.MainFlowInDoc.HighestLevelElement;
// Make sure the document is structured.
if (element.ObjectValid () === 1) {
processElement (doc);
}
}
}
function processElement (doc) {
var element, values;
// Get the currently selected element.
element = doc.ElementSelection.beg.child;
if (element.ObjectValid () === 1) {
// Call a function to get a comma-separated list of
// Tails attribute values.
values = getAttributeValues (element, "Tails");
if (values) {
// Apply the list to the "display" attribute
// used in the Prefix rule.
setAttributeValue (element, "Tails_display", values);
}
}
}
function getAttributeValues (element, name) {
var attrList = element.Attributes, i = 0;
var attrList, count, i;
attrList = element.Attributes;
count = attrList.length;
for (i = 0; i < count; i += 1) {
if (attrList[i].name === name) {
if (attrList[i].values.length > 0) {
return (Array.prototype.join.call (attrList[i].values, ", "));
}
}
}
}
function setAttributeValue (element, name, value) {
// Sets the value of an attribute on the element.
var attrList = element.Attributes, i = 0;
for (i = 0; i < attrList.length; i += 1) {
if (attrList[i].name === name) {
attrList[i].values[0] = value;
element.Attributes = attrList;
return;
}
}
}
... View more