0
$\begingroup$

enter image description hereHow to remove the first and last characters for selected text in Blender with a script?

$\endgroup$
3
  • $\begingroup$ What text? Blender Has a lot of text everywhere. $\endgroup$ Commented Nov 16, 2022 at 14:37
  • $\begingroup$ for me it sounds a bit like a python, but not a Blender question...maybe elaborate a bit more what you mean? Which text do you mean? $\endgroup$
    – Chris
    Commented Nov 16, 2022 at 15:44
  • $\begingroup$ The text object in Blender $\endgroup$ Commented Nov 16, 2022 at 17:57

1 Answer 1

1
$\begingroup$

Text object's text is stored in object.data.body so it's quite easy with Python. Let's say you select all the text objects you want to do that to and want to run a script from the text editor:

import bpy

for o in bpy.context.selected_objects:
    if o.type == 'FONT':
        o.data.body = o.data.body.replace("\"", "")

This removes " by replacing it with an empty string. You could also do exactly what you asked:

import bpy

for o in bpy.context.selected_objects:
    if o.type == 'FONT':
        o.data.body = o.data.body[1:-1] 

See this for info on slicing (the "[1:-1]" part )
And this for more about working with strings

$\endgroup$

You must log in to answer this question.

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