import bpy
from bpy.types import (Panel, Operator)
from bpy.utils import register_class, unregister_class
from bpy.props import (StringProperty,BoolProperty,IntProperty,FloatProperty,EnumProperty)
class RANOperator(bpy.types.Operator):
"""Replaces the Texture"""
bl_idname = "cobject.cs1"
bl_label = "Converter"
def execute(self, context):
for i in bpy.data.images:
i.filepath = i.filepath.replace('.dds', '.png')
return {'FINISHED'}
class COS(bpy.types.Panel):
bl_label = "Replace Texture(s)"
bl_idname = "cobject_PT_"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "Tool"
def draw(self, context):
layout = self.layout
obj = context.object
row = layout.row()
row.operator(RANOperator.bl_idname, text = "Replace", icon = "UV_SYNC_SELECT")
This is my code. And this is the resultant panel. However, whenever I click "Replace" Nothing happens
p.s. I have registered both classes.
additionally, I want to have an input text field or Checkboxes so that I can replace hard-coded values, to input strings like .png .dds .tga