Can't replace string


(Ampli) #1

Hello, I am trying to remove/replace part of string.

text = “Hello World”
text2 = text.replace(“World”, “All”)

Works like a charm but not this

ob = bpy.context.object
if ob:
for material in ob.material_slots:
mat = material.replace("<bpy_struct, MaterialSlot", “”)
print(mat)

Or can I use another way to get only the material names?

/Ampli

EDIT: Got it…

ob = bpy.context.object
if ob:
for material in ob.material_slots:
print(material.name)

WORKS!