ArchiCADで仮設計画〜仮囲いオブジェクト④〜

2024年11月11日月曜日

GDL group 仮囲い

t f B! P L
前回に引き続き、今回はくぐり戸(ドアパネル)を実装していきます。くぐり戸の追加に伴い、コードの内容が前回より大きく変更されています。既存のコードを使いまわしてるのではなく、ブログの執筆と同時並行でGDLを作成しているため、どうしても行き当たりばったり感が出てしまいます。
前向きに考えるとすれば、前回のコードとの比較などをしていただいて、変更箇所の追跡や、何故このように変更しなければいけなかったのかなどを分析すると、学習になると思いますので時間があればトライしてみてください。(言い訳っぽい笑)
質疑等はお問い合わせフォームやコメント機能にて受け付けていますので気軽にご利用ください。

さて、くぐり戸は画像のようなものになります。
また、ホットスポットを設けて好きな位置にくぐり戸を配置できるようなものを目指し、下の動画のような操作感になりました。ぜひ確認してみてください。

くぐり戸 GDL
くぐり戸のイメージ



スクリプト

かなり長くなってしまいましたが、お付き合いください。ちゃんと仕様を決めてから実装すれば、もっと短くできると思います💦

3Dスクリプト
unid = 3000

gosub "マテリアル定義"

hotspot 0,      0, 0, unid, scope, 1+128 	:unid=unid+1
hotspot scope, 	0, 0, unid, scope, 2		:unid=unid+1
hotspot -1, 	0, 0, unid, scope, 3	 	:unid=unid+1


gosub "3D表示"



!==============================================
end
!==============================================

"3D表示":

	!=============================-
	!パネル
	!=============================-
	for i=1 to panel_num - 1
		addx panel_W*(i-1)
		if i>1 then
			if 	not(door_list[i]) & not(door_list[i-1]) then
				gosub "パネル"
			endif	
		else
			if 	not(door_list[i]) then
				gosub "パネル"
				gosub "ジョイントJ左"
			endif
		endif
		del 1
	next i
	!=============================-

	!=============================-
	!ジョイント
	!=============================-
	for i=2 to panel_num - 1
		if i>2 then
			if not(door_list[i-2]) & not(door_list[i-1]) then
				addx panel_W*(i-1)
				gosub "ジョイントJ右"
				del 1
			endif
		else
			if not(door_list[i-1]) then
				addx panel_W*(i-1)
				gosub "ジョイントJ右"
				del 1
			endif
		endif
	next i

	for i=2 to panel_num - 1
		if not(door_list[i]) & not(door_list[i-1]) then
			addx panel_W*(i-1)
			gosub "ジョイントJ左"
			del 1
		endif
	next i
	!=============================-

	!=============================-
	!調整パネル
	!=============================-
	
	if (scope%panel_W) > 0.05 & (scope%panel_W) <= 0.48 then
		addx panel_W*(panel_num - 1)
		gosub "調整パネル"
		del 1
	endif
	!=============================-

	!=============================-
	!最後の一枚
	!=============================-
	add scope - panel_W, -panel_t, 0
		gosub "パネル"
		gosub "ジョイントJ左"
	del 1

	add scope , -panel_t, 0
		gosub "ジョイントJ右"
	del 1
	!=============================-

	!=============================-
	!ドアパネル
	!=============================-
	for i=1 to panel_num - 1
		if door_list[i] then
			addx panel_W*(i-1)
			gosub "くぐり戸"
			del 1
		endif
	next i

	gosub "くぐり戸ホットスポット"
	!=============================-

	!=============================-
	!ドアパネル部は横地を減算
	!=============================-
	group "くぐり戸減算"
		for i=1 to panel_num - 1
			if door_list[i] then
				addx panel_W*(i-1)
				gosub "くぐり戸部減算用"
				del 1
			endif
		next i
	endgroup

	group "横地"
		gosub "横地"
	endgroup
	
	g=subgroup ("横地", "くぐり戸減算")
	placegroup g
	!=============================-


	!gosub "控え"
