Results 1 to 1 of 1

Thread: Can't replace string

  1. #1

    Can't replace string

    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!
    Last edited by Ampli; 11-Jan-17 at 15:13.



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •