So I have 10 txt objects, named 1-10 accordingly, is there a way to insert smth in the python console to change them from "txt" to these names that I have on the left part of the screenshot?
1 Answer
$\begingroup$
$\endgroup$
1
with python its ease. Firs select the cells on the table and copy them.
then with this code
import bpy
## create an string with words copied from table
words = '''
word A
word B
word C
word D
word E
word F
word G
word H
word I
word J
'''
## 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
-
$\begingroup$ Thank you, this is very helpful!!! $\endgroup$ Commented Sep 29, 2022 at 17:31