I have created an object programmatically and want to add a modifier to it too, programmatically. Here is my current code
import bpy
# make mesh
vertices = [(0, 0, 0),(0, 1, 0)]
edges = [[0,1]]
faces = []
obj_name="hello"
new_mesh = bpy.data.meshes.new('new_mesh')
new_mesh.from_pydata(vertices, edges, faces)
new_mesh.update()
# make object from mesh
new_object = bpy.data.objects.new(obj_name, new_mesh)
# make collection
# add object to scene collection
new_object.modifier_add(type='SCREW')
new_collection = bpy.data.collections.new('new_collection')
bpy.context.scene.collection.children.link(new_collection)
new_collection.objects.link(new_object)
This returns an error:
AttributeError: 'Object' object has no attribute 'modifier_add'
How would I go about fixing this?