Jump to content

One rule for several frames?


esmith

Recommended Posts

Is it possible to write one JS rule that could be applied to several graphic frames, and potentially return a unique graphic to each one? My logic looks something like this:

 

// pull the trailing number from the current frame's name
var frame_name = FusionPro.Composition.CurrentFlow.Name;
var num = Right(frame_name, 1);

// use the number of the current frame to pull the corresponding numbered image
var style = num + "_sign_style";
var version = num + "_sign_version";
var place_image = Field(style) + "-" + Field(version) + ".pdf";

return CreateResource(SearchPath + place_image);

I could then (in theory) assign this same rule to "frame1", "frame2", and "frame3" and the rule would return "aa-123.pdf", "bb-456.pdf", and "cc-789.pdf" respectively.

 

This would save me from duplicating the same rule n number of times in order to apply a unique rule to each frame. I'm not sure if this is the purpose of the CurrentFlow object, but that's how I understood the documentation (RulesSystemGuide, p83).

Link to comment
Share on other sites

Well, my original code doesn't work, but modifying this logic accomplished my goal.

// assign correct graphic to each frame
var numUp = 1;
switch (Field("template_size")) {
   case "4x5":
   numUp = 4;
   break;

   case "5x8":
   numUp = 2;
   break;

   case "11x4":
   numUp = 2;
   break;

   case "label":
   numUp = 24;
   break;
}

var graphicNum = [];
for (i=1; i<=numUp; i++) {
   var styleNum = i + "_sign_style";
   var versionNum = i + "_sign_version";
   if (Field(styleNum) != "") graphicNum[i] = Field(styleNum) + "-" + Field(versionNum) + ".pdf";
   else graphicNum[i] = graphicNum[i-1];
   FindGraphicFrame("backdrop" + i).SetGraphic(SearchPath + graphicNum[i]);
   }

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...