ホームメンバー問い合わせ

GPT-4oでCAD図面を書く

By monco
Published in 博士の視点
June 20, 2024
GPT-4oでCAD図面を書く

GPT-4oでCAD図面を書く

サムライアプスのmoncoです。

先日、OpenAIからChatGPTで使えるモデルとしてGPT-4o(フォーオー)がリリースされました。マルチモーダルなモデル、ということで文字でチャットをするだけでなく、画像を入れたりデータを入れたり、様々なモノを入力として扱ってくれるようになりました。

色々と情報を見ていくと、手書きの表をExcel化してくれるという記事を見ました。 そこで思ったのが、もう少し手書きで入力できると楽なものはないのか―。 CADは流石にプロンプトで指示してもなかなか描けないな、と思い、試してみることにしました。 きれいな絵は現在ではAIに指示すれば描ける時代になっていますが、CADの例は見たことがないような気がします。

ネットフェンスの図面を書く

とりあえず公園にあるような網のフェンス(ネットフェンスというらしいです)の図面を書いてみることにしました。構造が簡単そうで、手でも描けそうだからです。

出典:https://www.nfe-kenzai.co.jp/products/fence/snowy-area/super_net_fence.html
出典:https://www.nfe-kenzai.co.jp/products/fence/snowy-area/super_net_fence.html

素人が手書きしてみました。完全なフリーハンドです。寸法とかは適当です。上と下の枠を胴縁(どうぶち)、上と下の胴縁の間に横に走っている針金を番線(ばんせん)と言うそうです。縦の枠は柱、下の方にある四角いのは基礎ブロックです。

IMG 3946 edited

CAD(図面)の一般的なデータとしては「DXFファイル」というのがあり、これをChatGPT出力することを狙います。事前にChatGPTに聞いたところ、DXFファイルを直接出力することはできないが、Pythonのezdxfというライブラリを使うとPythonで図面を記述してDXFファイルを出力できるとのこと。 そこで、上記のフリーハンド図面とともに下記のようなプロンプトを入力して、Pythonコードを出力してもらうことにしました。

これはネットフェンスの図面です。これをezdxfを使ったPythonコードで表現してください。

出力されたコードは下記のとおりです。

