Skip to main content
deleted 2732 characters in body
Source Link

@X Y, here is the code that's not working. Thank you again!

And one last question, if I wanted to modify one of the Noise modifier's parameters like scale, how would I go about doing that? Since it's an fcurve in the graph editor, I'm not sure how to go about doing that.

def get_fcurves_set(ob):
    if hasattr(ob, "animation_data"):
        animation_data = ob.animation_data
        if hasattr(animation_data, "action"):
            action = animation_data.action
            if hasattr(action, "fcurves"):
                return set(action.fcurves)
    return set()
        
        
def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # Get the object
                bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
                bpy.context.view_layer.objects.active = ob   # Make the cube the active object 
                ob.select_set(True)                          # Select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                #modBend.keyframe_insert("angle",frame=0)                             # add key on frame 0
                
                ob = bpy.context.object
                old_fcurves = get_fcurves_set(ob)
                success = bpy.context.object.keyframe_insert("location", index=0)
                if success:
                    new_fcurves_added = get_fcurves_set(ob) - old_fcurves
                    fc = list(new_fcurves_added)[0]
                    fmd = fc.modifiers.new("NOISE")
                #fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                        
                print(obj.name, ": Added", modBendName)
```

@X Y, here is the code that's not working. Thank you again!

And one last question, if I wanted to modify one of the Noise modifier's parameters like scale, how would I go about doing that? Since it's an fcurve in the graph editor, I'm not sure how to go about doing that.

def get_fcurves_set(ob):
    if hasattr(ob, "animation_data"):
        animation_data = ob.animation_data
        if hasattr(animation_data, "action"):
            action = animation_data.action
            if hasattr(action, "fcurves"):
                return set(action.fcurves)
    return set()
        
        
def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # Get the object
                bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
                bpy.context.view_layer.objects.active = ob   # Make the cube the active object 
                ob.select_set(True)                          # Select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                #modBend.keyframe_insert("angle",frame=0)                             # add key on frame 0
                
                ob = bpy.context.object
                old_fcurves = get_fcurves_set(ob)
                success = bpy.context.object.keyframe_insert("location", index=0)
                if success:
                    new_fcurves_added = get_fcurves_set(ob) - old_fcurves
                    fc = list(new_fcurves_added)[0]
                    fmd = fc.modifiers.new("NOISE")
                #fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                        
                print(obj.name, ": Added", modBendName)
```
appended answer 322255 as supplemental
Source Link

@X Y, here is the code that's not working. Thank you again!

And one last question, if I wanted to modify one of the Noise modifier's parameters like scale, how would I go about doing that? Since it's an fcurve in the graph editor, I'm not sure how to go about doing that.

def get_fcurves_set(ob):
    if hasattr(ob, "animation_data"):
        animation_data = ob.animation_data
        if hasattr(animation_data, "action"):
            action = animation_data.action
            if hasattr(action, "fcurves"):
                return set(action.fcurves)
    return set()
        
        
def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # Get the object
                bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
                bpy.context.view_layer.objects.active = ob   # Make the cube the active object 
                ob.select_set(True)                          # Select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                #modBend.keyframe_insert("angle",frame=0)                             # add key on frame 0
                
                ob = bpy.context.object
                old_fcurves = get_fcurves_set(ob)
                success = bpy.context.object.keyframe_insert("location", index=0)
                if success:
                    new_fcurves_added = get_fcurves_set(ob) - old_fcurves
                    fc = list(new_fcurves_added)[0]
                    fmd = fc.modifiers.new("NOISE")
                #fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                        
                print(obj.name, ": Added", modBendName)
```

@X Y, here is the code that's not working. Thank you again!

And one last question, if I wanted to modify one of the Noise modifier's parameters like scale, how would I go about doing that? Since it's an fcurve in the graph editor, I'm not sure how to go about doing that.

def get_fcurves_set(ob):
    if hasattr(ob, "animation_data"):
        animation_data = ob.animation_data
        if hasattr(animation_data, "action"):
            action = animation_data.action
            if hasattr(action, "fcurves"):
                return set(action.fcurves)
    return set()
        
        
def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # Get the object
                bpy.ops.object.select_all(action='DESELECT') # Deselect all objects
                bpy.context.view_layer.objects.active = ob   # Make the cube the active object 
                ob.select_set(True)                          # Select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                #modBend.keyframe_insert("angle",frame=0)                             # add key on frame 0
                
                ob = bpy.context.object
                old_fcurves = get_fcurves_set(ob)
                success = bpy.context.object.keyframe_insert("location", index=0)
                if success:
                    new_fcurves_added = get_fcurves_set(ob) - old_fcurves
                    fc = list(new_fcurves_added)[0]
                    fmd = fc.modifiers.new("NOISE")
                #fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                        
                print(obj.name, ": Added", modBendName)
```
Became Hot Network Question
added 87 characters in body
Source Link
File "C:\Program Files\Blender Foundation\Blender 4.1\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
    ret = _op_call(self.idname_py(), kw)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Operator bpy.ops.graph.fmodifier_add.poll() failed, context is incorrect

