11
$\begingroup$

For a 3D text object, especially with many many characters in it, how can I place the cursor to the right position in order to edit the text around it?

Here is an example to show what I mean:

enter image description here

$\endgroup$

5 Answers 5

16
$\begingroup$

Here is two methods to edit the text object in the text editor :

1- Link the object text to the text file :

enter image description here

2- Convert text object to a file, then back from a file to an object :

enter image description here


1- For the first method, run this script once and select your text object to see the live update.

import bpy

#this is one way link ( object to text file )
def link_object_to_text(context):
    obj = bpy.context.active_object
    if obj.type == 'FONT':
       if None == bpy.data.texts.get(obj.name):
          bpy.data.texts.new(name = obj.name)  
          bpy.data.texts[obj.name].write(obj.data.body)      
       text_file = bpy.data.texts[obj.name]
       obj.data.body = text_file.as_string()

bpy.app.handlers.scene_update_pre.append(link_object_to_text)

2- For conversion run the following script once

  • you will find it in 3D_View -> Object -> Convert text
  • OR type Convert Text Object in the Space menu

.

import bpy
from bpy.types import Operator  
from bpy.props import *  

def object_to_text():
    obj = bpy.context.active_object
    if obj.type == 'FONT':
       if None == bpy.data.texts.get(obj.name):
          bpy.data.texts.new(name = obj.name)

       text_file = bpy.data.texts[obj.name]
       text_file.clear()
       text = obj.data.body
       text_file.write(text)


def object_from_text():
    obj = bpy.context.active_object
    if obj.type == 'FONT':
       if None == bpy.data.texts.get(obj.name):
          bpy.data.texts.new(name = obj.name)

       text_file = bpy.data.texts[obj.name]
       #clear text_obj
       obj.data.body = text_file.as_string()

class   text_object(Operator):  

    """text file from&to text object"""        
    bl_idname = "object.from_to_text"  
    bl_label = "convert text object"     
    bl_options = {'REGISTER', 'UNDO'}    

    #parameters and variables
    convert = EnumProperty(
                name="Convert",
                description="Choose conversion",
                items=(('T2F', "object to file ", "convert text object to text file"),
                       ('F2T', "file  to object", "convert text file to text object")),
                default='T2F',
                )

    def execute(self, context): 
        if self.convert == 'T2F':
            object_to_text()
        else:
            object_from_text()

        self.report({'INFO'},"Conversion is Done")
        return {'FINISHED'}

    #get inputs 
    def invoke(self, context, event):
            wm = context.window_manager
            return wm.invoke_props_dialog(self)

def addObject(self, context): 
    self.layout.operator(
    text_object.bl_idname,
    text = text_object.bl_label,
    icon = 'OUTLINER_DATA_FONT')

def register():
    bpy.utils.register_class(text_object)      
    bpy.types.VIEW3D_MT_object.append(addObject)

def unregister(): 
    bpy.types.VIEW3D_MT_object.remove(addObject)
    bpy.utils.unregister_class(text_object)

if __name__ == "__main__":  
    register()
$\endgroup$
3
  • $\begingroup$ The solution very nice for now. Man, you really should make them as an addon to share. :) BTW, When accidentally run script Two twice, the menu will also be created twice. Anyway to solve this? $\endgroup$ Commented Mar 7, 2015 at 2:34
  • $\begingroup$ @LeonCheung thanks , and for the menu i have no idea for now ! I'll see if i can find something in the tomorrow $\endgroup$
    – Chebhou
    Commented Mar 7, 2015 at 2:39
  • $\begingroup$ Script two is an addon, best to disable/enable it in prefs. To work better running from text block add unregister() before register() after if at the end. $\endgroup$
    – sambler
    Commented Mar 7, 2015 at 7:15
7
$\begingroup$

You can just type what you want in the text editor and then convert it to a text.and it is so easy to do just toggle to the edit panel and press convert to 3d text and choose what you want.you can also use an original text for this.enter image description here Have fun.

$\endgroup$
1
  • $\begingroup$ Yes, it works, though I think it is a one way trip. Each time I need to edit something, I need to recreate as a new object and delete the last one. Anyway, it seems to be something about workflow. $\endgroup$ Commented Mar 7, 2015 at 2:41
6
$\begingroup$

While I would recommend using the text editor to edit large amounts of text, it really doesn't take too long to get around with just the arrow keys, at least in a situation like your example:

enter image description here

Using ⎈ Ctrl← Left arrow and ⎈ Ctrl→ Right arrow you can jump between spaces, allowing you to travel much faster horizontally. Home and End are also useful.

$\endgroup$
3
$\begingroup$

So far as I can see, there is no faster way than using the arrow keys and moving to the correct position. Unless you're writing a small novel, you should be fine with this. Once you use the arrow keys even once, you can use the options found in the tool bar to jump to next page, previous line ect. and then hone in on the particular place normally.

enter image description here

$\endgroup$
0
0
$\begingroup$

PgUp and PgDn function nowadays.

$\endgroup$
1
  • $\begingroup$ The original question asked for placing the cursor at a certain position in a text, using Page Up and Page Down will only make you skip a couple of lines instead of having to go through each line like with the Up or Down Arrow. It goes a bit faster but isn't really adding much of a solution to the already existing answers: it's still just moving through the text instead of placing the cursor. $\endgroup$ Commented May 25, 2022 at 9:39

You must log in to answer this question.

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