Component Packing (VB+Galapagos) Korean Version by Woo Jae Sung

Page 1

GRASSHOPPER WORKEXAMPLE

VB SCRIPTING + GALAPAGOS GH VER. 0.8.0010 woojae sung woojae.sung@yahoo.com http://woojsung.com


IDEA ๊ธฐ๋ณธ์ ์ธ ๊ฐœ๋…์€ ์„œ๋กœ ๋…๋ฆฝ์ ์ธ ๋ณ€์ˆ˜์— ์˜ํ•ด ์ •์˜๋˜๋Š” ๋„ค๊ฐœ์˜ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋งŒ๋“ ํ›„ ์ด๋ฅผ ์ด์›ƒํ•˜์—ฌ ๋ฐฐ์—ดํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋ถ€ํ„ฐ ์ถœ๋ฐœํ•ฉ๋‹ˆ๋‹ค. ์•„๋ž˜ ๊ทธ๋ฆผ์˜ step 01 ์—์„œ ๋ณผ์ˆ˜ ์žˆ๋“ฏ์ด, ๊ฐ๊ฐ์˜ ์ปดํฌ๋„ŒํŠธ๋Š” ๊ฐ๊ธฐ ๋‹ค๋ฅธ ๋ฒ”์œ„์˜ ์‚ฌ์ž‡๊ฐ์— ์˜ํ•ด ์ •์˜๋ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด type A์˜ ๊ฒฝ์šฐ๋Š” ์‚ฌ์ž‡๊ฐ์ด 5๋„์—์„œ 10๋„ ์‚ฌ์ด์˜ ์–ด๋– ํ•œ ๊ฐ์ด๋“  ๊ฐ€์งˆ ์ˆ˜ ์žˆ์œผ๋ฉฐ type B๋Š” 7๋„์—์„œ 12๋„ ์‚ฌ์ด์˜ ์–ด๋–ค ๊ฐ๋„ ๊ฐ€์งˆ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ ์„œ๋กœ ๋™์ผํ•œ ๊ธฐํ•˜ํ•™์  ๋ฐฐ์—ด์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉด์„œ๋„ ์„œ๋กœ ๋‹ค๋ฅธ ์‚ฌ์ž‡๊ฐ์„ ๊ฐ€์ง€๋Š” ๋„ค ๊ฐ€์ง€์˜ ์ปดํฌ๋„ŒํŠธ๋“ค์€, ์„œ๋กœ ๋ณ€์„ ๊ณต์œ ํ•˜๋ฉฐ ์ผ์ •ํ•œ ์ˆœ์„œ-์ˆœ์„œ๋Š” ์ฐจํ›„ ์กฐ์ •ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค-์— ์˜ํ•˜์—ฌ ์„ ํ˜•๋ฐฐ์—ด์„ ํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ type๋“ค ๊ฐ„์˜ ์„œ๋กœ ์กฐ๊ธˆ์”ฉ ๋‹ค๋ฅธ ์‚ฌ์ž‡๊ฐ๋“ค๋กœ ์ธํ•ด step 02์™€ ๊ฐ™์€ ์ดˆ๊ธฐ ๋ฐฐ์—ด์„ ํ˜•ํƒœ๋ฅผ ๊ฐ€์ง€๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ์˜ ๋ชฉํ‘œ๋Š” ๋…๋ฆฝ์ ์ธ ๋„ค๊ฐœ์˜ ์‚ฌ์ž‡๊ฐ ๋ณ€์ˆ˜๋“ค์„ ์กฐ๊ธˆ์”ฉ ์กฐ์ •ํ•˜๋Š” ๊ณผ์ •์„ ํ†ตํ•ด step 02 ์—์„œ ๋ณผ์ˆ˜ ์žˆ๋Š” ์„ ํ˜•๋ฐฐ์—ด์„ step 03์—์„œ ์ฒ˜๋Ÿผ ์›ํ˜• ๋ฐฐ์—ด์˜ ํ˜•ํƒœ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฆ‰ step 03์˜ ๊ทธ๋ฆผ์—์„œ ๋ณผ์ˆ˜ ์žˆ๋“ฏ์ด, ์‹œ์ž‘ํ•˜๋Š” ์„ ๊ณผ ๋๋‚˜๋Š” ์„ ์˜ ์‹œ์ž‘์  ๊ณผ ๋์ ์—์„œ์˜ ๊ฐ๊ฐ์˜ ๊ฑฐ๋ฆฌ๋ฅผ D1๊ณผ D2๋ผ๊ณ  ํ• ๋•Œ, ๋‘ ๊ฑฐ๋ฆฌ๊ฐ’์˜ ํ•ฉ์ด ์ตœ์†Œ๊ฐ€ ๋˜๋„๋ก ๊ฐ๊ฐ์˜ ์‚ฌ์ž‡๊ฐ์„ ์กฐ๊ธˆ์”ฉ ์กฐ์ ˆํ•˜์—ฌ ๋‚˜๊ฐ€๋Š” ๊ณผ์ •์—์„œ ์ตœ์ ์˜ ๋ฐฐ์—ด, ์ฆ‰ ์ตœ์†Œ ํ•œ์˜ ๊ฑฐ๋ฆฌ๊ฐ’์„ ๊ฐ€์ง€๋Š” ์‚ฌ์ž‡๊ฐ๋“ค์˜ ์กฐํ•ฉ์„ ์ฐพ์•„๋‚ด๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๊ณผ์ •์€ ์ผ์ผํžˆ ๋„˜๋ฒ„ ์Šฌ๋ผ์ด๋”๋ฅผ ์กฐ์ ˆํ•˜์—ฌ์„œ๋Š” ์‰ฝ์ง€ ์•Š์œผ๋ฆฌ๋ผ๊ณ  ์ƒ๊ฐ๋ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฌํ•œ ๋ฌด ์ˆ˜ํ•œ ์‹œํ–‰-์ฐฉ์˜ค์˜ ๊ณผ์ •์„ ๊ฑฐ์ณ์•ผ ํ•˜๋Š” ๋ฐฉ์ •์‹์˜ ํ•ด๋Š” Grasshopper์˜ Galapagos๋ผ๋Š” ๋ฐฉ์ ์‹ ํ’€์ด ๋ชจ๋“ˆ์„ ํ†ตํ•ด ์‰ฝ๊ฒŒ ์ฐพ์•„๋‚ผ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

STEP01 COMPONENTS

STEP02 INITIAL ARRAY

VARIABLE ANGLE 01

VARIABLE ANGLE 02

VARIABLE ANGLE 03

VARIABLE ANGLE 04

TYPE A

TYPE B

