オリジナル
日本語フォーラム
ChatGPT 3.5先生 へ
freecadのマクロを教えて下さい。
直方体のワイヤーフレームを書いて、それをソリッドに変換、4等分したその体積を教えて下さい。
ChatGPT 3.5先生 より
以下抜粋
import FreeCAD as App
import Part
# 直方体を作成
length = 10 # 長さ
width = 5 # 幅
height = 8 # 高さ
box = Part.makeBox(length, width, height)
# ソリッドに変換
solid = box.makeSolid()
# ソリッドを4つに分割
cut_plane = App.Placement(App.Vector(0, 0, 0), App.Rotation(App.Vector(0, 0, 1), 45))
splits = solid.cut(box.copy().Placement.multiply(cut_plane))
# 4つのソリッドの体積を計算
total_volume = 0
for split in splits:
total_volume += split.Volume
# 結果を出力
print("直方体の体積:", solid.Volume)
print("4等分した各体積の合計:", total_volume)
以下のエラーがでました。
<class 'AttributeError'>: 'Part.Solid' object has no attribute 'makeSolid'
つづく
勉強中