1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
| import bpy import os import numpy as np
bpy.ops.mesh.primitive_cube_add() text_obj = bpy.context.object
text_modifier_geometrynodes = text_obj.modifiers.new(type='NODES', name="Geometry Nodes") bpy.ops.node.new_geometry_node_group_assign() node_tree = text_modifier_geometrynodes.node_group
node_tree.nodes.remove(node_tree.nodes.get("Group Input"))
special_characters_node = node_tree.nodes.new(type='FunctionNodeInputSpecialCharacters') special_characters_node.location = (-800, 200)
string_to_curves_nodes = [] for i in range(2): string_to_curves_nodes.append(node_tree.nodes.new(type='GeometryNodeStringToCurves')) string_to_curves_nodes[-1].location = (-400, 350 - 400 * i) string_to_curves_nodes[-1].align_x = "CENTER" string_to_curves_nodes[-1].align_y = "MIDDLE" string_to_curves_nodes[-1].inputs[1].default_value = 2.2 string_to_curves_nodes[0].font = bpy.data.fonts.load(os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(bpy.data.filepath)) , './fonts/Neon_Future.ttf'))) string_to_curves_nodes[1].font = bpy.data.fonts.load(os.path.abspath(os.path.join(os.path.abspath(os.path.dirname(bpy.data.filepath)) , './fonts/Ourland.otf')))
resample_curve_node = node_tree.nodes.new(type='GeometryNodeResampleCurve') resample_curve_node.location = (250, 50)
resample_curve_node.mode = "EVALUATED"
fill_curve_node = node_tree.nodes.new(type='GeometryNodeFillCurve') fill_curve_node.location = (450, 50)
extrude_mesh_node = node_tree.nodes.new(type='GeometryNodeExtrudeMesh') extrude_mesh_node.location = (650, 150)
extrude_mesh_node.inputs[3].default_value = 0.4 extrude_mesh_node.inputs[4].default_value = False
flip_faces_node = node_tree.nodes.new(type='GeometryNodeFlipFaces') flip_faces_node.location = (650, -100)
join_geometry_nodes = [] for i in range(2): join_geometry_nodes.append(node_tree.nodes.new(type='GeometryNodeJoinGeometry')) join_geometry_nodes[0].location = (50, 50) join_geometry_nodes[1].location = (850, 50)
realize_instances_node = node_tree.nodes.new(type='GeometryNodeRealizeInstances') realize_instances_node.location = (1050, 50)
merge_by_distance_node = node_tree.nodes.new(type='GeometryNodeMergeByDistance') merge_by_distance_node.location = (1250, 50)
output_node = node_tree.nodes.get("Group Output") output_node.location = (1450, 50)
string_nodes = [] for i in range(3): string_nodes.append(node_tree.nodes.new(type='FunctionNodeInputString')) string_nodes[-1].location = (-800, -150 * i + 50) string_nodes[0].string = 'Taco' string_nodes[1].string = 'Tuesday!' string_nodes[2].string = 'gigigigigi~'
join_strings_node = node_tree.nodes.new(type='GeometryNodeStringJoin') join_strings_node.location = (-600, 75)
set_position_nodes = [] for i in range(2): set_position_nodes.append(node_tree.nodes.new(type='GeometryNodeSetPosition')) set_position_nodes[-1].location = (-150, -250 * i + 200) set_position_nodes[0].inputs[3].default_value[1] = 2 set_position_nodes[1].inputs[3].default_value[1] = -1
node_tree.links.new(special_characters_node.outputs[0], join_strings_node.inputs[0]) node_tree.links.new(string_nodes[1].outputs[0], join_strings_node.inputs[1]) node_tree.links.new(string_nodes[0].outputs[0], join_strings_node.inputs[1]) node_tree.links.new(string_nodes[2].outputs[0], string_to_curves_nodes[1].inputs[0]) node_tree.links.new(join_strings_node.outputs[0], string_to_curves_nodes[0].inputs[0]) node_tree.links.new(string_to_curves_nodes[0].outputs[0], set_position_nodes[0].inputs[0]) node_tree.links.new(string_to_curves_nodes[1].outputs[0], set_position_nodes[1].inputs[0]) node_tree.links.new(set_position_nodes[0].outputs[0], join_geometry_nodes[0].inputs[0]) node_tree.links.new(set_position_nodes[1].outputs[0], join_geometry_nodes[0].inputs[0]) node_tree.links.new(join_geometry_nodes[0].outputs[0], resample_curve_node.inputs[0]) node_tree.links.new(resample_curve_node.outputs[0], fill_curve_node.inputs[0]) node_tree.links.new(fill_curve_node.outputs[0], extrude_mesh_node.inputs[0]) node_tree.links.new(fill_curve_node.outputs[0], flip_faces_node.inputs[0]) node_tree.links.new(extrude_mesh_node.outputs[0], join_geometry_nodes[1].inputs[0]) node_tree.links.new(flip_faces_node.outputs[0], join_geometry_nodes[1].inputs[0]) node_tree.links.new(join_geometry_nodes[1].outputs[0], realize_instances_node.inputs[0]) node_tree.links.new(realize_instances_node.outputs[0], merge_by_distance_node.inputs[0]) node_tree.links.new(merge_by_distance_node.outputs[0], output_node.inputs[0])
text_modifier_bevel = text_obj.modifiers.new(name="Bevel", type="BEVEL") text_modifier_bevel.width = 0.05 text_modifier_bevel.segments = 5 text_modifier_bevel.use_clamp_overlap = False text_modifier_bevel.harden_normals = True
text_modifier_simple_deform = text_obj.modifiers.new(name="SimpleDeform", type="SIMPLE_DEFORM") text_modifier_simple_deform.deform_method = "BEND" text_modifier_simple_deform.angle = - np.pi / 4 text_modifier_simple_deform.deform_axis = "Z"
|