TYPE C

TYPE D

STEP03 PACKED D1

D2

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 01


DEFINING A COMPONENT ์ฒซ๋ฒˆ์งธ ๋‹จ๊ณ„๋กœ, ์šฐ๋ฆฌ๋Š” Grasshopper์˜ ๊ธฐ๋ณธ ์˜ค๋ธŒ์ ํŠธ๋งŒ์„ ํ†ตํ•ด ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ •์˜ํ•ด ๋ณผ๊ฒƒ์ž…๋‹ˆ๋‹ค. ์ฒซ๋ฒˆ์งธ๋กœ ํ•ด์•ผ ํ•  ๊ฒƒ์€, ๋ผ์ด๋…ธ์—์„œ ๊ธธ์ด 20์ด ๋˜๋Š” ์„ ์„ ๊ทธ๋ฆฌ ๊ณ (Start Line) ์ด๋ฅผ Grasshopper์˜ Curve ์˜ค๋ธŒ์ ํŠธ์— ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค. ๊ทธํ›„ ๊ทธ ์„ ์˜ ์ค‘์ (Start Leg Pt)์„ ์ฐพ๊ณ  ์ด ์ ์—์„œ ๊ธธ์ด 2.5์˜ ๋ฒ•์„ (Start Leg)์„ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค. ์ด ์„ ์˜ ๋๋‚˜๋Š” ์ ์„ ์ฐพ๊ณ (Center Pt), ์ด๋ฅผ ์ค‘์ ์œผ๋กœ ํ•˜๋ฉฐ Start Line์— ์ ‘ํ•˜๋Š” ์›(Circle / Pivot Cell)์„ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ , ์ด ์›์˜ ์ค‘์‹ฌ(Pivot Point)์„ ํšŒ์ „์ถ•์œผ๋กœ ์‚ผ์•„ Start Leg, Start Leg Pt, Start Line์„ ํŠน์ •๊ฐ๋„(Angle)๋กœ ํšŒ์ „์‹œ์ผœ End Leg, End Leg Pt, End Line์„ ์ž‘์„ฑํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

End Line

L = 0.5

Start Leg Pt

LENGTH = 2.5

Center Pt

RADIUS = 2.5

INPUT GEOMETRY Start Line

Circle / Pivot Cell

End Leg

ANGLE Start Leg

Pivot Point

End Leg Pt

01 A CENTER POINT

02 A PERPENDICULAR LINE

03 A CIRCLE

04 ROTATE BY ANGLE

05 ROTATE BY ANGLE

GH DEFINITION

์•„๋ž˜ ์Šคํฌ๋ฆฐ ์ƒท์€ ์™„์„ฑ๋œ Grasshopper Definition์˜ ๋ชจ์Šต์ž…๋‹ˆ๋‹ค. ( 001 component GH objects.ghx ํŒŒ์ผ์„ ์ฐธ์กฐํ•˜์„ธ์š” ).

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 02


CUSTOM VB COMPONENT ์ด๋ฒˆ์—๋Š” ์œ„์—์„œ ์ •์˜ํ•œ Grasshopper ๊ฐ์ฒด๋“ค์„ VB ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ†ตํ•˜์—ฌ ๋‹จ์ผ ์˜ค๋ธŒ์ ํŠธ๋กœ ๋ณ€ํ™˜ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ์Šคํฌ๋ฆฐ์ƒท์—์„œ ๋ณด์‹œ๋Š” input / output ๋ณ€์ˆ˜์˜ ์ด๋ฆ„๋“ค์€ ์•ž์žฅ์˜ ์ปดํฌ๋„ŒํŠธ ์ •์˜ ๋‹ค์ด์–ด๊ทธ๋žจ์˜ ๋ณ€์ˆ˜๋ช…๋“ค๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. ์ฆ‰, input line, ๋ฐ˜์ง€๋ฆ„, ๊ทธ๋ฆฌ๊ณ  ์‚ฌ์ž‡๊ฐ์˜ ๊ฐ๋„๋ฅผ input ํŒŒ๋ผ๋ฉ”ํ„ฐ๋กœ ๊ฐ€์ง€๊ณ  ๊ฒฐ๊ณผ๋ฌผ๋กœ์จ pivot_cell, pivot_pt ๋“ฑ๋“ฑ์„ ๋งŒ๋“ค์–ด ๋ƒ…๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ ๋™์ผํ•œ ์ž‘์—…์„ ํ•˜๊ฒŒ ๋˜์ง€๋งŒ ๋‹จ ํ•˜๋‚˜์˜ ์˜ค๋ธŒ์ ํŠธ๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. (002 component VB.ghx ํŒŒ์ผ์„ ์ฐธ์กฐํ•˜์„ธ์š”)

๊ทธ๋ ‡๋‹ค๋ฉด, ๊ตณ์ด ์ด๋Ÿฌํ•œ VB Scripting์„ ์จ์„œ ์ž‘์—…์„ ํ•ด์•ผ ํ•˜๋Š” ์ด์œ ๊ฐ€ ๋ญ˜๊นŒ์š”? ๋งŽ์€ ๋‹ค๋ฅธ ์ด์œ ๋“ค์ด ์žˆ์„์ˆ˜ ์žˆ๊ฒ ์ง€๋งŒ, ๋ณธ ์ž‘์—…์˜ ๊ฒฝ์šฐ๋Š” ์•„๋ž˜์™€ ๊ฐ™์ด ์ปจํŠธ๋กค ํ•˜ ๊ธฐ ์–ด๋ ค์šด ์ƒํ™ฉ์„ ๋งŒ๋“ค์ง€ ์•Š๊ธฐ ์œ„ํ•ด์„œ ์ž…๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 03


CODE REVIEW ์ด๋ฒˆ์—๋Š” VB ์˜ค๋ธŒ์ ํŠธ์˜ ์ฝ”๋“œ๋ฅผ ํ•œ์ค„์”ฉ ์‚ดํŽด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. VB ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๋”๋ธ”ํด๋ฆญํ•˜๋ฉด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ˆ˜์ •ํ• ์ˆ˜ ์žˆ๋Š” ์ฐฝ์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.

Circle /

Dim s_pt As New point3d(start_crv.PointAt(0.5)) Pivot Cell

Start Leg Pt

LENGTH = 2.5

L = 0.5

โ€ข โ€ข โ€ข โ€ข โ€ข

End Leg

RADIUS = 2.5

Center Pt

start_leg_pt = s_pt