import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
width_top_section = 2000 # 2m
width_bottom_left_section = 2000 # 2m
width_bottom_right_section = 1500 # 1.5m
width_right_section = 3000 # 3m
width_bottom_last_section = 500 # 0.5m
post_height = 600 # 60cm
post_width = 300 # 30cm
# Draw the vertical posts
posts_x_coords = [0, 2000, 4000, 5500, 6000]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
# Draw the horizontal bars
bars_y_coords = [1000, 2000, 3000]
for y in bars_y_coords:
msp.add_line((0, y), (6000, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
supports_coords = [(0, 0), (2000, 0), (4000, 0), (5500, 0)]
for x, y in supports_coords:
msp.add_line((x - post_width / 2, y - post_height), (x + post_width / 2, y - post_height), dxfattribs={'layer': 'LINES'})
msp.add_line((x - post_width / 2, y), (x - post_width / 2, y - post_height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + post_width / 2, y), (x + post_width / 2, y - post_height), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence.dxf")

これをPython環境で実行し、出力された net_fence.dxfAutodesk Viewerで読ませた結果です。

Untitled 2

ちょっと微妙ですね。励ましつつ、足りないところを伝えてあげます。

惜しいです。柱やフェンスの上下を支える胴縁に3cmの幅を持たせてください。下胴縁と基礎の上部は5cm離れています。一番右端ははいりません。基礎の上部の線を書いてください。

出力コードです。

import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x - bar_width / 2, 0), (x - bar_width / 2, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width / 2, 0), (x + bar_width / 2, height), dxfattribs={'layer': 'LINES'})
# Draw the horizontal bars with width
bars_y_coords = [0, 1000, 2000, 3000]
for y in bars_y_coords:
msp.add_line((0, y - bar_width / 2), (5500, y - bar_width / 2), dxfattribs={'layer': 'LINES'})
msp.add_line((0, y + bar_width / 2), (5500, y + bar_width / 2), dxfattribs={'layer': 'LINES'})
# Draw the base supports
supports_coords = [0, 2000, 4000, 5500]
for x in supports_coords:
# Base top line
msp.add_line((x - post_width / 2, gap_to_base), (x + post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Left vertical line
msp.add_line((x - post_width / 2, gap_to_base), (x - post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, gap_to_base), (x + post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Bottom line
msp.add_line((x - post_width / 2, gap_to_base - post_height), (x + post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence.dxf")

Untitled 3

それっぽくなりましたが、まだイメージが伝わっていません。

上胴縁と下胴縁にの間に1m間隔にある番線は幅はありません。下胴縁が基礎に埋まっているので、下胴縁と基礎の上面を5cm空けてください。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x - bar_width / 2, 0), (x - bar_width / 2, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width / 2, 0), (x + bar_width / 2, height), dxfattribs={'layer': 'LINES'})
# Draw the horizontal bars with width (top and bottom bars)
bars_y_coords = [0, 3000]
for y in bars_y_coords:
msp.add_line((0, y - bar_width / 2), (5500, y - bar_width / 2), dxfattribs={'layer': 'LINES'})
msp.add_line((0, y + bar_width / 2), (5500, y + bar_width / 2), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
supports_coords = [0, 2000, 4000, 5500]
for x in supports_coords:
# Base top line
msp.add_line((x - post_width / 2, gap_to_base), (x + post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Left vertical line
msp.add_line((x - post_width / 2, gap_to_base), (x - post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, gap_to_base), (x + post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Bottom line
msp.add_line((x - post_width / 2, gap_to_base - post_height), (x + post_width / 2, gap_to_base - post_height), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence.dxf")

Untitled 4

少しずつ直ってはいますが…下の胴縁が基礎ブロックにめり込んでいます。

要求をしっかり伝えます。

画像のようになっています。下部の胴縁が基礎にめり込んでいますので、基礎の上の辺から5cm離したところに下の胴縁が来るようにしてください。また、柱と胴縁が交差する角が離れているので、くっつけてください。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width
msp.add_line((0, gap_to_base + bar_width), (5500, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Bottom line
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence_updated.dxf")

Untitled 5

めり込まなくはなりましたが、基礎ブロックの上の辺が描画されていません。もう少し明確に伝える必要があると思い、改めて図を提示することにしました。

81b5fb66 b0e4 4807 918d a4912f33251f

入力したプロンプト。

これは下胴縁と基礎部分を拡大して書いた図です。下胴縁と基礎が重ならないように、下胴縁の下辺と基礎の上辺の間に5cmの間を取ってほしいのです。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width
msp.add_line((0, gap_to_base + bar_width), (5500, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, gap_to_base), dxfattribs={'layer': 'LINES'})
# Bottom line
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence_updated.dxf")

Untitled 6

変わりませんでした。

実行しましたが、下胴縁の下辺と基礎の上面に5cmの間がありません。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width, 5cm above the base
msp.add_line((0, gap_to_base + bar_width + base_y), (5500, gap_to_base + bar_width + base_y), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base + base_y), (5500, gap_to_base + base_y), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, gap_to_base + base_y), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, gap_to_base + base_y), dxfattribs={'layer': 'LINES'})
# Bottom line
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence_corrected.dxf")

Untitled 7

うまく伝わらないですね…改めて図も含めて伝えます。有効化はわかりませんが、ちょっと怒りを込めます。

d7d0af98 7bde 4eb2 b8e8 76b92fba0bc1

余計ひどくなりました。基礎と下胴縁はこのようにしたいんです。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width, 5cm above the base
msp.add_line((0, gap_to_base + bar_width), (5500, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Top line of base
msp.add_line((x - post_width / 2, 0), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Bottom line of base
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence_corrected.dxf")

Untitled 8

おおお、やっと下胴縁と基礎の間に隙間ができました。気持ちを組んでくれたのでしょうか… ただ、柱の幅がなくなってしまいました。褒めつつ、修正をお願いします。

すごく惜しいです。下胴縁と基礎の部分は完璧です。右端と左端の柱の幅がなくなったので、幅を戻せば完璧です。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width, 5cm above the base
msp.add_line((0, gap_to_base + bar_width), (5500, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Top line of base
msp.add_line((x - post_width / 2, 0), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Bottom line of base
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("net_fence_final.dxf")

Untitled 9

ほぼ完成ですね。右端の柱が上下の胴縁と番線と交差してません。

あと一声です。右端の柱と、胴縁、番線を完全に交差させれば完成です。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the rightmost post completely crossing
msp.add_line((5500, 0), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((5500 + bar_width, 0), (5500 + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width, 5cm above the base
msp.add_line((0, gap_to_base + bar_width), (5500, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500 + bar_width, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Top line of base
msp.add_line((x - post_width / 2, 0), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Bottom line of base
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("mesh_fence_final.dxf")

Untitled 10

もう一声!

番線は交差しました。上部と下部の胴縁も右端の柱と交差させてください。
import ezdxf
# Create a new DXF document
doc = ezdxf.new()
# Add new layers
doc.layers.add("DIMENSIONS")
doc.layers.add("LINES")
# Create a new model space
msp = doc.modelspace()
# Dimensions
height = 3000 # 3m
widths = [2000, 2000, 1500] # section widths
post_height = 600 # 60cm
post_width = 300 # 30cm
bar_width = 30 # 3cm
gap_to_base = 50 # 5cm
base_y = -post_height
# Draw the vertical posts with width
posts_x_coords = [0, 2000, 4000, 5500]
for x in posts_x_coords:
msp.add_line((x, 0), (x, height), dxfattribs={'layer': 'LINES'})
msp.add_line((x + bar_width, 0), (x + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the rightmost post completely crossing
msp.add_line((5500, 0), (5500, height), dxfattribs={'layer': 'LINES'})
msp.add_line((5500 + bar_width, 0), (5500 + bar_width, height), dxfattribs={'layer': 'LINES'})
# Draw the top horizontal bar with width
msp.add_line((0, height), (5500 + bar_width, height), dxfattribs={'layer': 'LINES'})
msp.add_line((0, height - bar_width), (5500 + bar_width, height - bar_width), dxfattribs={'layer': 'LINES'})
# Draw the bottom horizontal bar with width, 5cm above the base
msp.add_line((0, gap_to_base + bar_width), (5500 + bar_width, gap_to_base + bar_width), dxfattribs={'layer': 'LINES'})
msp.add_line((0, gap_to_base), (5500 + bar_width, gap_to_base), dxfattribs={'layer': 'LINES'})
# Draw the intermediate wires without width
intermediate_y_coords = [1000, 2000]
for y in intermediate_y_coords:
msp.add_line((0, y), (5500 + bar_width, y), dxfattribs={'layer': 'LINES'})
# Draw the base supports
for x in posts_x_coords:
# Left vertical line
msp.add_line((x - post_width / 2, base_y), (x - post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Right vertical line
msp.add_line((x + post_width / 2, base_y), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Top line of base
msp.add_line((x - post_width / 2, 0), (x + post_width / 2, 0), dxfattribs={'layer': 'LINES'})
# Bottom line of base
msp.add_line((x - post_width / 2, base_y), (x + post_width / 2, base_y), dxfattribs={'layer': 'LINES'})
# Save the DXF document
doc.saveas("mesh_fence_final.dxf")

Untitled 11

絵のとおりとなりました。ありがとう、ChatGPT…

ちなみに、プロが書いたネットフェンスの図面はこのようなもののようです。ちょっともう少し色々工夫が必要そうです。

出典:https://www.jfe-kenzai-fence.co.jp/products/v-net-fence-5t/
出典:https://www.jfe-kenzai-fence.co.jp/products/v-net-fence-5t/

まとめ

ここでは、手書きの図面を元に、Pythonのコードを経てDXFファイルを生成してみました。 手書きの図面をコンピュータで2D CADとして再現できました。本格的に使うにはまだまだですが、プロンプトの与え方や図をもう少し丁寧に書けば、もっと綺麗な図面を生成できるかもしれません。

それにしてもGPT-4o、すごすぎる…。

これにて御免!


Tags

AIChatGPTテクノロジーGPT-4oCAD

Share

Previous Article
マイナンバーカード×抽出する、ほか(2024年06月20日)
monco

monco

デジタル化 サムライ

Table Of Contents

1
GPT-4oでCAD図面を書く
2
ネットフェンスの図面を書く
3
まとめ

Related Posts

【これだ!】アイデア発想のフレームワークについて
March 06, 2024
© 2024, All Rights Reserved.
Powered By

コンテンツ

補助金・政策博士の視点アイデアの小槌

Social Media