Thank you so much!

Code:

import bpy
import math
    def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # get the object
                bpy.ops.object.select_all(action='DESELECT') # deselect all objects
                bpy.context.view_layer.objects.active = ob   # make the current object the active object 
                ob.select_set(True)                          # select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                modBend.keyframe_insert("angle",frame=0)                             # add key at frame 0
                fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                print(obj.name, ": Added", modBendName)

Error Message

    File "C:\Program Files\Blender Foundation\Blender 4.1\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
        ret = _op_call(self.idname_py(), kw)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: Operator bpy.ops.graph.fmodifier_add.poll() failed, context is incorrect
File "C:\Program Files\Blender Foundation\Blender 4.1\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
    ret = _op_call(self.idname_py(), kw)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Operator bpy.ops.graph.fmodifier_add.poll() failed, context is incorrect

Thank you so much!

def anim_bend(input_name, bend_angle):
    
    obj = bpy.context.active_object
    
    # for each selected object, run this
    for obj in bpy.data.objects:
        if input_name in obj.name:
            
            #select objects individually 
            ob = bpy.context.scene.objects[obj.name]     # get the object
            bpy.ops.object.select_all(action='DESELECT') # deselect all objects
            bpy.context.view_layer.objects.active = ob   # make the current object the active object 
            ob.select_set(True)                          # select the object
            print(obj.name, ": Selected Successfully")
            
            
            modBendName = "SimpleDeform_Bend"
            
            for modifier in obj.modifiers:
                if modifier.name == modBendName:
                    obj.modifiers.remove(obj.modifiers.get(modBendName))
                    print(obj.name, ": DELETED existing", modBendName)
                    
            modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
            modBend.deform_method = 'BEND'                                       # change deform to bend
            modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
            modBend.keyframe_insert("angle",frame=0)                             # add key at frame 0
            fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
            

            print(obj.name, ": Added", modBendName)

Thank you so much!

Code:

import bpy
import math
    def anim_bend(input_name, bend_angle):
        
        obj = bpy.context.active_object
        
        # for each selected object, run this
        for obj in bpy.data.objects:
            if input_name in obj.name:
                
                #select objects individually 
                ob = bpy.context.scene.objects[obj.name]     # get the object
                bpy.ops.object.select_all(action='DESELECT') # deselect all objects
                bpy.context.view_layer.objects.active = ob   # make the current object the active object 
                ob.select_set(True)                          # select the object
                print(obj.name, ": Selected Successfully")
                
                
                modBendName = "SimpleDeform_Bend"
                
                for modifier in obj.modifiers:
                    if modifier.name == modBendName:
                        obj.modifiers.remove(obj.modifiers.get(modBendName))
                        print(obj.name, ": DELETED existing", modBendName)
                        
                modBend = obj.modifiers.new(name= modBendName, type='SIMPLE_DEFORM') # add simple Deform to mesh
                modBend.deform_method = 'BEND'                                       # change deform to bend
                modBend.angle = math.radians(bend_angle)                             # set initial angle before adding animated noise
                modBend.keyframe_insert("angle",frame=0)                             # add key at frame 0
                fNoise = bpy.ops.graph.fmodifier_add(type='NOISE')
                

                print(obj.name, ": Added", modBendName)

Error Message

    File "C:\Program Files\Blender Foundation\Blender 4.1\4.1\scripts\modules\bpy\ops.py", line 109, in __call__
        ret = _op_call(self.idname_py(), kw)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    RuntimeError: Operator bpy.ops.graph.fmodifier_add.poll() failed, context is incorrect
added 308 characters in body
Source Link
Loading
added 1 character in body
Source Link
Loading
edited title
Link
Loading
Source Link
Loading