โ€˜ ๋กœ ์‹œ์ž‘ํ•˜๋Š” ์ค„์€ ์ฃผ์„์ž…๋‹ˆ๋‹ค. ์ฆ‰ ์–ด๋– ํ•œ ์ผ๋„ ํ•˜์ง€ ์•Š๋Š” ์ค„์ž…๋‹ˆ๋‹ค. ๋‘๋ฒˆ์งธ ์ค„์—์„œ๋Š” s_pt๋ผ๋Š” ์ƒˆ๋กœ์šด ์ ์„ ์ƒ์„ฑํ•˜๊ณ  ์ด ์ ์— start_crv์˜ L=0.5 ์ฆ‰ ์ค‘์ ์— ํ•ด๋‹นํ•˜๋Š” ์ ์„ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. ๊ทธ ๋‹ค์Œ, s_pt๋ฅผ start_leg_pt๋ผ๋Š” output๋ณ€์ˆ˜์— ํ• ๋‹นํ•˜์—ฌ ์ค๋‹ˆ๋‹ค. ์ฆ‰ ๋ผ์ด๋…ธ ๋ทฐํฌํŠธ์—์„œ ์ด์ ์„ ๋ณผ์ˆ˜ ์žˆ๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค. ANGLE ๋งŒ์•ฝ ์„ธ๋ฒˆ์งธ ์ค„์˜ ๋ช…๋ น์ด ์—†๋‹ค๋ฉด VB๋Š” ์ ์„ ์ƒ์„ฑํ•˜์—ฌ ๋†“๊ณ ๋„ ๊ทธ๊ฒƒ์„ ์šฐ๋ฆฌ์—๊ฒŒ ๋ณด์—ฌ์ฃผ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. Start Leg์ •์˜์™€ ์ ์œผ๋กœ ๊ตฌ๋ถ„๋˜๋Š” ๋ช…๋ น์–ด๋“ค์— ๋ณ€์ˆ˜์˜ Pivot Point ๋Œ€ํ•œ ์ข€ ๋” ์ž์„ธํ•œ ์„ค๋ช…์„ ์ฐพ์œผ์‹œ๋Š” ๋ถ„์€ http://www.rhino3d.com/5/ rhinocommon/ ์„ ๋ฐฉ๋ฌธํ•˜์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

End Leg Pt

01 A CENTER POINT

02 A PERPENDICULAR LINE

03 A CIRCLE

04 ROTATE BY ANGLE

05 ROTATE BY ANGLE

End Line 'defines start_leg /////////////////////////////////////////////////////////////////////////////////////////////

UT GEOMETRY t Line

Circle /

End Leg Dim start_crv_start Pivot Cell As New Point3d(start_crv.PointAt(0.0)) Dim start_crv_end As New Point3d(start_crv.pointat(1.0)) RADIUS = 2.5

Center Pt

Dim original_vector As New Vector3d(start_crv_start - start_crv_end)

LENGTH = 2.5

t Leg Pt

End Line 'defines start_leg_pt //////////////////////////////////////////////////////////////////////////////////////////

INPUT GEOMETRY Start Line

Dim rotation_ang_start_leg As Double = math.PI / 2 Dim rotation_axis_start_leg As New Vector3d(0, 0, 1) ANGLE

original_vector.Rotate(rotation_ang_start_leg, rotation_axis_start_leg) Start Leg

Pivot Point

Dim line_start As New line(start_leg_pt, original_vector, pivot_cell_radius) start_leg = line_start

End Leg Pt

โ€ข โ€ข

02 A PERPENDICULAR LINE

์ด๋ฒˆ์—๋Š” ์ „๋‹จ๊ณ„์—์„œ ์ƒ์„ฑํ•œ ์ค‘์ , ์ฆ‰ start_leg_pt๋ฅผ ์ถœ๋ฐœ์ ์œผ๋กœ ํ•˜๋Š” ๋ฒ•์„ ์„ ๊ทธ๋ฆด ์ฐจ๋ก€์ž…๋‹ˆ๋‹ค. ๋จผ์ €, ๊ธฐ์ค€์ด ๋˜๋Š” ์„ , ์ฆ‰ start_crv์˜ ๋ฐฉํ–ฅ๋ฒกํ„ฐ๋ฅผ ๊ตฌํ•˜๊ณ  ์ด ๋ฒกํ„ฐ๋ฅผ ์‹œ๊ณ„๋ฐฉํ–ฅ์œผ๋กœ 90๋„ ๋Œ๋ ค์คŒ์œผ๋กœ์จ ๋ฒ•์„  ๋ฒกํ„ฐ๋ฅผ 03 A CIRCLE ์ƒ์„ฑํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. 04 ROTATE BY ANGLE 05 ROTATE BY ANGLE โ€ข ๊ธฐ์ค€์ด ๋˜๋Š” ์„ , start_crv์˜ ์–‘๋์ ์„ ์ •์˜ํ•˜์—ฌ ์ค๋‹ˆ๋‹ค. โ€ข ๊ทธ๋‹ค์Œ ๋‘ ์ ์˜ ์ฐจ๋ฅผ ํ†ตํ•ด original_vector๋ฅผ ์ •์˜ํ•ด ์ค๋‹ˆ๋‹ค. ์ด๋Š” ์™ผํŽธ๊ทธ๋ฆผ์— ํŒŒ๋ž€์ƒ‰ ํ™”์‚ดํ‘œ๋กœ ํ‘œ์‹œ๋˜์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. โ€ข ์ด์ œ๋Š” ์ด ํŒŒ๋ž€์ƒ‰ ๋ฒกํ„ฐ๋ฅผ ํšŒ์ „์‹œ์ผœ ์ดˆ๋ก์ƒ‰ ๋ฒกํ„ฐ๋กœ ๋งŒ๋“ค์–ด ์ฃผ์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๊ธฐ ์œ„ํ•ด์„œ๋Š” rotation์ด๋ž€ methods๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. rotation method๋Š” ํšŒ์ „๊ฐ๊ณผ ํšŒ์ „์ถ•์ด๋ผ๋Š” ๋‘๊ฐ€์ง€ ๋ณ€์ˆ˜๋ฅผ ํ†ตํ•ด ์ž‘๋™ํ•ฉ๋‹ˆ๋‹ค. โ€ข ํšŒ์ „๊ฐ, rotation_ang_start_leg๋ฅผ 90๋„๋กœ ์ •์˜ ํ•ฉ๋‹ˆ๋‹ค. (ํŒŒ์ด/2 = 90๋„) โ€ข ํšŒ์ „์ถ•์€ Z ๋ฐฉํ–ฅ๋ฒกํ„ฐ๋กœ ์žก์Šต๋‹ˆ๋‹ค. โ€ข ๊ทธํ›„ original_vector์— rotate method๋ฅผ ์  ์—ฐ๊ฒฐ์ž๋กœ ์—ฐ๊ฒฐํ•˜๊ณ  ํšŒ์ „๊ฐ๊ณผ ํšŒ์ „์ถ•์„ ์ž…๋ ฅํ•˜์—ฌ original_vector๋ฅผ 90๋„ ๋Œ๋ฆฝ๋‹ˆ๋‹ค. ํšŒ์ „๋œ ๋ฒกํ„ฐ๋Š” ์ด์ œ ์ดˆ๋ก์ƒ‰ ํ™”์‚ดํ‘œ์™€ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. โ€ข ์ด์ œ ์ƒˆ๋กœ์šด ์„ ์„ ๊ธ‹์Šต๋‹ˆ๋‹ค. ์‹œ์ž‘์ (start_leg_pt)์™€ ๋ฐฉํ–ฅ(์ด๋ฏธ ํšŒ์ „๋œ original_vector)์™€ ๊ธธ์ด(pivot_cell_radius)๋ฅผ ์ž… ๋ ฅํ•˜์—ฌ line_start๋ผ๋Š” ์„ ์„ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. โ€ข ์ด์ œ ๊ทธ ์„ ์„ start_leg๋ผ๋Š” output ํŒŒ๋ผ๋ฉ”ํ„ฐ์— ์—ฐ๊ฒฐํ•˜์—ฌ ๋ทฐํฌํŠธ์ƒ์— ์ถœ๋ ฅ๋ ์ˆ˜ ์žˆ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 04


