mesh_outline_projection #1
1 changed files with 26 additions and 27 deletions
|
|
@ -386,22 +386,6 @@ def project_outline_to_mesh(context, source_obj, target_obj, outline_edges):
|
||||||
|
|
||||||
print(f" Created curve with {len(unique_edges_normalized)} splines")
|
print(f" Created curve with {len(unique_edges_normalized)} splines")
|
||||||
|
|
||||||
# Set view to top orthographic
|
|
||||||
original_view_data = None
|
|
||||||
for area in context.screen.areas:
|
|
||||||
if area.type == 'VIEW_3D':
|
|
||||||
for space in area.spaces:
|
|
||||||
if space.type == 'VIEW_3D':
|
|
||||||
from mathutils import Quaternion
|
|
||||||
original_view_data = {
|
|
||||||
'rotation': space.region_3d.view_rotation.copy(),
|
|
||||||
'perspective': space.region_3d.view_perspective,
|
|
||||||
'distance': space.region_3d.view_distance
|
|
||||||
}
|
|
||||||
space.region_3d.view_rotation = Quaternion((1.0, 0.0, 0.0, 0.0))
|
|
||||||
space.region_3d.view_perspective = 'ORTHO'
|
|
||||||
break
|
|
||||||
|
|
||||||
# Switch back to object mode to select objects
|
# Switch back to object mode to select objects
|
||||||
bpy.ops.object.mode_set(mode='OBJECT')
|
bpy.ops.object.mode_set(mode='OBJECT')
|
||||||
|
|
||||||
|
|
@ -421,17 +405,6 @@ def project_outline_to_mesh(context, source_obj, target_obj, outline_edges):
|
||||||
print(f" Running knife_project...")
|
print(f" Running knife_project...")
|
||||||
bpy.ops.mesh.knife_project(cut_through=False)
|
bpy.ops.mesh.knife_project(cut_through=False)
|
||||||
|
|
||||||
# Restore view
|
|
||||||
if original_view_data:
|
|
||||||
for area in context.screen.areas:
|
|
||||||
if area.type == 'VIEW_3D':
|
|
||||||
for space in area.spaces:
|
|
||||||
if space.type == 'VIEW_3D':
|
|
||||||
space.region_3d.view_rotation = original_view_data['rotation']
|
|
||||||
space.region_3d.view_perspective = original_view_data['perspective']
|
|
||||||
space.region_3d.view_distance = original_view_data['distance']
|
|
||||||
break
|
|
||||||
|
|
||||||
# Get bmesh for material assignment
|
# Get bmesh for material assignment
|
||||||
bm = bmesh.from_edit_mesh(target_obj.data)
|
bm = bmesh.from_edit_mesh(target_obj.data)
|
||||||
bm.faces.ensure_lookup_table()
|
bm.faces.ensure_lookup_table()
|
||||||
|
|
@ -555,6 +528,32 @@ class MESH_OT_outline_project(bpy.types.Operator):
|
||||||
original_mode = context.mode
|
original_mode = context.mode
|
||||||
print(f"Original mode: {original_mode}")
|
print(f"Original mode: {original_mode}")
|
||||||
|
|
||||||
|
# RESET TARGET MATERIALS ONCE (not per source object)
|
||||||
|
print(f"\nResetting target materials...")
|
||||||
|
print(f"Target currently has {len(target_obj.material_slots)} material slot(s)")
|
||||||
|
|
||||||
|
if len(target_obj.material_slots) > 0:
|
||||||
|
first_material = target_obj.material_slots[0].material
|
||||||
|
print(f"First material: {first_material.name if first_material else 'None'}")
|
||||||
|
|
||||||
|
# Apply first material to all faces
|
||||||
|
for poly in target_obj.data.polygons:
|
||||||
|
poly.material_index = 0
|
||||||
|
|
||||||
|
print(f"✓ Applied first material to all {len(target_obj.data.polygons)} faces")
|
||||||
|
|
||||||
|
# Remove all material slots except the first one
|
||||||
|
slots_removed = 0
|
||||||
|
while len(target_obj.material_slots) > 1:
|
||||||
|
target_obj.data.materials.pop(index=1)
|
||||||
|
slots_removed += 1
|
||||||
|
|
||||||
|
if slots_removed > 0:
|
||||||
|
print(f"✓ Removed {slots_removed} material slot(s)")
|
||||||
|
print(f"Target now has {len(target_obj.material_slots)} material slot(s)")
|
||||||
|
else:
|
||||||
|
print(f"WARNING: Target has no materials!")
|
||||||
|
|
||||||
total_verts = 0
|
total_verts = 0
|
||||||
|
|
||||||
for source_obj in source_objects:
|
for source_obj in source_objects:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue