Skip to content

Commit

Permalink
fix: use more reliable collection objects link call for operators cre…
Browse files Browse the repository at this point in the history
…ating single vertex objects
  • Loading branch information
tristan-hm committed Jan 30, 2022
1 parent 3cf72cb commit 58d433a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@
def add_single_vertex_object(cls, context, name):
mesh = bpy.data.meshes.new("ND — " + name)
obj = bpy.data.objects.new("ND — " + name, mesh)
bpy.data.collections[context.collection.name].objects.link(obj)

bpy.context.collection.objects.link(obj)

bm = bmesh.new()
bm.verts.new()
bm.to_mesh(mesh)
bm.free()

obj.select_set(True)

context.view_layer.objects.active = obj

bpy.ops.object.shade_smooth()
obj.data.use_auto_smooth = True
obj.data.auto_smooth_angle = radians(30)
Expand Down

0 comments on commit 58d433a

Please sign in to comment.