0
$\begingroup$

I have this script that allows me to change my text:

import bpy

## create an string with words copied from table
words = '''
txt 1
txt 2
txt 3
txt 4

'''

## split the string and select all except the first and the last because these spaces are empty
words_array = words.split("\n")[1:-1]

## print the array to verify that it is correct. Printed on the system console: "Window > Toogle System Console"
print(words_array)

## initialice an index to extract a word from array
index = 0

## loop through the selected text objects and assign them the corresponding word.
for textObject in bpy.context.selected_objects:
    textObject.data.body = words_array[index]
    index = index + 1

And it works fine as long as I keep each text on a different line,I want to bring the text from an excel sheet, each columns has 2-3 lines of text, is there a way to bring in the text with script keeping the lines as they are in an excel

enter image description here

$\endgroup$
3
  • $\begingroup$ Hi. Please use proper code tags for your code $\endgroup$ Nov 14, 2022 at 22:31
  • $\begingroup$ i might be wrong, but isn't that depending on the column width of excel? so how should Blender know the column width of excel? and even if it would have it - it would have to know the font and the font attributes like character spacing etc $\endgroup$
    – Chris
    Nov 15, 2022 at 7:12
  • $\begingroup$ I think they forced the escaped line wiht ALT + ENTER, I don't know the specifics, maybe this adds a hidden character in the text ? Otherwise you would have to do it differently. All in all I'm a bit on the fence about this question, it is not about blender specifically. $\endgroup$
    – Gorgious
    Nov 15, 2022 at 16:49

0

You must log in to answer this question.

Browse other questions tagged .