Skip to content

Commit

Permalink
refactor(material tools): replace bpy.context with context in materia…
Browse files Browse the repository at this point in the history
…l operator
  • Loading branch information
NMC-TBone committed Jan 3, 2025
1 parent 969b4ca commit 2761581
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions i3d_exporter_additionals/tools/material_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,20 +225,20 @@ class I3DEA_OT_i3dio_material(bpy.types.Operator):
def execute(self, context):
selected_list = []

for obj in bpy.context.selected_objects:
for obj in context.selected_objects:
if obj.type == "MESH":
selected_list.append(obj)

for loop_obj in selected_list:
bpy.context.view_layer.objects.active = loop_obj
context.view_layer.objects.active = loop_obj
loop_obj.select_set(state=True, view_layer=None)

for num in range(0, len(loop_obj.material_slots)):
loop_obj.active_material_index = num
material = loop_obj.active_material
shader_loc = context.scene.i3dea.shader_path

if bpy.context.scene.i3dea.shader_box:
if context.scene.i3dea.shader_box:
if shader_loc:
material.i3d_attributes.source = shader_loc

Expand All @@ -247,11 +247,11 @@ def execute(self, context):
f"{loop_obj.active_material.name}")
continue
else:
if bpy.context.scene.i3dea.mask_map_box:
if context.scene.i3dea.mask_map_box:
mask = context.scene.i3dea.mask_map
if mask:
material.i3d_attributes.shader_textures[0].source = mask
if bpy.context.scene.i3dea.dirt_diffuse_box:
if context.scene.i3dea.dirt_diffuse_box:
dirt = context.scene.i3dea.dirt_diffuse
if dirt:
material.i3d_attributes.shader_textures[1].source = dirt
Expand Down

0 comments on commit 2761581

Please sign in to comment.