[Python] How to engrave custom text on a curved surface (eyeglass temple) using Python in...

Discussão em 'Python' iniciado por Stack, Maio 8, 2025.

  1. Stack

    Stack Membro Participativo

    I'm creating a Blender add-on that automatically engraves custom text (like a name) on the side of an eyeglass temple (imported as an STL). The temple mesh is slightly curved and also contains a pre-existing embossed text which I want to override with my own engraving.

    I import the STL temple (right_temple.stl) and convert it to a mesh and I voxel remesh it to simplify topology and remove the watermark. I create a Text object, extrude it, convert to mesh, and apply a shrinkwrap modifier to hug the curved surface and then apply a Boolean (Difference) modifier using the text as the cutter.

    Goal:


    • Add custom text (e.g., “Nisha”) to the temple.


    • The text should be cleanly engraved (using boolean difference).


    • I should be able to control its position via offset sliders.


    • It should replace the existing watermark visually if possible.

    Even though the existing watermark disappears after remeshing, my custom text does not engrave properly:


    • Sometimes it does nothing.


    • Sometimes it produces smudges or artifacts.


    • No visible difference is seen in most cases even though modifiers are applied.

      #Voxel remesh
      rem = temple.modifiers.new("EngraveRemesh", 'REMESH') rem.mode = 'VOXEL' rem.voxel_size = 0.5 bpy.ops.object.modifier_apply(modifier=rem.name)

      #Create text object
      bpy.ops.object.text_add(location=temple.location, rotation=(math.pi/2, 0, 0)) cutter = bpy.context.object cutter.data.body = "Nisha" cutter.data.size = 0.4 cutter.data.extrude = temple.dimensions.y * 1.2 bpy.ops.object.convert(target='MESH')

      #Shrinkwrap
      sw = cutter.modifiers.new("Shrink", 'SHRINKWRAP') sw.target = temple sw.wrap_method = 'NEAREST_SURFACEPOINT' bpy.ops.object.modifier_apply(modifier=sw.name)

      #Boolean
      boolmod = temple.modifiers.new("Engrave", 'BOOLEAN') boolmod.operation = 'DIFFERENCE' boolmod.object = cutter boolmod.solver = 'EXACT' bpy.ops.object.modifier_apply(modifier=boolmod.name)

    What I want help with:


    • Why isn’t the boolean engraving working on the curved surface after remesh?


    • Is there a better way to “embed” custom text onto a curved mesh like this?


    • Should I be projecting the text differently? Is shrinkwrap the wrong approach here?

    Additional Info:


    • Blender 3.0+


    • The temple is a solid mesh.


    • I want to automate this process via Python scripting.

    Continue reading...

Compartilhe esta Página