End Line 'defines pivot_pt //////////////////////////////////////////////////////////////////////////////////////////////

RADIUS = 2.5

nter Pt

Circle / Pivot Cell

End Leg Dim p_pt As New point3d(line_start.PointAt(1.0))

pivot_pt = p_pt 'defines pivot_cell //////////////////////////////////////////////////////////////////////////////////////////// Dim pivot_circle As New Circle(line_start.PointAt(1.0), pivot_cell_radius) ANGLE

pivot_cell = pivot_circle

eg

Pivot Point

โ€ข โ€ข โ€ข

R LINE

03 A CIRCLE

์ „๋‹จ๊ณ„์—์„œ ๋งŒ๋“  ๋ฒ•์„ , line_start๋ฅผ ์ด์šฉํ•˜์—ฌ ์›์„ ๊ทธ๋ฆฝ๋‹ˆ๋‹ค. ์šฐ์„  line_start์˜ ๋์ ์— ์ ์„ ์ƒ์„ฑํ•˜์—ฌ ์ด๋ฅผ p_pt๋ผ๋Š” ์ ์— ํ• ๋‹นํ•˜๊ณ  ์ด๋ฅผ ๋‹ค์‹œ pivot_pt๋ผ๋Š” output ํŒŒ๋ผ๋ฉ”ํ„ฐ์— ํ•  ๋‹นํ•ฉ๋‹ˆ๋‹ค. End Leg Pt p_pt๋ผ๋Š” ์ ์„ ์ค‘์‹ฌ์œผ๋กœ ํ•˜๊ณ  pivot_cell_radius๋งŒํผ์˜ ๋ฐ˜์ง€๋ฆ„์„ ๊ฐ€์ง€๋Š” ์›์„ ์ƒ์„ฑํ•˜์—ฌ pivot_circle์ด๋ผ๋Š” ์›์— ํ• ๋‹น ํ•ฉ๋‹ˆ๋‹ค. ์ด๋Š” ๋‹ค์‹œ pivot_cell์ด๋ผ๋Š” output ํŒŒ๋ผ๋ฉ”ํ„ฐ์— ํ• ๋‹น๋ฉ๋‹ˆ๋‹ค.

04 ROTATE BY ANGLE

05 ROTATE BY ANGLE

End Line 'defines end_leg /////////////////////////////////////////////////////////////////////////////////////////////// Circle / Pivot Cell

End Leg

Dim rot As transform = transform.Rotation(pivot_ang * math.PI / 180, vector3d.ZAxis, line_start.PointAt(1.0)) Dim rotated_leg As line = line_start rotated_leg.Transform(rot) end_leg = rotated_leg

ANGLE

'defines end_leg_pt ////////////////////////////////////////////////////////////////////////////////////////////

Pivot Point

s_pt.Transform(rot) End Leg Pt

end_leg_pt = s_pt 'defines end_crv ///////////////////////////////////////////////////////////////////////////////////////////////

04 ROTATE BY ANGLE

Dim st_line As line = start_crv

05 ROTATE BY ANGLE

st_line.Transform(rot) End Line

Dim end_line_st_pt As New Point3d(st_line.PointAt(1.0)) Dim end_line_end_pt As New Point3d(st_line.PointAt(0.0)) Dim end_line As New line(end_line_st_pt, end_line_end_pt) end_crv = end_line โ€ข โ€ข โ€ข โ€ข โ€ข

Pt

โ€ข โ€ข 05 ROTATE BY ANGLE

โ€ข

์ด๋ฒˆ๋‹จ๊ณ„์—์„œ๋Š” ์ „๋‹จ๊ณ„์—์„œ ๋งŒ๋“ค์—ˆ๋˜ start line, start leg, start leg point๋“ค์„ ์ค‘์ ์ธ pivot point๋ฅผ ์ค‘์‹ฌ์œผ๋กœ pivot_ ang๋งŒํผ ํšŒ์ „์‹œ์ผœ์„œ end line, end leg, end leg point๋“ฑ์„ ์ƒ์„ฑํ•˜๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ํ•œ๊ฐœ ์ด์ƒ์˜ ํšŒ์ „ ์ž‘์—…์„ ํ•ด์•ผ ํ•˜๋ฏ€๋กœ ํšŒ์ „ matrix๋ฅผ ์ƒ์„ฑํ›„ ์ด๋ฅผ ์žฌ์ฐจ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ํŽธ๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ํšŒ์ „ matrix์˜ input์œผ๋กœ๋Š” ํšŒ์ „๊ฐ(pivot_ang), ํšŒ์ „์ถ•(z axis), ๊ทธ๋ฆฌ๊ณ  ํšŒ์ „์˜ ์ค‘์‹ฌ์ด ๋˜๋Š” ์ ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. rotated_leg๋ผ๋Š” ์ƒˆ๋กœ์šด ๋ผ์ธ์„ ์ƒ์„ฑํ›„ ์ด์— ๊ธฐ์กด์˜ ์„ ์ธ line_start๋ฅผ ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. rotated_leg๋ฅผ transform matrix์ธ rot์„ ํ†ตํ•ด ํšŒ์ „ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด ํšŒ์ „๋œ ์„ ์„ end_leg๋ผ๋Š” output ํŒŒ๋ผ๋ฉ”ํ„ฐ์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. let_pt์—๋„ ๋™์ผํ•œ ์ž‘์—…์„ ํ•ด ์ค๋‹ˆ๋‹ค. end_crv์—๋„ ๋™์ผํ•œ ์ž‘์—…์„ ํ•ด ์ค๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์„ ์€ ๋ฐฉํ–ฅ์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฏ€๋กœ start_crv๋ฅผ ํšŒ์ „์‹œ ๋ฐฉํ–ฅ์ด ๋ฐ”๋€Œ๊ฒŒ ๋ฉ๋‹ˆ ๋‹ค. (์ดˆ๋ก์ƒ‰ ํ™”์‚ดํ‘œ๋กœ ํ‘œ์‹œ). ๊ทธ๋ž˜์„œ ์ด ์„ ์˜ ๋ฐฉํ–ฅ์„ ๋ฐ˜๋Œ€๋กœ ๋Œ๋ ค์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ผ๋‹จ ์„ ์„ ํšŒ์ „ํ•œํ›„, (st_line.Transform(rot)), ์ด ์„ ์˜ ์–‘๋์ ์„ ์ฐพ์•„ ๋ฐ˜๋Œ€ ๋ฐฉํ–ฅ์œผ๋กœ ์—ฐ๊ฒฐํ•˜์—ฌ end_crv์˜ ๋ฐฉํ–ฅ์„ ๋ฐ” ๋กœ ์žก์Šต๋‹ˆ๋‹ค. COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 05


