# Importing Objects as Empties

That may sound weird, but I want to import all the objects from an .OBJ file as dummies centered where the object's center would be for a little experiment involving game modding. I have no experience with scripting, so I'm asking if it'd be hard to make a script that executes the operations I just described.

Use the importer provided

Would simply import with the provided importer then replace each with an empty.

Import the obj file. Add an empty with the same transform as each imported object. Remove the originals. (Note doesn't keep parenting)

Modify the filepath to where your obj file is on your computer.

import bpy

context = bpy.context

# some path to your obj file
filepath = "/home/batfinger/Desktop/xxxx.obj"

# import it
bpy.ops.import_scene.obj(
filepath=filepath
)

# the imported objects.
imported_objs = context.selected_objects

# add an empty for each imported object
for o in imported_objs:
mt = context.object
mt.name = o.name
mt.matrix_world = o.matrix_world

# delete imported objects
bpy.ops.object.delete(
{"selected_objects" : imported_objs}
)


For starting blender-python-programming it can be helpfull to check out the info tab and copy out the listed commands to your script.

here is the script you want, wich keeps the original objects name. Import your objects by hand, select the ones you want to empty out and run script from text editor.

comments are marked with #, so you can understand whats going on. This way you could easily create other macros as well.

works only on 2.8

#import blender namespace
import bpy
#get all selected objects
selection_names = bpy.context.selected_objects

#loop trough all "selection_names"
for i in selection_names:
#for every object "i":
#set active object as "i"
bpy.context.view_layer.objects.active = i

#go to edit mode of "i"
bpy.ops.object.editmode_toggle()
#select all
bpy.ops.mesh.select_all(action='SELECT')
#delete all verts
bpy.ops.mesh.delete(type='VERT')
#go back to object mode
bpy.ops.object.editmode_toggle()
#repeat for next object in "selection_names" till none left