diff --git a/examples/Step_Down_Carrier_Board-B_Cu.stl b/examples/Step_Down_Carrier_Board-B_Cu.stl index 4121b74..68cf696 100644 Binary files a/examples/Step_Down_Carrier_Board-B_Cu.stl and b/examples/Step_Down_Carrier_Board-B_Cu.stl differ diff --git a/examples/Step_Down_Carrier_Board-B_Mask.stl b/examples/Step_Down_Carrier_Board-B_Mask.stl index 7221b0b..eb66653 100644 Binary files a/examples/Step_Down_Carrier_Board-B_Mask.stl and b/examples/Step_Down_Carrier_Board-B_Mask.stl differ diff --git a/examples/Step_Down_Carrier_Board-F_Silkscreen.stl b/examples/Step_Down_Carrier_Board-F_Silkscreen.stl index da66698..983bf3f 100644 Binary files a/examples/Step_Down_Carrier_Board-F_Silkscreen.stl and b/examples/Step_Down_Carrier_Board-F_Silkscreen.stl differ diff --git a/pcb_to_stl.py b/pcb_to_stl.py index 58d0670..67ae1e1 100644 --- a/pcb_to_stl.py +++ b/pcb_to_stl.py @@ -56,24 +56,29 @@ if bpy.context.selected_objects: print(f"Resizing: {current_width:.2f}mm -> {target_width_mm:.2f}mm (Factor: {scale_factor:.4f})") # Apply Scale to X and Y (Maintain Aspect Ratio) - # We do NOT scale Z because Z is 0 (flat mesh) obj.scale[0] = scale_factor obj.scale[1] = scale_factor - # Freeze the scale transformation so dimensions are real + # Freeze the scale transformation so dimensions are real before adding modifiers bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) else: print("Warning: Object has 0 width, skipping resize.") - # 3. Extrude (Z-Height) - # Now that X/Y are sized correctly, we extrude Z - bpy.ops.object.mode_set(mode='EDIT') - bpy.ops.mesh.select_all(action='SELECT') + # 3. Add Solidify Modifier (Replaces manual extrusion) + print(f"Applying Solidify Modifier: Thickness {thickness_mm}mm") - # Extrude exactly the thickness value - bpy.ops.mesh.extrude_region_move(TRANSFORM_OT_translate={"value":(0, 0, thickness_mm)}) - - bpy.ops.object.mode_set(mode='OBJECT') + # Add the modifier + mod = obj.modifiers.new(name='PCBSolidify', type='SOLIDIFY') + + # Set Modifier Properties + mod.thickness = thickness_mm + mod.use_even_offset = True # "Even Thickness: yes" + mod.use_rim = True # "Fill Rim: ON" + mod.offset = 0 # 0 centers the thickness, 1 extends vertically. + # Use 0 or 1 depending on where you want the origin. + + # Apply the modifier (Bake it into the mesh) + bpy.ops.object.modifier_apply(modifier=mod.name) # --- Step 4: Export STL --- print(f"Exporting to: {output_stl}")