USING A SUBROUTINE (FUNCTION) IN VB COMPONENT ์ด์ œ VB custom ์˜ค๋ธŒ์ ํŠธ๊ฐ€ ์ž˜ ์ž‘๋™์„ ํ•ฉ๋‹ˆ๋‹ค. ์ด๋ฒˆ์—๋Š” ์ปดํฌ๋„ŒํŠธ์˜ ํƒ€์ž…์— ์˜๊ฑฐํ•ด์„œ ์ด ์ปดํฌ๋„ŒํŠธ๋“ค์„ ๋ฐฐ์—ดํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋‚˜ ์•„๋ž˜ ๊ทธ๋ฆผ์—์„œ ๋ณด๋“ฏ ์•„์ง ๋„ ๋ณต์‚ฌ์™€ ๋ถ™์ž„์ด๋ผ๋Š” ๊ณผ์ •์„ ๊ฑฐ์ณ์•ผ ํ•˜๋ฏ€๋กœ ์—ญ์‹œ๋‚˜ ๋ฒˆ๊ฑฐ๋กญ๊ณ  ๋”๋”˜ ์ž‘์—…์ด ๋ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. (003 subroutine component VB.ghx ํŒŒ์ผ์„ ์ฐธ์กฐํ•˜์„ธ์š”)

ํ•˜์ง€๋งŒ ์šฐ๋ฆฌ๊ฐ€ VB scripting์˜ ์„œ๋ธŒ๋ฃจํ‹ด์˜ ๊ฐœ๋…์„ ์ดํ•ด ํ•œ๋‹ค๋ฉด ์ด๋ ‡๊ฒŒ ๊ธด ์ฝ”๋“œ๋ฅผ ์ข€๋” ํšจ์œจ์ ์œผ๋กœ ์ค„์ผ์ˆ˜๋„ ์žˆ์„๊ฒ๋‹ˆ๋‹ค. ์„œ๋ธŒ๋ฃจํ‹ด์ด๋ž€ ์ผ์ข…์˜ ์‚ฌ์šฉ์ž ํ•จ์ˆ˜์™€ ๊ฐ™์€ ๊ฐœ๋…์ธ๋ฐ, ์ผ๋‹จ ์ •์˜๋ฅผ ํ•ด ๋†“์œผ๋ฉด, ์„œ๋ธŒ๋ฃจํ‹ด์€ ์šฐ๋ฆฌ๊ฐ€ VB scripting์—์„œ line์ด๋ผ๋Š” ๊ณต์šฉ ํ•จ์ˆ˜๋ฅผ ์“ฐ๋Š”๊ฒƒ๊ณผ ๋™์ผํ•˜๊ฒŒ ์‚ฌ์šฉํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

line(start point, direction vector, distance)

์˜ˆ๋ฅผ ๋“ค์–ด, FunctionA๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ์„œ๋ธŒ๋ฃจํ‹ด์„ ๋งŒ๋“ค๊ณ  ์‹ถ๋‹ค๊ณ  ํ•ฉ์‹œ๋‹ค. ์ด ์„œ๋ธŒ๋ฃจํ‹ด์€ ๋‘๊ฐœ์˜ input๊ณผ ํ•˜๋‚˜์˜ output์œผ๋กœ ์ด๋ค„์ ธ ์žˆ๊ณ  ์–ด๋–ค์ผ์ธ๊ฐ€๋ฅผ ํ•˜๊ฒŒ ๋ฉ๋‹ˆ ๋‹ค. ์ด ํ•จ์ˆ˜๊ฐ€ ์ž‘๋™ํ•˜๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ ์šฐ๋ฆฌ์˜ VB ์ฝ”๋“œ๋‚ด์˜ ์–ด๋”˜๊ฐ€์—”๊ฐ€๋Š” ์ด ํ•จ์ˆ˜๊ฐ€ ๋ฌด์—‡์„ ํ•˜๋Š” ํ•จ์ˆ˜์ธ์ง€์—๋Œ€ํ•ด ์ •์˜๋ฅผ ํ•ด์ค˜์•ผ ํ•˜๋ฉฐ ๋˜ ๋‹ค๋ฅธ ์–ด๋–ค ๋ถ€๋ถ„์ธ๊ฐ€์— ์„œ๋Š” ์ด ํ•จ์ˆ˜๋ฅผ ์‹ค์ œ๋กœ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด call ํ•˜๋Š” ๋ถ€๋ถ„๋„ ์žˆ์–ด์•ผ ํ• ๊ฒƒ ์ž…๋‹ˆ๋‹ค. ํ•จ์ˆ˜์˜ ์ •์˜๋Š” ๋ณดํ†ต Custom additional code ๋ฅผ ์œ„ํ•œ ๋ณ„๋„์˜ ๊ณต๊ฐ„์— ์œ„์น˜ํ•˜๊ฒŒ ๋˜ ๋ฉฐ ํ•จ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด callํ•˜๋Š” ๋ถ€๋ถ„์€ ์šฐ๋ฆฌ๊ฐ€ ํ”ํžˆ ์ฝ”๋“œ๋ฅผ ์ž…๋ ฅํ•˜๋Š” ๊ณณ์— ์œ„์น˜ํ•˜์—ฌ์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•จ์ˆ˜์˜ ์ •์˜์‹œ ๋ˆˆ์—ฌ๊ฒจ ๋ด์•ผ ํ•  ๋ถ€๋ถ„์€ ByVal๊ณผ ByRef์ธ๋ฐ์š”, ByVal์€ ์ด ๋ณ€์ˆ˜๊ฐ€ input๋ณ€์ˆ˜๋ผ๋Š” ๊ฒƒ์„ ๋งํ•˜๊ณ  ByRef๋Š” ์ด ๋ณ€์ˆ˜๊ฐ€ output ํŒŒ๋ผ๋ฉ”ํ„ฐ๋ผ๋Š” ๊ฒƒ์„ ์•”์‹œํ•˜์—ฌ ์ค๋‹ˆ๋‹ค.