return


!===============================================
!マテリアル定義
!===============================================
"マテリアル定義":
	DEFINE MATERIAL "フック材質" 0,
		1.0, 0.8, 0.2,! 表面 RGB [0.0..1.0]
		1.0, ! 環境係数 [0.0..1.0]
		0.5, ! 拡散係数 [0.0..1.0]
		0.5, ! 鏡係数 [0.0..1.0]
		0.0, ! 透過係数 [0.0..1.0]
		100.0, ! 光沢 [0.0..100.0]
		1, ! 透過減衰量 [0.0..4.0]
		0.5284, 0.5989, 0.6167,! 鏡面 RGB [0.0..1.0]
		0, 0, 0, ! 放射 RGB [0.0..1.0]
		0.0 ! 放射減衰量 [0.0..65.5]

	DEFINE MATERIAL "ジョイントS材質" 0,
		0.2, 0.8, 1.0,! 表面 RGB [0.0..1.0]
		1.0, ! 環境係数 [0.0..1.0]
		0.5, ! 拡散係数 [0.0..1.0]
		0.5, ! 鏡係数 [0.0..1.0]
		0.0, ! 透過係数 [0.0..1.0]
		100.0, ! 光沢 [0.0..100.0]
		1, ! 透過減衰量 [0.0..4.0]
		0.5284, 0.5989, 0.6167,! 鏡面 RGB [0.0..1.0]
		0, 0, 0, ! 放射 RGB [0.0..1.0]
		0.0 ! 放射減衰量 [0.0..65.5]
	
	DEFINE MATERIAL "ジョイントL材質" 0,
		0.2, 1.0, 0.5,! 表面 RGB [0.0..1.0]
		1.0, ! 環境係数 [0.0..1.0]
		0.5, ! 拡散係数 [0.0..1.0]
		0.5, ! 鏡係数 [0.0..1.0]
		0.0, ! 透過係数 [0.0..1.0]
		100.0, ! 光沢 [0.0..100.0]
		1, ! 透過減衰量 [0.0..4.0]
		0.5284, 0.5989, 0.6167,! 鏡面 RGB [0.0..1.0]
		0, 0, 0, ! 放射 RGB [0.0..1.0]
		0.0 ! 放射減衰量 [0.0..65.5]

	DEFINE MATERIAL "ジョイントJ材質" 0,
		1.0, 0.6, 0.2,! 表面 RGB [0.0..1.0]
		1.0, ! 環境係数 [0.0..1.0]
		0.5, ! 拡散係数 [0.0..1.0]
		0.5, ! 鏡係数 [0.0..1.0]
		0.0, ! 透過係数 [0.0..1.0]
		100.0, ! 光沢 [0.0..100.0]
		1, ! 透過減衰量 [0.0..4.0]
		0.5284, 0.5989, 0.6167,! 鏡面 RGB [0.0..1.0]
		0, 0, 0, ! 放射 RGB [0.0..1.0]
		0.0 ! 放射減衰量 [0.0..65.5]
return

!===============================================
!パネル
!===============================================
"パネル":
	building_material panel_bm
	material panel_mat
	extrude 24, 0, 0, height, 1+2+4+16+32,
		0, 0, 0,
		panel_W, 0, 0,
		panel_W, -0.016, 0,
		panel_W + 0.008, -0.016, 0,
		panel_W + 0.008, -0.030, 0,
		panel_W - 0.008, -0.030, 0,
		panel_W - 0.008, -0.022, 0,
		panel_W - 0.008 + panel_t, -0.022, 0,
		panel_W - 0.008 + panel_t, -0.030 + panel_t, 0,
		panel_W + 0.008 - panel_t, -0.030 + panel_t, 0,
		panel_W + 0.008 - panel_t, -0.016 - panel_t, 0,
		panel_W - panel_t, -0.016 - panel_t, 0,
		panel_W - panel_t, - panel_t, 0,
		panel_t, - panel_t, 0,
		panel_t, -0.014 + panel_t, 0,
		0.008 + panel_t, -0.014 + panel_t, 0,
		0.008 + panel_t, -0.030 + panel_t, 0,
		0.024 - panel_t, -0.030 + panel_t, 0,
		0.024 - panel_t, -0.022, 0,
		0.024, -0.022, 0,
		0.024, -0.030, 0,
		0.008, -0.030, 0,
		0.008, -0.014, 0,
		0, -0.014,0
