Hello,
I would like dynamically changing text (multiple lines) to be bounded by rectangles with the appropriate position, width and height. I would like these bounding boxes to follow the GeoText any way they translate, rotate, scale etc.
I start with a tableDAT and use it and a Grid SOPtoChop to feed a GeoText comp (SpecDAT & SpecChop).
For the Rectangle bounding boxes, I use a Geo with a rectange SOP, use instancing with the SOPtoCHOP as positions.
The first problem is that the rectangles are positioned with an offset. I wonder if GeoText and Geo interpret the positions tx, ty, tz from the CHOP differently.
For the diffenrent sizes of the rectangles I use a DAT that calculates the width and height of every line and these values are then used in the Geo instancing for the scale parameters. This seems to work.
ts = op('text_size') # tableDAT to store calculated values
ts.clear(keepFirstRow=True)
text = op('incoming_text').text # the DAT with the lines of text
layout = op('geotext1').layoutText(text) # positions of all letters
first_letters = [] # list to story indices of the first letter of each line of text
index = 0
# fill the list with indices for first letters
for i in range(incoming.numRows):
line = incoming[i, 0].val
first_letters.append(index)
index += len(line)
#
line_index = 0
for i in range(len(layout)):
x = layout[i].origin.x
y = layout[i].origin.y
z = 0
table.appendRow([layout[i].text, x, y, z])
if i in first_letters :
line = op('incoming_text')[line_index,0].val
wh = op('geotext1').evalTextSize(line)
print( '\nidx: ', idx, 'line: ', line, 'i: ', i, 'wh: ', wh, 'pos: ', x, y)
ts.appendRow([line, wh[0], wh[1], x, y, z])
first_letters.pop(0)
line_index += 1
ts.deleteRow(1)
Additionally I tried to calculate the xyz positions of the first letter of each line to use these as positional parameters in the geo, but this gives me totally wrong positions.
Could anyone point me to a way how to achieve this?
thank you
Boris