3
$\begingroup$

The idea I want to implement is to have some kind of StringProperty in the UI so the user could enter multiple lines of text into it which then could be used as a text body of the new Text Object. But I can't find any way to do it with the bpy.props.StringProperty. It doesn't recognize Python \n command and I can't see any other Property which would suit this purpose. So is there any way to do it directly through the UI or the only way to get multiple lines of text at once is from the bpy.data.texts?

$\endgroup$

1 Answer 1

5
$\begingroup$

Blender doesn't have a multi-line text/string property at the moment that could be edited in UI panels like other bpy.props. There are some workarounds to render multiline texts from text objects in panels, but I think you want to render a string as a multiline text into a Text object.

You could still use the StringProperty to let the user enter text in a single line and let him mark new lines with \n. The captured string could then be placed in a Text object like so:

some_text = 'line one\nline two\nline three'
bpy.data.texts[0].from_string(some_text)

Also see related questions:

Btw there's a more or less corresponding feature request on Right-Click Select: https://blender.community/c/rightclickselect/S6fbbc/

I'd appreciate the addition of such a multiline text property among the bpy.props.

$\endgroup$

You must log in to answer this question.

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