return

"調整パネル":
	building_material panel_bm
	material adjust_mat
	extrude 14, 0, 0, height, 1+2+4+16+32,
		0, 0, 0,
		panel_W+0.02, 0, 0,
		panel_W+0.02, - panel_t, 0,
		panel_t, - panel_t, 0,
		panel_t, -0.014 + panel_t, 0,
		0.008 + panel_t, -0.014 + panel_t, 0,
		0.008 + panel_t, -0.030 + panel_t, 0,
		0.024 - panel_t, -0.030 + panel_t, 0,
		0.024 - panel_t, -0.022, 0,
		0.024, -0.022, 0,
		0.024, -0.030, 0,
		0.008, -0.030, 0,
		0.008, -0.014, 0,
		0, -0.014,0

	add panel_W - 0.03, -0.007, height - 0.049
		gosub "フック"
	del 1

	add panel_W - 0.03, -0.007, - 0.001
		gosub "ジョイントS"
	del 1

	IF int(panel_h) = 3 then
		add - 0.022, -0.031, height/2 + 0.1
		gosub "ジョイントL"
		del 1
	endif

	add - 0.022, -0.031, 0.25
		gosub "ジョイントL"
	del 1

	add - 0.022, -0.031, height - 0.27
		gosub "ジョイントL"
	del 1

	gosub "ジョイントJ左"
return

"線パネル":
	material panel_mat
	plane 4,
		0, 0, 0,
		panel_W, 0, 0,
		panel_W, 0, height,
		0, 0, height
return
"線調整パネル":
	material adjust_mat
	plane 4,
		0, 0, 0,
		panel_W+0.02, 0, 0,
		panel_W+0.02, 0, height,
		0, 0, height
return

!===============================================
!各種ジョイント金具
!===============================================

"ジョイントL":
	material "ジョイントL材質"
	brick 0.06, 0.015,0.02
return

"ジョイントS":
	material "ジョイントS材質"
	brick 0.02, 0.008,0.05
return

"フック":
	material "フック材質"
	brick 0.02, 0.008,0.05
return

"ジョイントJ":
	material "ジョイントJ材質"
	j_w = 48.6/2000 + 0.002
	extrude 4, 0, 0, 0.01, 1+2+4+16+32,
		0.01, j_w, 0,
		0.01, -j_w, 0,
		54.3/1000, -j_w, 0,
		54.3/1000, j_w, 1000
return

"ジョイントJ左":
	add 0.034, 0, 0.15
	rotx 90
	roty -90
	gosub "ジョイントJ"
	del 3

	add 0.034, 0, height - 0.15
	rotx 90
	roty -90
	gosub "ジョイントJ"
	del 3

	if int(panel_h) = 3 then
		add 0.034, 0, height/2
		rotx 90
		roty -90
		gosub "ジョイントJ"
		del 3	
	endif
return

"ジョイントJ右":
	add -0.008, 0, 0.15
	rotx 90
	roty -90
	gosub "ジョイントJ"
	del 3

	add -0.008, 0, height - 0.15
	rotx 90
	roty -90
	gosub "ジョイントJ"
	del 3

	if int(panel_h) = 3 then
		add -0.008, 0, height/2
		rotx 90
		roty -90
		gosub "ジョイントJ"
		del 3	
	endif	
return