FunctionA (ByVal input1, ByVal input2, ByRef output1)

โ€˜<Custom additional code> Sub FunctionA (ByVal input1, ByVal input2, ByRef output1) ...... End Sub โ€˜</Custom additional code>

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 06


์Šคํฌ๋ฆฝํŠธ ์—๋””ํ„ฐ๋ฅผ ์—ด๊ณ 

๊ทธ๋‹ค์Œ ์ด๋ฅผ

โ€œPrivate Sub ~โ€ ์—์„œ โ€œEnd Subโ€ ๊นŒ์ง€๋ฅผ ๋ณต์‚ฌํ•ฉ๋‹ˆ๋‹ค.

โ€˜<Custom additional code> ๊ณผ โ€˜</Custom additional code> ์‚ฌ์ด์˜ ๊ณต๊ฐ„์— ๋ถ™์—ฌ ๋„ฃ์Šต๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 07


๊ทธ๋ฆฌ๊ณ  ๋‹ค์Œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ํ•จ์ˆ˜์˜ ์ด๋ฆ„์„ ์ •์˜ ํ•ด ์ค๋‹ˆ๋‹ค. ์ด๋ฒˆ ๊ฒฝ์šฐ๋Š” ํ•จ์ˆ˜์˜ ์ด๋ฆ„์ด component์ž…๋‹ˆ๋‹ค.

์ด์ œ VB์˜ค๋ธŒ์ ํŠธ์˜ ์‹ค์งˆ์ ์ธ input๊ณผ outputํƒญ์„ ๋‹ค์Œ ๊ทธ๋ฆผ๊ณผ ๊ฐ™์ด ๋ฐ”๊พธ์–ด ์ค๋‹ˆ๋‹ค. input์€ celltype์ด๋ผ๋Š” string ๋ณ€์ˆ˜๊ฐ€ ์ถ”๊ฐ€๋˜๊ณ  ์„ธ๊ฐœ์˜ ์ถ”๊ฐ€์ ์ธ ์‚ฌ์ž‡๊ฐ ๋ณ€์ˆ˜๊ฐ€ ์ถ”๊ฐ€๋œ๊ฒƒ์„ ์ œ์™ธํ•˜๊ณ ๋Š” ๊ฑฐ์˜ ์ด์ „๊ณผ ๋™์ผํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ ์ค‘์š”ํ•œ ๊ฒƒ์€ celltype์ด๋ผ๋Š” ๋ฌธ์ž์—ด ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค. ์ด ๋ณ€์ˆ˜๋Š” ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ์ปดํฌ๋„ŒํŠธ๋“ค์ด ์–ด๋– ํ•œ ๋ฐฐ์—ด๋กœ ์—ฐ๊ฒฐ๋˜์–ด ์žˆ๋Š”์ง€๋ฅผ ์ •์˜ํ•˜๋Š” ๋ณ€์ˆ˜์ž…๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 08


CODE REVIEW ์ด๋ฒˆ์—๋Š” VB ์˜ค๋ธŒ์ ํŠธ์˜ ์ฝ”๋“œ๋ฅผ ํ•œ์ค„์”ฉ ์‚ดํŽด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. VB ์˜ค๋ธŒ์ ํŠธ๋ฅผ ๋”๋ธ”ํด๋ฆญํ•˜๋ฉด ์Šคํฌ๋ฆฝํŠธ๋ฅผ ์ˆ˜์ •ํ• ์ˆ˜ ์žˆ๋Š” ์ฐฝ์ด ๋‚˜์˜ต๋‹ˆ๋‹ค.

โ€˜defines output parameters ////////////////////////////////////////////////////////////////////////////////////// Dim pivot_cell_list As New List(Of circle) Dim pivot_pt_list As New List(Of point3d) Dim start_leg_list As New List(Of Line) Dim start_leg_pt_list As New List(Of point3d) Dim end_leg_list As New List(Of Line) Dim end_leg_pt_list As New List(Of point3d) Dim end_crv_list As New List(Of Line) โ€ข

์ด ๋ถ€๋ถ„์—์„œ๋Š” VB์ปดํฌ๋„ŒํŠธ์˜ output ๊ฐ’๋“ค์„ ์ •์˜ ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ณต์ˆ˜์˜ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉฐ ์ด๋“ค์˜ ๋ชจ๋“  ์š”์†Œ๋“ค, ์ฆ‰ start line, start leg, pivot cell, pivot point, end leg, end line๋“ฑ๋“ฑ์ด ๋ชจ๋‘ ๋ทฐํฌํŠธ์ƒ์— ์ถœ๋ ฅ๋˜๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด์„œ ๋‹จ์ผ ๊ฐ’๋ณด๋‹ค๋Š” ๋ฆฌ์ŠคํŠธ์˜ ํ˜•ํƒœ๋กœ ์ถœ๋ ฅ์„ ํ•˜๋Š”๊ฒƒ์ด ๋” ๋ฐ” ๋žŒ์งํ•ฉ๋‹ˆ๋‹ค.

โ€˜defines output parameters of โ€œcomponentโ€ subroutine ///////////////////////////////////////////////////////////// Dim pivot_cell As circle Dim pivot_pt As point3d Dim start_leg As line Dim start_leg_pt As point3d Dim end_leg As line Dim end_leg_pt As point3d Dim end_crv As line โ€ข

