2
$\begingroup$

I am trying to use the Blender Python API, bpy and I would like to import an Autocad DXF file. However, I cannot the find the way to do this properly.

How can I import a DXF file in python script?

or

What lines of python code should I write to import a DXF file?

Thanks in advance

$\endgroup$
1
  • 3
    $\begingroup$ Hello and welcome. Please don't post the same question more than once. If you feel your previous question was incorrectly marked as duplicate, or the linked posts don't adequately address your issue, go back to your previous question and edit by pressing the Edit button below, including information of what you have tried, why it failed and how the duplicates don't address your issue. Once edited the question is automatically queued up for review so it can be reopened. $\endgroup$ Nov 9, 2021 at 16:09

1 Answer 1

2
$\begingroup$

This is quite old and I haven't seen an answer on the site. I've stumbled over this myself, so here is a possible solution (if this is a dupe, please let me know)

First, install the Autocad add-on Go to: Edit > Preferences > Add-ons > type "auto" in the search bar > check the relevant add-ons (install if needed) enter image description here

Afterwards, you will be both able to load .dxf file manually and thru Python API

For manual upload go to: File > Import > AutoCad DXF

enter image description here

Or for the Python API simply

import bpy
bpy.ops.import_scene.dxf(filepath = "path/to/your/file.dxf")
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .