Skip to content

Commit

Permalink
better empty-at function
Browse files Browse the repository at this point in the history
  • Loading branch information
Pullusb committed May 16, 2024
1 parent 3694c86 commit 0542500
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions snippets/bpy/create_empty_at.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
def empty_at(pos, type='PLAIN_AXES', size=1):
def empty_at(pos, name='Empty', type='PLAIN_AXES', size=1.0, link=True):
'''
Create an empty at given Vector3 position.
Optional type (default 'PLAIN_AXES') in ,'ARROWS','SINGLE_ARROW','CIRCLE','CUBE','SPHERE','CONE','IMAGE'
default size is 1.0
pos (Vector3): position
name (str, default Empty): name of the empty object
type (str, default 'PLAIN_AXES'): options in 'PLAIN_AXES','ARROWS','SINGLE_ARROW','CIRCLE','CUBE','SPHERE','CONE','IMAGE'
size (int, default 1.0): Size of the empty
link (Bool,default True): Link to active collection
i.e : empty_at((0,0,1), 'ARROWS', 2) creates "Empty" at Z+1, of type gyzmo and size 2
'''

mire = bpy.data.objects.new( "mire_empty", None )
bpy.context.collection.objects.link(mire)
mire = bpy.data.objects.new(name, None)
if link:
bpy.context.collection.objects.link(mire)
mire.empty_display_type = type
mire.empty_display_size = size
mire.location = pos
return mire

#exemple : create an empty at Z+1, of type gyzmo and size 2
empty_at((0,0,1), 'ARROWS', 2)
return mire

0 comments on commit 0542500

Please sign in to comment.