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: ejrolon, Barry Kelly, Karl Ottenstein, LaszloNagy, Gordana Radonic, nbalogh, gkmethy, mnguyen, rmasaki, Akos Somorjai, Peter Baksa, Csilla Mai

#325950
Hello everyone,

I have two questions related to Label for objects.
Question 1 :
I have created a Label that reads values of parameters in objects by using request (ASSOCLP_PARVALUE).
it works well, if the parameter inside the object is String or Number.
But when I have an array of parameters (by using DIM and VALUES{2}), I get the value as number but I cannot get the description by using PARVALUE_DESCRIPTION ("parameter").
here is the code:
Code: Select all
! "Steckdose_typ" is an array with values and descriptions
rrr = request ("ASSOCLP_PARVALUE", "Steckdose_typ", Steckdose_typ)
AC_MarkerText_5 = PARVALUE_DESCRIPTION ("Steckdose_typ")         ! this didn't work
AC_MarkerText_5 = str ("%.0", Steckdose_typ)       !I got the value as number
Question 2:
When I insert the Label it is created far away from the object. How do I create the Label directly over the object? I am using a simple text command
Code: Select all
text2 0.125,0,AC_MarkerText_5
best regards,
#325957
I've got an answer to your second question. Because label can have a pointer line with arrow - there is a global variable, that describes coordinates of three points of the pointer. If you want, that label would be located exactly where you placed it, you need to shift it. To do so, use this script:
Code: Select all
ADD2 LABEL_POSITION[2][1]+LABEL_POSITION[3][1], LABEL_POSITION[3][2]
#325961
For the first question, you might want to look at the request "ASSOCLP_PARVALUE_WITH_DESCRIPTION".

Since your "Steckdose_typ" is an array, the variable "p_values_and_descriptions" should be too.

!2D Script
Code: Select all
dim p_values_and_descriptions[]
n = REQUEST ("ASSOCLP_PARVALUE_WITH_DESCRIPTION", "Steckdose_typ", name_or_index, type, flags, dim1, dim2, p_values_and_descriptions)

for i = 1 to vardim1(p_values_and_descriptions)
	text2 0, i, p_values_and_descriptions[i]
next i
#325973
Ah, of course, PARVALUE_DESCRIPTION ("parameter") is not working, because it's the wrong command. It simply does not exist in GDL.
The only way to extract a description is how Palawat is showing.
Code: Select all
rrr = request ("ASSOCLP_PARVALUE", "Steckdose_typ", Steckdose_typ)

also not working, because it has wrong form. It must look like that:
Code: Select all
rrr = REQUEST ("ASSOCLP_PARVALUE", "Steckdose_typ", name_or_index, type, flags, dim1, dim2, Steckdose_typ)
#325976
Thanks to you guys for your support, it worked!
here is the code:
Code: Select all
! Step 1: Requesting the values of parameters in objects
!--------------------------------------------------------
number_of_sockets = 1		! Parameter 1 (Integer)
n = request ("ASSOCLP_PARVALUE", "Steckdose_anzahl",name_or_index, type, flags, dim1, dim2, number_of_sockets)

dim p_values_and_descriptions[] 	! Parameter 2 (array)
n = REQUEST ("ASSOCLP_PARVALUE_WITH_DESCRIPTION", "Steckdose_typ", name_or_index, type, flags, dim1, dim2, p_values_and_descriptions)

! Step 2: Inserting the values in textfields
!-------------------------------------------
font_size 	=1.5
font_size_m =font_size/1000*GLOB_SCALE 	! font size in meters
DEFINE STYLE "fontstyle_label" "Candela Book",font_size,4,0
SET STYLE "fontstyle_label"

ADD2 LABEL_POSITION[2][1]+LABEL_POSITION[3][1], LABEL_POSITION[3][2]  	! to move the Text to the origin of the Label
offset_textbox = 0.075			! offset between the text and the object

! Inserting the value of parameter 1 and only the description of parameter 2
for i = 2 to vardim1(p_values_and_descriptions)   	! i=2 to skip the the value of parameter 2 in the array
	text2 offset_textbox,0,str ("%.0", number_of_sockets) + "X " + p_values_and_descriptions[i]
next i

! Inserting the elevation of the object as text
text2 offset_textbox,-(font_size_m+0.005),"H:" + STR(GLOB_ELEVATION,5,2)+ "m"

! a fill to make the selection of the Label easier
width_textbox = 0.5
add2 offset_textbox,font_size_m-0.02

fill "Nur Hintergrund-Stift"
poly2_b{5} 5,2,1,3,195,0,
 0,0,1,0,0,1,0,
 0,0,33,
 0,-font_size_m*3,33,
 width_textbox,-font_size_m*3,33,
 width_textbox,0,33,
 0,0,33

 ! drawing a line to the object 
line2 0,0,-0.1,0
Label_object.JPG
Label_object.JPG (38.71 KiB) Viewed 184 times
#325977
I might recommend to make few small adjustments:

Instead of naming Fill in the script, use better GLOB_FILL_INDEX_SOLID or GLOB_FILL_INDEX_BACKGROUND (works since version 22). It's better, because if by some reason in another file named fill is missed, you will receive an error.

Also, if array p_values_and_description has only two entries, there is no point to use loop FOR - NEXT.
You can just get second entry from array: p_values_and_description[2]
#326152
Hi,
Ah, of course, PARVALUE_DESCRIPTION ("parameter") is not working, because it's the wrong command. It simply does not exist in GDL.
It does exist, you need to specify array indices when using it with an array.