์ด ๋ถ€๋ถ„์€ ์„œ๋ธŒ๋ฃจํ‹ด์˜ output ํŒŒ๋ผ๋ฉ”ํ„ฐ๋“ค์„ ์ •์˜ ํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์šฐ๋ฆฌ๊ฐ€ ์„œ๋ธŒ๋ฃจํ‹ด์„ callํ•˜๊ธฐ ์ „์— ์ด ๋ณ€์ˆ˜๋“ค์„ ์„ค์ •ํ•ด๋†“์ง€ ์•Š๋Š”๋‹ค๋ฉด VB์˜ค๋ธŒ์ ํŠธ๋Š” ์— ๋Ÿฌ๋ฉ”์„ธ์ง€๋ฅผ ๋‚˜ํƒ€๋‚ด๊ฒŒ ๋  ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ์™€๋Š” ๋ฐ˜๋Œ€๋กœ ์„œ๋ธŒ๋ฃจํ‹ด์˜ input ๋ณ€์ˆ˜๋“ค์€ ๋ฏธ๋ฆฌ ์ •์˜ํ•  ํ•„์š”๊ฐ€ ์—†์Šต๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์ด ๋ณ€์ˆ˜๋“ค์€ ์„œ๋ธŒ๋ฃจํ‹ด ๋‚ด์—์„œ ์ •์˜๊ฐ€ ๋˜๊ฑฐ๋‚˜ ํ˜น์€ VB์˜ค๋ธŒ์ ํŠธ ์ž์ฒด์˜ input ๋ณ€์ˆ˜์ด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค.

โ€˜defines rotation_ang /////////////////////////////////////////////////////////////////////////////////////////// Dim rotation_ang As Double โ€ข

์ด๋ถ€๋ถ„์€ ์‚ฌ์ž‡๊ฐ์„ ์ •์˜ ํ•˜๋Š”๋ฐ์š”, ๋„ค๊ฐœ๋‚˜ ์‚ฌ์ž‡๊ฐ์„ ์ž…๋ ฅํ•˜๋ฉด์„œ ์™œ ๋˜ ๋‹ค๋ฅธ ๋ณ€์ˆ˜๊ฐ€ ํ•„์š”ํ•œ๊ฑธ๊นŒ์š”. ์ด๋Š” ๋„ค๊ฐ€์ง€ ๋‹ค๋ฅธ ๊ฒฝ์šฐ์— ๊ฐ๊ฐ ๋‹ค๋ฅธ ์‚ฌ์ž‡๊ฐ์„ ์ž…๋ ฅ ํ•˜๊ฒŒ ๋˜๋ฏ€๋กœ ์•„์ง์€ ์–ด๋–ค ๊ฐ’์ด ์‚ฌ์ž‡๊ฐ์œผ๋กœ ๋“ค์–ด๊ฐˆ์ง€ ๋ชจ๋ฅด๊ธฐ ๋•Œ๋ฌธ์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ๋ฏธ๋ฆฌ ๊ฐ€์ƒ์˜ ๊ฐ’์„ ์ •ํ•ด ๋†“๊ณ  ๊ฒฝ์šฐ์— ๋”ฐ๋ผ ์ด ๊ฐ€์ƒ์˜ ๊ฐ’์— ๋‹ค๋ฅธ ๊ฐ’์„ ๋ฐ”๊ฟ”์น˜๊ธฐ ํ•จ์œผ๋กœ์จ ๋ณต์ˆ˜์˜ ๊ฒฝ์šฐ์˜ ์ˆ˜์— ์œ ์—ฐํ•˜๊ฒŒ ๋Œ€์ฒ˜ํ• ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 09


โ€˜checks component types and computes output based on the types ///////////////////////////////////////////////// For i As Integer = 0 To celltype.Count - 1 If i = 0 Then If celltype(i) = โ€œAโ€ Then rotation_ang = A_ang Else If celltype(i) = โ€œBโ€ Then rotation_ang = B_ang Else If celltype(i) = โ€œCโ€ Then rotation_ang = C_ang Else If celltype(i) = โ€œDโ€ Then rotation_ang = D_ang End If component(int_line, r, rotation_ang, pivot_cell, pivot_pt, start_leg, start_leg_pt, end_leg, end_leg_pt, end_crv) โ€ข โ€ข โ€ข

์ด์ œ ์ปดํฌ๋„ŒํŠธ ํƒ€์ž…์„ ๋‚˜ํƒ€๋‚ด๋Š” ๋ฌธ์ž์—ด์— ์˜ํ•ด ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ฆ์‹์‹œํ‚ค๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. ๋ฌธ์ž์—ด์— ์–ผ๋งˆ๋‚˜ ๋งŽ์€ ๋ฌธ์ž๊ฐ€ ์žˆ๋Š”๊ฐ€์— ๋”ฐ๋ผ for ๊ตฌ๋ฌธ์„ ๋Œ๋ฆฝ๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์ด๋ฒˆ ํšŒ์ „์ด ์ฒซ๋ฒˆ์งธ๋ผ๋ฉด(if i = 0 then), โ€œint_lineโ€, ์ฆ‰ ๋ผ์ด๋…ธ์—์„œ ๋งŒ๋“  ์ดˆ๊ธฐ ์ง€์˜ค๋ฉ”ํŠธ๋ฆฌ๊ฐ€ ์„œ๋ธŒ๋ฃจํ‹ด component์˜ ์ดˆ๊ธฐ ์ž…๋ ฅ๊ฐ’์ด ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€ ์•Š์€ ๊ฒฝ์šฐ๋Š” ๋ฐ”๋กœ ์ด์ „์˜ ์—ฐ์‚ฐ์—์„œ ๊ฒฐ๊ณผ๋ฌผ๋กœ ๋‚˜์˜จ โ€œend_crvโ€๋ฅผ ์„œ๋ธŒ๋ฃจํ‹ด์˜ ์ž…๋ ฅ๊ฐ’์œผ๋กœ ์‚ฌ์šฉํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋‹ค์Œ ์ค„์—์„œ๋Š” ์–ด๋– ํ•œ ํƒ€์ž… ๋ฌธ์ž (A/B/C/D)๊ฐ€ ๋‚˜์˜ค๋Š”์ง€์— ๋”ฐ๋ผ ๊ฐ๊ธฐ ๋‹ค๋ฅธ ์‚ฌ์ž‡๊ฐ โ€œrotation_angโ€์„ ์ ์šฉํ•˜๋Š” ์ง€์— ๋Œ€ํ•œ ๋‚ด์šฉ์ž…๋‹ˆ๋‹ค. ๊ทธ ๋‹ค์Œ์—์„œ๋Š” ๋“œ๋””์–ด ์„œ๋ธŒ๋ฃจํ‹ด component๋ฅผ ํ˜ธ์ถœํ•˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ์ž…๋ ฅ์€ โ€œint_lineโ€(input geometry), โ€œrโ€(radius of a circle) ๊ณผ โ€œrotation_angโ€ ์ด๋ฉฐ ์ด๋ฅผ ํ†ตํ•ด ์šฐ๋ฆฌ๋Š” โ€œpivot_cellโ€, โ€œstart_legโ€, โ€œstart_leg_ptโ€, โ€œend_legโ€, โ€œend_leg_ptโ€, ๊ณผ โ€œend_crvโ€ ๋ฅผ ์–ป์Šต๋‹ˆ๋‹ค.

