BIM Coordinator Program (INT) April 22, 2024

Find the next step in your career as a Graphisoft Certified BIM Coordinator!

GDL
About building parametric objects with GDL.

Refresh the variable

Anonymous
Not applicable
Hallo,

how do I reset the value of the variable "delka_2" if I change the value of the variable "sklon"?

It makes a mistake in the floor plan. See picture. The length of the line changes but the distance of the point no longer.

Thank you

MAIN code

IF	GLOB_MODPAR_NAME = "delka_3"	THEN
	PARAMETERS delka_2 = delka_3*cos(sklon)
	PARAMETERS A = delka_3
ENDIF
IF	GLOB_MODPAR_NAME = "delka_2"	THEN
	PARAMETERS delka_3 = delka_2/cos(sklon)
	PARAMETERS A = delka_2/cos(sklon)
ENDIF

2D code

		HOTSPOT2 0,				0, unID, delka_2, 1			: unID = unID +1
		HOTSPOT2 -1,			0, unID, delka_2, 3			: unID = unID +1
		HOTSPOT2 delka_2,		0, unID, delka_2, 2			: unID = unID +1

LINE2 0,0,A*cos(sklon),0
3D code

				HOTSPOT 0,				0,	0,				unID, sklon, 6		: unID = unID +1
				HOTSPOT A,				0,	0,				unID, sklon, 4		: unID = unID +1
				HOTSPOT A*cos(sklon),	0,	A*sin(sklon),	unID, sklon, 5			: unID = unID +1


LIN_ 0,0,0,A,0,0
ROTy -sklon

		HOTSPOT 0,			0,	0,	 unID, delka_3, 1			: unID = unID +1
		HOTSPOT -1,			0,	0,	 unID, delka_3, 3			: unID = unID +1
		HOTSPOT delka_3,	0,	0,	 unID, delka_3, 2			: unID = unID +1



LIN_ 0,0,0,A,0,0
3 REPLIES 3
The logic of your glob_modpar_name statements is saying that the delka_2 value will only change if the last parameter changed was the delka_3, hence it wont respond if you change the sklon value.
to fix this you should do:

if glob_modpar_name = "delka_2" then
	parameters delka_3 = delka_2/cos(sklon)
	parameters A = delka_2/cos(sklon)
else
	parameters delka_2 = delka_3*cos(sklon)
	parameters A = delka_3
endif
this way delka_2 always references the delka_3 and sklon values.
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
You should also set the values in a local parameter so you don't have to wait for the parameter to update for the 2D and 3D representations to update, like this:

if glob_modpar_name = "delka_2" then
	delka_3 = delka_2/cos(sklon)
	parameters delka_3 = delka_3
	A = delka_2/cos(sklon)
	parameters A = A
else
	delka_2 = delka_3*cos(sklon)
	parameters delka_2 = delka_2
	A = delka_3
	parameters A = A
endif
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
Personally I would tidy this up to read like this:

delka_2 = delka_3*cos(sklon)
A = delka_3
parameters 	delka_2 = delka_2,
		A = A
if glob_modpar_name = "delka_2" then
	delka_3 = delka_2/cos(sklon)
	parameters delka_3 = delka_3
endif
Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists
Learn and get certified!