!===============================================
!単管
!===============================================

"横地":
	if int(panel_h) = 2 then
		tankan_l = scope
		add 0, -54.3/1000, 0.15
		roty 90
		gosub "単管"
		del 2

		add 0, -54.3/1000, height - 0.15
		roty 90
		gosub "単管"
		del 2
	endif

	if int(panel_h) = 3 then
		tankan_l = scope
		add 0, -54.3/1000, 0.15
		roty 90
		gosub "単管"
		del 2

		add 0, -54.3/1000, height/2
		roty 90
		gosub "単管"
		del 2

		add 0, -54.3/1000, height - 0.15
		roty 90
		gosub "単管"
		del 2
	endif
return

"控え":
	tankan_l = scope
	tate_pos = -130.3/1000

	add 0, tate_pos - negarami_len - 0.07, 0.15
	roty 90
	gosub "単管"
	del 2
	gosub "建地"
return

"建地":
	tankan_l = height + neire

	hotspot 0, tate_pos, 0		, unid, neire, 1+128 	:unid=unid+1
	hotspot 0, tate_pos, -neire  , unid, neire, 2		:unid=unid+1
	hotspot 0, tate_pos, 1		, unid, neire, 3	 	:unid=unid+1
 
	!建地
	add 0, tate_pos, -neire
	gosub "単管"

	tankan_l = 0.5 + neire
	addy -negarami_len
	gosub "単管"

	del 2

	!根がらみ
	tankan_l = 0.15 + negarami_len
	add 0.07, -0.08, 0.2
	rotx 90
	gosub "単管"
	del 2
	
	!斜め
	tankan_l = negarami_len/cos(atn((3*height/5)/negarami_len)) + 0.2
	add 0.07 ,tate_pos-negarami_len- 0.1, 0.25
	rotx atn((3*height/5)/negarami_len)	- 91	
	gosub "単管"
	del 2

	hotspot 0, 0, 			 				0.2, unid, negarami_len, 1+128 :unid=unid+1
	hotspot 0, tate_pos-negarami_len-0.1, 	0.2, unid, negarami_len, 2		:unid=unid+1
	hotspot 0, 1, 			 				0.2, unid, negarami_len, 3	 	:unid=unid+1
return

"単管":
	material tankan_mat
	cylind tankan_l, 48.6/2000
return

"くぐり戸ホットスポット":
	minus=0
	if (scope%panel_W) > 0.05 & (scope%panel_W) <= 0.48 then
		minus = 1
	endif

	for i=1 to vardim1(door_list)-minus
		addx panel_W*i
		if i>1 then
			if not(door_list[i+1]) & not(door_list[i-1]) then
				hotspot 0, 	0, 0, 			unid, door_list[i], 1+128 	:unid=unid+1
				hotspot 0, 	0, door_list[i],unid, door_list[i], 2		:unid=unid+1
				hotspot 0, 	0, -1, 			unid, door_list[i], 3	 	:unid=unid+1
			endif
		else
			if not(door_list[i+1]) then
				hotspot 0, 	0, 0, 				unid, door_list[i], 1+128 	:unid=unid+1
				hotspot 0, 	0, 0.2*door_list[i], unid, door_list[i], 2		:unid=unid+1
				hotspot 0, 	0, -1, 				unid, door_list[i], 3	 	:unid=unid+1
			endif
		endif
		del 1
	next i	
return

"くぐり戸部減算用":
	muly -1
	brick 1, 0.2, 2
	del 1
return

