1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

2Dデータ(DXF)に適当な高さ情報を与えて3Dデータ(STL)を出力

Last updated at Posted at 2019-12-11

open3dとdxfgrabberを使えばよい.

dxf2stl.py
import open3d as o3d
import dxfgrabber

# DXFを読み込み
dxf = dxfgrabber.readfile("test.dxf")
# 実線の円だけ選択
c_cirs = [e for e in dxf.entities if e.dxftype == 'CIRCLE' and e.linetype == 'CONTINUOUS']

# 立体化
mesh = None
H = 50.0 # 円筒の高さ
Z = 0.0  # 円筒を並べるZ値
for c in c_cirs:
    m = o3d.geometry.TriangleMesh.create_cylinder(radius=c.radius, height=H)
    m.translate([c.center[0], c.center[1], Z])
    if mesh is None:
        mesh = m
    else:
        mesh += m
mesh.compute_vertex_normals()

# STLで出力
o3d.io.write_triangle_mesh("sample.stl", mesh)

色とかレイヤー毎に高さ決めたDXF描いて,自動で立体化したい.

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?