简体   繁体   中英

Cannot display Mesh in Freecad after exporting Mesh from Python using the ezdxf interface

This is my first time posting here. I am making 3D models of houses using python and I would like to visualise the output using FreeCAD. I found the ezdxf interface ( https://pypi.org/project/ezdxf/ ) which writes to dxf format and I ran the below code (this is one of the examples provided there)

import ezdxf

# 8 corner vertices
cube_vertices = [
    (0, 0, 0),
    (1, 0, 0),
    (1, 1, 0),
    (0, 1, 0),
    (0, 0, 1),
    (1, 0, 1),
    (1, 1, 1),
    (0, 1, 1),
]

# 6 cube faces
cube_faces = [
    [0, 1, 2, 3],
    [4, 5, 6, 7],
    [0, 1, 5, 4],
    [1, 2, 6, 5],
    [3, 2, 6, 7],
    [0, 3, 7, 4]
]

doc = ezdxf.new('R2000')  # MESH requires DXF R2000 or later
msp = doc.modelspace()
mesh = msp.add_mesh()
mesh.dxf.subdivision_levels = 0  # do not subdivide cube, 0 is the default value
with mesh.edit_data() as mesh_data:
    mesh_data.vertices = cube_vertices
    mesh_data.faces = cube_faces

doc.saveas("cube_mesh.dxf")

However, when I open the output in FreeCAD nothing is displayed. Freecad doesn't display mesh Perhaps I am making a simple error. FreeCAD is totally new to me so maybe I have to enable something in FreeCAD before I can see the mesh. I could draw each of the edges by drawing lines between vertices but I would prefer to input vertices and faces and draw the mesh that way. Can anyone tell me what I am doing wrong or another way to do what I am trying to do, export meshes from python and open them in FreeCad. Thanks for you help

我没有使用 FreeCAD 的经验,但是,为了确定问题的根源是文件本身还是仅仅与 FreeCAD 显示网格对象不兼容,您可以尝试使用 Autodesk 的TrueView应用程序打开生成的文件,该应用程序也是免费的将允许您查看(但不能编辑)2D 或 3D DWG、DWF 或 DXF 文件。

The created file can be viewed in TrueView, BricsCAD and Autodesk Online Viewer, BUT you have to zoom to the drawing extends: 在此处输入图片说明

I haven't installed FreeCAD.

Looks like the libraries FreeCAD uses to import DXF don't have a compatible license so they must be activated in FreeCAD manually.

Here's a comprehensive document on how to go about importing DXF files: https://wiki.freecadweb.org/DXF

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM