More complex (Python?) function evaluation / formatting in text objects?

Often when I’m creating a larger drawing set for a project, I have a few files with layouts that eventually get printed to several pdfs, which are then concatenated into one. Page numbers need to line up across the packet. I’m already using Document user text and various text functions including the page number function. However I was thinking it would be nice to use an arbitrary offset value in an evaluated equation to calculate the page numbers.

This had me thinking, what if there was a way to generally evaluate mathematical or pythonic equations to generate text objects? It could be possible with a script that finds the text objects via user attributes, evaluates and updates them but this would be clunky.

I’m imagining an expression evaluator like in the vscode python debug console.
Indexing arrays, dicts, using math, f-strings etc.

Are you using regex already?

Hi Tristan -

I’m not clear about the specifics of your situation but there is an offset that can be used in a default text field:

Apart from that, you can use Python syntax to evaluate text fields.
-wim

I’m aware of this offset but I was thinking of a global offset that one could change and all instances of the text that used that value would change…?
Can you give an example of regex or python evaluation in the text field?
Thanks,
T

Hi Tristan -

You can have that global offset as a document user text and add that to the page number as in this example:

Martin can possibly shed light on the use of regex; there is some information about the use of Python in the help file:

-wim

1 Like

My comment about regex was mainly because I thought you might have tons of files with meaningfully concatenated file names and now you need to extract and join some of them. If that was the case, you could use regex patterns to filter a selection of files.

Thanks, I was able to achieve what I wanted with this:
%<int(DocumentText("var1")) + PageNumber()>%
Excited to save myself some time.

1 Like