Quantcast
Channel: All Your Documents Archive - 65bit Software
Viewing all articles
Browse latest Browse all 131

Formatting Rules – Duplicating a Frame for Each Cell of a Tabular Field

$
0
0

Sometimes is useful to break out things like colours into a tabular field and then populate these as a set of frames, one for each colour. The frames might contain a Swatch and a swatch name.

The example below iterates though the Colour tabular field, duplicating the frame given the Script Label group. It then populates it with the data for each cell. If the group is anchored in a text frame it will be duplicated immediately after in the text flow.

-- Get the frame by its Script Label
frame = formattingrule:getframe("group");

-- Store the original frame
original_frame = frame;

-- Get the tabular field called "Colour"
mytable = SELECTION.root():getfield('Colour'):content();

-- Loop for each row in the tabular field
for i = 1, mytable:rowcount() do 

  -- duplicate the frame and populate it with data from the given cell
  frame = frame:duplicate(mytable:cell(i,1));
end

-- Delete the original frame
original_frame:delete()

 

The post Formatting Rules – Duplicating a Frame for Each Cell of a Tabular Field appeared first on 65bit Software.


Viewing all articles
Browse latest Browse all 131

Trending Articles