The Global Archicad Community

Stay informed. Get help. Share your knowledge.

Topics specific to the scripting and development of Library Parts and Libraries using Param-O or the Geometric Description Language – GDL. (Example: How do you use “REQUEST” GDL commands?)

Moderators: Karl Ottenstein, LaszloNagy, ejrolon, Barry Kelly, Gordana Radonic, nbalogh, mnguyen, gkmethy, rmasaki, Akos Somorjai, Csilla Mai, Peter Baksa

By Vojta
#320957
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
Code: Select all
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
Code: Select all
		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
Code: Select all
				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
Attachments
Snímek obrazovky 2021-01-11 v 11.07.48.png
Snímek obrazovky 2021-01-11 v 11.07.48.png (1.97 KiB) Viewed 97 times
User avatar
By Kristian Bursell
#320978
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:
Code: Select all
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.
User avatar
By Kristian Bursell
#320979
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:
Code: Select all
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
User avatar
By Kristian Bursell
#320980
Personally I would tidy this up to read like this:
Code: Select all
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