# Convert files from console using Blender

I'm trying to import glTF file into Blender and export it as dxf by running a Python script from command line.

I'm able to do this via GUI when I activate both glTF & dxf plugins. I've seen a similar solution for conversion from obj to fbx, which runs fine:

import bpy
bpy.ops.import_scene.obj(filepath="D:\\source.obj")
bpy.ops.export_scene.fbx(filepath="D:\\taget.fbx")


However, glTF and dxf are handled via plugins and I've been unable to modify the code since I'm no Python expert

This is untested, but too much to write in comment.

Would say the gltf addon is default in 2.8 the dxf not. Here is a test script to enable both and set as default and persistent.

If you look at addon info for the two addons in question will note that the folder name in addon folder for each is

"io_export_dxf", "io_scene_gltf2"


this is the key used to enable them using the addon_utils helper method enable, and check if already default and enabled with check

import bpy
if not enabled:

#bpy.ops.import_scene.gltf(filepath="/somepath")
#bpy.ops.export.dxf(filepath="/somefilepath")


Note commented out the operator calls.

See the output in the python console to find and check what properties can be set for operators.

For example export to dxf. Will reflect those in UI panel when manually exporting.

>>> bpy.ops.export.dxf(
dxf()
bpy.ops.export.dxf(filepath="",
projectionThrough='NO',
onlySelected=True,
apply_modifiers=True,
mesh_as='3DFACEs',
entitylayer_from='obj.data.name',
entitycolor_from='default_COLOR',
entityltype_from='CONTINUOUS',
layerName_from='LAYERNAME_DEF',
verbose=False)
Export to the Autocad model format (.dxf)


Note properties listed in long winded operator call above are defaults, and only need to be set when non default (eg filepath)

As mentioned untested.

• Thanks a lot @batFINGER. Worked like a charm. Sadly, I can't upvote your answer here due to lack of reputation – Immugio May 14 at 16:11