建築でコンピュータ、する?
2025年1月20日(月) 04:28 JST
昨年に引き続き、本年度もGDL教科書を用いて講習を行い、課題を進めていきます。本ページでは、課題とその解答例を載せていきます。例年と重複するところもありますので、GDLに興味のある方は過去のページもご覧ください。
第1回目の講習では、基本的な図形の作成と座標変換についてのコマンドを扱いました。今回は座標変換に関して「Work desk」を、回転変換に関して「Wall clock」を課題としました。
!!部材の寸法 tenban_w = 1.800 !天板:幅 tenban_d = 0.900 !天板:奥行 tenban_h = 0.030 !天板:高さ kiban_w = 1.500 !基板:幅 kiban_d = 0.880 !基板:奥行 kiban_h = 0.030 !基板:高さ ashi_w = 0.060 !脚:幅 ashi_d = 0.060 !脚:奥行 ashi_h = 0.720 !脚:高さ hari_w = 0.060 !梁:幅 hari_d = 0.880 !梁:奥行 hari_h = 0.050 !梁:高さ nuki_l_w = 1.160 !貫(長手):幅 nuki_l_d = 0.030 !貫(長手):奥行 nuki_l_h = 0.060 !貫(長手):高さ nuki_m_w = 1.130 !貫(短手):幅 nuki_m_d = 0.030 !貫(短手):奥行 nuki_m_h = 0.060 !貫(短手):高さ nuki_s_w = 0.030 !貫(中):幅 nuki_s_d = 0.670 !貫(中):奥行 nuki_s_h = 0.060 !貫(中):高さ !脚の位置 BLOCK ashi_w, ashi_d, ashi_h ADDX nuki_m_w + ashi_w BLOCK ashi_w, ashi_d, ashi_h ADDY nuki_s_d + ashi_d BLOCK ashi_w, ashi_d, ashi_h DEL TOP ADDY nuki_s_d + ashi_d BLOCK ashi_w, ashi_d, ashi_h DEL TOP !貫の位置 ADDZ(ashi_h - nuki_m_h) / 2 ADDX ashi_w ADDY(ashi_d - nuki_m_d) / 2 BLOCK nuki_m_w, nuki_m_d, nuki_m_h DEL 1 ADDY ashi_d + nuki_s_d + (ashi_d - nuki_m_d) / 2 BLOCK nuki_m_w, nuki_m_d, nuki_m_h DEL 2 ADDX(ashi_w - nuki_s_w) / 2 + nuki_s_w ADDY ashi_d + (nuki_s_d - nuki_l_d) / 2 BLOCK nuki_l_w, nuki_l_d, nuki_l_h DEL 2 ADDY ashi_d ADDX(ashi_w - nuki_s_w) / 2 BLOCK nuki_s_w, nuki_s_d, nuki_s_h DEL 1 ADDX ashi_w + nuki_m_w + (ashi_w - nuki_s_w) / 2 BLOCK nuki_s_w, nuki_s_d, nuki_s_h DEL TOP !梁の位置 ADDY(ashi_d * 2 + nuki_s_d - hari_d) / 2 ADDZ ashi_h BLOCK hari_w, hari_d, hari_h ADDX ashi_w + nuki_m_w BLOCK hari_w, hari_d, hari_h DEL 1 !基板、天板の位置 ADDZ hari_h ADDX(ashi_w * 2 + nuki_m_w - kiban_w) / 2 BLOCK kiban_w, kiban_d, kiban_h ADDZ kiban_h ADDX(kiban_w - tenban_w) / 2 BLOCK tenban_w, tenban_d, tenban_h DEL TOP
次に回転変換を用いた例として簡単な時計をモデリングしました。時計の針と文字盤は薄いブロックを用いています。その際にモデルを生成する位置が、CYLINDは中心を原点とし、BLOCKは一頂点を原点にするので、座標変換して位置を合わせる必要があります。RNDでランダムな角度に時計の針を回転されています。 また今後の回で詳しく解説しますが、FOR文を使うことで繰り返しの動作を簡潔に書くことができ、「MATERIAL」を用いれば生成されるモデルの材質を変えることができます。
!!時計 !!部材の寸法 body_h1 = 0.010 !!文字盤の厚み body_r1 = 0.150 !!文字盤の半径 body_h2 = 0.030 !!機械部の厚み body_r2 = 0.140 !!機械部の半径 !!文字盤の位置、大きさ num_pos = 0.110 !!軸心からの距離 num_thick = 0.001 !!文字盤の厚み num_length = 0.020 !!文字盤の長さ num_width = 0.0075 !!文字盤の広さ !!針の長さ、角度 hand_l = 0.10 !!時計の針の腕 hand_w = 0.0075 !!時計の針の広さ hand_t = 0.0025 !!時計の針の厚み hand_l_axs = RND(360) !!長針の角度 hand_s_axs = RND(360) !!短針の角度 !!時計の軸心 core_h = 3*hand_t !!軸心の高さ core_r = 0.010 !!軸心の半径 !時計本体の作成 ROTX 90 CYLIND body_h2, body_r2 ADDZ body_h2 CYLIND body_h1, body_r1 ADDZ body_h1 !!針と時計を区別するために「MATERIAL ○○」で色を付ける MATERIAL 49 CYLIND core_h, core_r ADD 0, - hand_w/2, 5/9*core_h ROTZ hand_l_axs BLOCK hand_l, hand_w, hand_t !!長針 DEL 2 ROTZ hand_s_axs ADD 0, -1.5*hand_w/2, 1/9*core_h BLOCK 2/3*hand_l, 1.5*hand_w, hand_t !!短針 DEL TOP ROTx 90 ADDZ body_h1 + body_h2 !!文字盤 FOR i = 1 to 12 ROTZ 30 ADDX num_pos ADDY -num_width/2 BLOCK num_length, num_width, num_thick DEL 2 NEXT i DEL TOP
このように基本的な座標変換とコマンドでいろいろなものをつくってみましょう。
以下のコメントは、その投稿者が所有するものでサイト管理者はコメントに関する責任を負いません。