"くぐり戸":
	tate_pos = -130.3/1000
	material panel_mat
	muly -1

	brick 0.098, 0.03, 1.86

	addx 0.1
	rotz door_angle
	gosub "戸"
	del 1

	addx 0.782
	brick 0.118, 0.03, 1.86
	del 2

	addz 1.862
	brick 1, 0.03, 0.138
	del 1

	if int(height)=3 then
		addz 2
		brick 0.5, 0.03, 1
		addx 0.5
		brick 0.5, 0.03, 1
		del 2

		add -0.25, 54.3/1000, 2.2
		roty 90
		tankan_l = 1.5
		gosub "単管"
		del 2
	endif

	!建地

	add -0.1225, -tate_pos, 0
	tankan_l = height
	gosub "単管"
	del 1

	add 1.1225, -tate_pos, 0
	tankan_l = height
	gosub "単管"
	del 1
	
	del 1
return

"戸":
	material tankan_mat
	add 0.7, 0, 1
	rotx 90
	cylind 0.01, 0.04
	del 2

	material panel_mat
	brick 0.78, 0.03, 1.86
return


GROUPコマンド

これだけ長いと全部を説明できませんが、本ブログで今回初めて使用したgroupコマンドについて触れていきたいと思います。複数の要素を一つのグループとしてまとめて扱えるようにするコマンドです。具体的には、groupとその対になるendgroupの間にある要素をまとめて処理できるため、座標の設定や変換などを一括で適用できるようになります。

addgroupsubgroupコマンドを用いると、GDL内でグループ同士のブーリアン演算を行うことができます。たとえば、subgroupを使って特定の形状を減算し、くぐり戸部分の単管を削除するといった操作が可能です。これにより、モデル内の部材同士の調整やカスタマイズが柔軟に行えるようになります。

また、実際に3Dに配置する際は、placegroupコマンドを使って定義したグループを配置します。これによって、複数の形状をまとめて操作したり、表示位置を制御したりできます。



マスタースクリプト
eps = 0.0000001

height = panel_h
panel_W = 0.5
panel_t = 0.003


パラメータスクリプト
values "panel_h", 2, 3
values{2} "mode" 1,"3D表示",2,"パネル調整"

if (scope%panel_W) <= 0.05 then
	parameters scope = panel_W*panel_num
endif

if (scope%panel_W) >= 0.48 then
	parameters scope = panel_W*(panel_num+1)
endif

panel_num = int(scope/panel_W)
parameters panel_num = panel_num

if (scope%panel_W) > 0.05 & (scope%panel_W) <= 0.48 then
	adjust_panel_num = 1
else
	adjust_panel_num = 0
endif
parameters adjust_panel_num = adjust_panel_num

tate_num = int(scope/1.8) + 1
parameters tate_num = tate_num

if int(height)=3 then
	k = 6
	m = 3
else
	k = 4
	m = 2
endif

j_num = panel_num*k
parameters j_num = j_num

l_num = adjust_panel_num*m
parameters l_num = l_num

dim _door_list[]
for i=1 to panel_num-1
	_door_list[i] = door_list[i]
next i
parameters door_list = _door_list


パラメータリスト
パラメータgdl



仮囲い関連の記事はこちら


なお、基本的なGDLの学習はこちらの教材がおすすめです!
GDLリファレンスがgraphisoftが用意していますが、初見では理解しづらいので、
簡単にまとめられたやさしく学ぶArchiCAD GDLプログラミングという本で基礎をしっかり学びましょう!

【お知らせ】
Xのアカウントを作成しましたので、ぜひフォロー頂けると嬉しいです。
アカウントはこちらから⇨https://x.com/BIM_arekore

世界の建設業従事者、BIM推進者と繋がりたいです。よろしくお願いします。

検索

GDLオブジェクト

UI (4) ユニーク (1) ラベル (2) 仮囲い (6) 多角形 (3) 小ネタ (4) (7) 椅子 (4) 法規 (1) 無償DL (4) 足場 (15) 足場計画 (4)

ブログ アーカイブ

自己紹介

自分の写真
GDL作成などBIM活用のお仕事の相談お待ちしております。 #中堅ゼネコン出身 #施工管理職 #生産設計部 #BIM開発部門
ArchiCADのGDLをコスパよく作成します ArchiCADユーザーでGDL作成を外部委託されている方へ

QooQ