import bpy import abc3d from abc3d import butils from abc3d.common import Font def get_text_properties_by_mom(mom): scene = bpy.context.scene abc3d_data = scene.abc3d_data for text_properties in abc3d_data.available_texts: if mom == text_properties.text_object: return text_properties return None def isolate_objects(objects): for area in bpy.context.window.screen.areas: if area.type == "VIEW_3D": with bpy.context.temp_override( selected_objects=list(objects), area=area, refgion=[region for region in area.regions if region.type == "WINDOW"][ 0 ], screen=bpy.context.window.screen, ): # bpy.ops.view3d.view_selected() bpy.ops.view3d.localview(frame_selected=True) break def main(): # create a curve bpy.ops.curve.primitive_bezier_curve_add( radius=1, enter_editmode=False, align="WORLD", location=(0, 0, 0), scale=(1, 1, 1), ) # new curve is active object mom = bpy.context.active_object # make sure print(f"MOM: {mom.name}") fonts = Font.get_loaded_fonts_and_faces() if len(fonts) == 0: print("no fonts! what?") return font_name = fonts[0][0] face_name = fonts[0][1] font = f"{font_name} {face_name}" isolate_objects([mom]) bpy.ops.abc3d.placetext( font_name=font_name, face_name=face_name, font=font, text="SOMETHING SOMETHING BROKEN ARMS", letter_spacing=0, font_size=1, offset=0, translation=(0, 0, 0), orientation=(1.5708, 0, 0), ) def change_text(font_name="", face_name="", text=""): print(f"change_text to '{text}'") text_properties = get_text_properties_by_mom(mom) if font_name != "": text_properties["font_name"] = font_name if face_name != "": text_properties["face_name"] = face_name if text != "": text_properties.text = text else: text_properties.text = text_properties.text return None def unload(glyph_id): print(f"unload glyph '{glyph_id}'") butils.unload_unused_glyph(font_name, face_name, glyph_id) return None def unload_all(): print(f"unload glyph all unused glyphs") butils.unload_unused_glyphs() return None bpy.app.timers.register(lambda: change_text(text="SOMETHING"), first_interval=0) bpy.app.timers.register(lambda: change_text(text="LOLSS"), first_interval=2) bpy.app.timers.register(lambda: change_text(text="LOLAA"), first_interval=3) bpy.app.timers.register(lambda: change_text(text="WHAT"), first_interval=4) bpy.app.timers.register(lambda: change_text(text="LOL"), first_interval=5) bpy.app.timers.register(lambda: unload("A"), first_interval=10) bpy.app.timers.register(lambda: unload_all(), first_interval=12) bpy.app.timers.register(lambda: change_text(text="LOLM"), first_interval=16) bpy.app.timers.register(lambda: change_text(text="ZHE END"), first_interval=20) bpy.app.timers.register( lambda: change_text(font_name="NM_Origin", face_name="Tender"), first_interval=30, ) bpy.app.timers.register(lambda: unload_all(), first_interval=42) main()