Results 1 to 2 of 2
  1. #1

    Script running only on Active object, not entire selection?

    I am trying to make a script to Clear Custom Split Normals on all the objects I have selected. I have copied code from other scripts that run a command on all selected objects. However, this only seems to work on the Active Object, not the rest of the selection. Anyone know why?
    Code:
    import bpy
    
    selected_objects = bpy.context.selected_objects
    
    for selected_object in selected_objects:
        bpy.ops.mesh.customdata_custom_splitnormals_clear()
    Non-Photorealistic Rendering and basic character tutorials:
    http://www.aversionofreality.com/



  2. #2
    Member
    Join Date
    Sep 2015
    Location
    Canada
    Posts
    188
    bpy.ops.blahblah does not necessarily share all its characteristic with a different bpy.ops.brahbrah

    Every bpy.ops.blah works differently. Most of them only work on the active object. Some of them work on multiple objects.

    If you want such "active-only" operator to work on multiple objects, you need to set scene's active object target to the object in your selections for that specific loop.

    Code:
    for obj in selected_objects:
        bpy.context.scene.objects.active = obj
        bpy.ops.mesh.customdata_custom_splitnormals_clear()
    Basically, for each loop, you change the active object in the scene, and then execute the bpy.ops.whatever.

    Typical Macro.



Posting Permissions

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