0
$\begingroup$

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 theenter image description here screenshot?

$\endgroup$
1
  • $\begingroup$ Are you sure you mean the left part…?😎💁🏻‍♂️ $\endgroup$
    – Chris
    Sep 29, 2022 at 15:40

1 Answer 1

0
$\begingroup$

with python its ease. Firs select the cells on the table and copy them.

enter image description here

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
    

and with the selected objects we have the result code to assing words to text objects

$\endgroup$
1
  • $\begingroup$ Thank you, this is very helpful!!! $\endgroup$ Sep 29, 2022 at 17:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .