Skip to main content
missrubytoo
Participant
January 11, 2018
Answered

Dynamically Placed Variables

  • January 11, 2018
  • 4 replies
  • 3841 views

I'm trying to figure out if there's a way to dynamically place elements based on the length of a variable text string. I have a few images that I'm creating with variables where there are two text strings centered and stacked. Those are all working perfectly because nothing on the image needs to move in relation to other variable data. The third image I'm working on has a text variable (that varies quite a bit in character length), a graphic element (not a variable) to the right of it, and then another text variable. I'm trying to figure out if there's a way to move the graphic element to the right of the first text variable based on what data is inputted (e.g. if the variable text string is 3 characters the graphic element should be say, 20 px to the right but if the variable text string is 15 characters, the graphic element should still be 20 px to the right - but in a totally different position than the case of the 3 character text string). 

This topic has been closed for replies.
Correct answer JETalmage

If the graphic between the two varialbles must be variable (or something other than text), you can:

  • Create the left text variable as a right-aligned PointType object.
  • Create the right text variable as a left-aligned PointType object.
  • Position the graphic variable between them, spaced as desired.
  • Group the three variables.
  • "Name" the group by selecting it and entering text in the Note field of the Attributes palette. (ex: "Group")

Then record an Action which:

  1. Invokes Next Data Set
  2. Selects Group
  3. Left aligns Group to the left edge of the Artboard
  4. Moves Group rightward the required amount
  5. Deselects

Action_VariablePosition_1of3.PNG

Action_VariablePosition_2of3.PNG

Action_VariablePosition_3of3.PNG

JET

4 replies

JETalmage
JETalmageCorrect answer
Inspiring
January 16, 2018

If the graphic between the two varialbles must be variable (or something other than text), you can:

  • Create the left text variable as a right-aligned PointType object.
  • Create the right text variable as a left-aligned PointType object.
  • Position the graphic variable between them, spaced as desired.
  • Group the three variables.
  • "Name" the group by selecting it and entering text in the Note field of the Attributes palette. (ex: "Group")

Then record an Action which:

  1. Invokes Next Data Set
  2. Selects Group
  3. Left aligns Group to the left edge of the Artboard
  4. Moves Group rightward the required amount
  5. Deselects

Action_VariablePosition_1of3.PNG

Action_VariablePosition_2of3.PNG

Action_VariablePosition_3of3.PNG

JET

missrubytoo
Participant
January 17, 2018

Oh interesting. I tried using an action to align things but didn't get it quite right. Your suggestion might work! Thank you. As to your previous response, the text is in separate variables because different data needs to go into each variable. This is for generating thousands of files so things like adding spaces based on the characters in a variable or trying to combine variables in a spreadsheet would be super time consuming. I'll try the alignment action as you suggest and let you know! Thanks for your help!

redwards_
Inspiring
January 17, 2018

padding data with spaces takes under a minute. (100 to 100,000,000 variables)
You need to start experimenting with workflows to see how things actually behave

JETalmage
Inspiring
January 16, 2018

The reason people are asking you for a more thorough description of the requirements is because the way you've described it so far suggests you could simply do it using regular typography if it's just a vertical bar and there's no reason why the whole string can't be in a single variable:

Cat | Mississippi

Mississippi | Cat

JET

redwards_
Inspiring
January 16, 2018

well if its a predictable 'pattern' aka... a certain number range of possible numbers.. make group, label them by character length (15 is here, 10 is there)

then make some data to import.. have one of the columns be the 'length' .. which would correspond with the group name '10', '15'

Here's an article... you can make 'visibility' of groups/layers controlled by the data... 'turn on this one for this length.. etc)
Data-driven graphics through templates and variables in Illustrator
....
But if what your picture shows .. a generic blue bar ... type '|' ... color it blue then make red text and again pad with spaces.

they can now both appear to move based on the spaces idea from above.

xxxx | Variable

xxxxxxxxxxxxxxxxxxxx | Variable

Other than that I'd recommend taking better pictures of your idea for us to dissect.

Until then experimenting/testing is your best bet

Kurt Gold
Community Expert
Community Expert
January 11, 2018

Which version of Illustrator are you using?

Can you provide a sample .ai file with detailed instructions? Or can you at least post some screenshots that may explain your task?

missrubytoo
Participant
January 11, 2018

I'm using CC 2018

So I'm trying to figure out if there's a way to move the graphic element (in this case the blue bar) and the variable on the right, based on the character length of the text variable on the left which needs to stay left-aligned. So in one data set, I might have both "cat" and "Mississippi" - in the case of "cat" the blue bar and the second variable would need to move left to maintain the distance of the first variable to the blue bar and the second variable to the blue bar but in the case of "Mississippi" everything would have to move a bit to the right. I'm trying to do a batch export of a large number of files, all of which have variables that vary in character length. the character length of the second variable (on the right) doesn't matter because it's also left-aligned and there's nothing to the right of it. Does that make sense?

redwards_
Inspiring
January 12, 2018

Easiest way would be to pre-define a slot length say '30 characters' and just pad you variable (i.e. text 'string' with space characters concatenated with it)

Left = 'Left                         '

Right = '                     Right'

Just make an excel file or something that will pad in the extra spaces

'x' being a 'space'
'xxxxxxxxxxx' (full maximum length of your variables/list items)

put 'cat' in there...

'xxxxCATxxxx'

'CATxxxxxxxx'

'xxxxxxxxCAT'