AIモデリング04:歯ブラシスタンド
AIモデリングのサンプルです。
# モデル4: 歯ブラシスタンド(4本用)
# 長円形の中空ボディ。天板に歯ブラシを差す穴、床に水抜き穴、
# 底面に排水溝を切って、垂れた水が溜まらないようにする。
@param 80..140 desc:"幅 (mm)"
body_w = 100
@param 36..60 desc:"奥行 (mm)"
body_d = 45
@param 60..120 desc:"高さ (mm)"
body_h = 90
@param 2..4 step:0.5 desc:"側壁の厚み (mm)"
wall_t = 3
@param 3..6 desc:"天板の厚み (mm)"
top_t = 4
@param 3..6 desc:"床の厚み (mm)"
bot_t = 4
@param 2..8 desc:"歯ブラシの本数"
n = 4
@param 5..9 step:0.5 desc:"歯ブラシ穴の半径 (mm)"
brush_r = 7
@param 16..30 desc:"穴の間隔 (mm)"
brush_pitch = 22
@param 1.5..3 step:0.5 desc:"水抜き穴の半径 (mm)"
drain_r = 2.5
$corner = body_d / 2 - 0.5
$xs = [($i - (n - 1) / 2) * brush_pitch for $i in range(n)]
$body = box body_w body_d body_h
| floor
| edges "=Z" | fillet $corner
| edges ">Z" | fillet 2
# 内部の空洞(天板と床を残す)
$cavity = box (body_w - wall_t * 2) (body_d - wall_t * 2) (body_h - top_t - bot_t)
| floor
| edges "=Z" | fillet ($corner - wall_t)
| translate 0 0 bot_t
# 天板の穴(天板だけを貫通)
$brush_holes = union [cylinder brush_r (top_t + 2) | floor | translate $x 0 (body_h - top_t - 1) for $x in $xs]
# 床の水抜き穴(各歯ブラシの真下)
$drains = union [cylinder drain_r (bot_t + 2) | floor | translate $x 0 -1 for $x in $xs]
# 底面の排水溝(X方向に1本、水抜き穴を横切って両端に抜ける)
$groove = box (body_w + 2) 6 2 | floor
$body - $cavity - $brush_holes - $drains - $groove