โ€ข โ€ข

Else If celltype(i) = โ€œAโ€ Then rotation_ang = A_ang Else If celltype(i) = โ€œBโ€ Then rotation_ang = B_ang Else If celltype(i) = โ€œCโ€ Then rotation_ang = C_ang Else If celltype(i) = โ€œDโ€ Then rotation_ang = D_ang End If int_line = end_crv component(int_line, r, rotation_ang, pivot_cell, pivot_pt, start_leg, start_leg_pt, end_leg, end_leg_pt, end_crv) End If โ€ข

์„œ๋ธŒ๋ฃจํ‹ด์„ ํ˜ธ์ถœํ•˜๊ธฐ ์ „ โ€œend_crvโ€ ๋ฅผ ๋‹ค์Œ iteration ์„ ์œ„ํ•œ ์ดˆ๊ธฐ๊ฐ’์ธ โ€œint_lineโ€ ์— ํ• ๋‹นํ•ฉ๋‹ˆ๋‹ค. COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 10


pivot_cell_list.Add(pivot_cell) pivot_pt_list.Add(pivot_pt) start_leg_list.Add(start_leg) start_leg_pt_list.Add(start_leg_pt) end_leg_list.Add(end_leg) end_leg_pt_list.Add(end_leg_pt) end_crv_list.Add(end_crv) Next โ€ข

๊ฐ๊ฐ์˜ iteration์—์„œ ๋ฐœ์ƒํ•œ output๊ฐ’์„ ๋ฆฌ์ŠคํŠธ์˜ ํ˜•ํƒœ๋กœ ์ €์ •ํ•ฉ๋‹ˆ๋‹ค.

โ€˜output ///////////////////////////////////////////////////////////////////////////////////////////////////////////// A = pivot_cell_list B = pivot_pt_list C = start_leg_list D = start_leg_pt_list E = end_leg_list F = end_leg_pt_list G = end_crv_list โ€ข

์ด ๋ณ€์ˆ˜๋“ค์„ ๋ผ์ด๋…ธ ๋ทฐํฌํŠธ์— ๋ฟŒ๋ ค์ฃผ๊ธฐ ์œ„ํ•ด A,B,C,D,E,F,G๋ผ๋Š” output ํƒญ์— ์—ฐ๊ฒฐ ์‹œํ‚ต๋‹ˆ๋‹ค.

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 11


STEP03 PACKED

OPTIMUM SOLUTION BY GALAPAGOS

์ฃผ์ง€ํ•˜๋‹ค์‹œํ”ผ, ์ปดํฌ๋„ŒํŠธ๋“ค์„ ์•„์ฃผ ๊ธด๋ฐ€ํ•˜๊ฒŒ ์—ฐ๊ฒฐ์‹œํ‚ค๊ธฐ ์œ„ํ•ด ์šฐ์ธก ๋‹ค ์ด์–ด๊ทธ๋žจ์˜ ๋‘ ๊ฑฐ๋ฆฌ๊ฐ’์˜ ํ•ฉ์€ ๋˜๋„๋ก ์ž‘์•„์•ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ Galapagos ๋Š” ์ตœ์†Œ๊ฐ’์ด ์•„๋‹Œ ์ตœ๋Œ€๊ฐ’์„ ์ฐพ๋„๋ก ์„ค๊ณ„๋˜์–ด์ ธ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ์œ„ํ•ด ์šฐ ๋ฆฌ๋Š” ๋‘๊ฐ’์„ ํ•ฉํ•œํ›„ ์ด์˜ ์—ญ์ˆ˜๋ฅผ ๊ตฌํ•ด์„œ ์ด ๊ฐ’์ด ์ตœ๋Œ€๊ฐ€ ๋˜๋Š” ์‚ฌ์ž‡๊ฐ์˜ ์กฐํ•ฉ์„ Galapagos์—๊ฒŒ ์ฐพ๋„๋ก ํ•ฉ๋‹ˆ๋‹ค. (004 galapagos.ghx ํŒŒ์ผ์„ ์ฐธ์กฐํ•˜์„ธ์š”) โ€ข โ€ข โ€ข โ€ข โ€ข โ€ข

VB ์—์„œ ์ƒ์„ฑ๋œ end line์ค‘ ์ œ์ผ ๋งˆ์ง€๋ง‰ ๋ผ ์ธ๊ณผ start line์ค‘ ๊ฐ€์žฅ ์ฒซ๋ฒˆ์งธ ๋ผ์ธ์„ ์ฐพ๋Š”๋‹ค. ์ด๋“ค์ด ์–‘๋์ ์„ ์ฐพ์•„ ์‹œ์ž‘์ ๋ผ๋ฆฌ์˜ ๊ฑฐ๋ฆฌ์™€ ๋์ ๋ผ๋ฆฌ์˜ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ•ด D1, D2๋ผ ์ •์˜ ํ•œ๋‹ค. ๋‘ ๊ฐ’์„ ํ•ฉํ•œํ›„ ์—ญ์ˆ˜๋ฅผ ์ทจํ•œ๋‹ค. Galapagos์˜ Genomeํƒญ์— ์‚ฌ์ž‡๊ฐ ์Šฌ๋ผ์ด๋” ๋“ค์„ ์—ฐ๊ฒฐํ•ด ์ค€๋‹ค. Galapagos์˜ Fitness ํƒญ์„ ๊ฑฐ๋ฆฌ๊ฐ’์˜ ์—ญ์ˆ˜์™€ ์—ฐ๊ฒฐํ•œ๋‹ค. Galapagos๋ฅผ ๋”๋ธ”ํด๋ฆญํ•˜์—ฌ solver ํƒญ์œผ๋กœ ์ด ๋™ํ›„ start solver๋ฒ„ํŠผ์„ ๋ˆ„๋ฅธํ›„ ์—ฐ์‚ฐ์ด ์™„๋ฃŒ ๋ ๋•Œ ๊นŒ์ง€ ๊ธฐ๋‹ค๋ฆฐ๋‹ค.

D1

D2

COMPONENT PACKING VB + GALAPAGOS - http://woojsung.com 12


Turn static files into dynamic content formats.

Createย aย flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.