Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Zone stamp 2d script, Need Help Please, Thanks.

Anonymous
Not applicable
Hi,
This my first attempt write GDL. I have tried to modify the Zone_Stamp_02.gsm to show the Occupant load Factor (set as integer) and an Occupant Load ((set as integer) of an area. In 2D script I am getting some sort of mismatch errors in two places but can not fix them after 5 hrs of trial! could any one guide me? (attach is the file)

!!!room_perim = "P: " + room_perim + lin_unit
room_perim = peritext + room_perim + lin_unit

!!!ol_factor = "OL Factor: " + ol_factor
ol_factor = olftext + ol_factor < HAVING PROBLEM WITH THIS LINE

code_string=basec!!!!+" "+wallc+" "+ceilc

set style "znamestyle"
w_roona = (stw (Zname)) * name !*** width of the strings - 0 if not displayed

set style "znumstyle"
w_roonu = (stw (ROOM_NUMBER)+2) * num

set style "codestyle"
w_code = (stw (code_string)+2) * code

set style "arstyle"
w_rooar = (stw (room_area)+2) * area

set style "pestyle"
w_peri = (stw (room_perim)+2) * peri

set style "chstyle"
w_roohe = (stw (room_height)+2) * ceil_s

set style "olffstyle"
w_olf = (stw (ol_factor)+2) * olf < HAVING PROBLEM WITH THIS LINE

max_len = max (name*w_roona, num*w_roonu, peri*w_peri, area*w_rooar, ceil_s*w_roohe, code*w_code, olf*w_olf) !*** width of the stamp
max_detlen = max (num*w_roonu, peri*w_peri, area*w_rooar, ceil_s*w_roohe, code*w_code, olf*w_olf)
max_h = - name*shight - (num + floor + area + peri + ceil_s + code + olf) * shight2 !*** height of the stamp
7 REPLIES 7
Ralph Wessel
Mentor
Joseph wrote:
In 2D script I am getting some sort of mismatch errors in two places...
...
ol_factor = olftext + ol_factor < HAVING PROBLEM WITH THIS LINE
...
w_olf = (stw (ol_factor)+2) * olf < HAVING PROBLEM WITH THIS LINE
In the first problem line, you are trying to add two values which are not the same kind. 'olftext' is a string (textual) value, and 'ol_factor' is an integer (numeric) value. The + operator in GDL is designed to only add things of the same kind, e.g. '1 + 1 = 2' or '"ABC" + "DEF" = "ABCDEF"'. The problem line says something like '1 + "ABC" = ???'

You can convert a number to a string with the STR function. So your line could be changed to:
ol_factor = olftext + STR(ol_factor, 8, 0)
Read the documentation on STR to determine how you can best use it. The script now works with this change, but I would recommend another related change. The variable called 'ol_factor' is a parameter with an integer value. In your script you subsequently assign a string value to it. Although this works, I recommend not changing a variable's type. Create a new variable instead:
olFactorText = olftext + STR(ol_factor, 8, 0)
...
w_olf = (STW(olFactorText) + 2) * olf
...
TEXT2 dist, -vlen, olFactorText
Ralph Wessel BArch
Active Thread Ltd
Anonymous
Not applicable
Ralph wrote:
In the first problem line, you are trying to add two values which are not the same kind. 'olftext' is a string (textual) value, and 'ol_factor' is an integer (numeric) value. The + operator in GDL is designed to only add things of the same kind, e.g. '1 + 1 = 2' or '"ABC" + "DEF" = "ABCDEF"'. The problem line says something like '1 + "ABC" = ???'
Thanks a million Jay,
Two more questions:

1. Based on what you say, In expression "w_olf = (STW(olFactorText) + 2) * olf" what is the reason for multiplying by "olf" parameter? Is it that if this parameter olf, is 1 if set to ON and 0 if set to OFF so we want to make the value of "w_olf " to zero when olf is set to OFF so will not have effect on other parts of the script?

Futher more, If so 1 or 0 are INTEGERS and olFactorText is TEXT?

2. Also based on what you say, the previous line of the code on ROOM_PERIM = PERITEXT + ROOM_PERIM + LIN_UNIT should not wok either since: ROOM_PERIM is lengthand I assume a REAL number and PERITEXT is text!?
Thanks,
Joseph
Ralph Wessel
Mentor
Joseph wrote:
1. Based on what you say, In expression "w_olf = (STW(olFactorText) + 2) * olf" what is the reason for multiplying by "olf" parameter? Is it that if this parameter olf, is 1 if set to ON and 0 if set to OFF so we want to make the value of "w_olf " to zero when olf is set to OFF so will not have effect on other parts of the script?
Futher more, If so 1 or 0 are INTEGERS and olFactorText is TEXT?
The STW function returns the (display) length of a string, i.e. it's size when it is displayed in a drawing. Therefore, STW(olFactorText) will give you the length of the string in the variable olFactorText.

The parameter olf is a boolean variable - it can only have two values or states which you could describe as true or false, on or off, 1 or 0. If you use a boolean value in an arithmetic expression, it will have the value 1 if it is set to true, or 0 if it is set to false.

This particular line will result in a length of 0 if 'olf' is false because it will be multiplied by 0. Otherwise, it will return the length of 'olFactorText + 2'.
Joseph wrote:
2. Also based on what you say, the previous line of the code on ROOM_PERIM = PERITEXT + ROOM_PERIM + LIN_UNIT should not wok either since: ROOM_PERIM is lengthand I assume a REAL number and PERITEXT is text!?
No, all the variables in that line are text. The author of the script has assigned text values to variables that were originally numbers:
room_perim = str (lin_form , ROOM_PERIM)
The confusion you are feeling is the reason for my suggestion to use different names rather than changing the type of an existing variable.
Ralph Wessel BArch
Active Thread Ltd
Anonymous
Not applicable
Ralph wrote:
The confusion you are feeling is the reason for my suggestion to use different names rather than changing the type of an existing variable.
Thanks and have a GREAT week end, after your guidance I will have a great one also.

Joseph
Anonymous
Not applicable
Ralph wrote:
No, all the variables in that line are text. The author of the script has assigned text values to variables that were originally numbers
Ralph,
I tried to get the integer (INT) portion of the parameter room_area so I can have the area with out the decimals (for better representation in the stamp), but I am getting an error.
I guess it is because it is converted to text somehow. Could you give me guidance how to convert it back to integer AND/OR not showing the decimals?
Thanks very much,
Joseph
Ralph Wessel
Mentor
Joseph wrote:
I tried to get the integer (INT) portion of the parameter room_area so I can have the area with out the decimals (for better representation in the stamp), but I am getting an error.
I guess it is because it is converted to text somehow.
Yes, it is converted on the following line:
room_area = str (area_form, Temp_CalcArea)
It would be better to use a different variable name for the text version so you can retain the original value (and the two can't be confused with each other), e.g.
roomAreaText = str (area_form, Temp_CalcArea)
The author of this object has used lower case for the text variable, so you could quickly change every instance with "Find & Replace..." provided you check the 'Case Sensitive' option.
Ralph Wessel BArch
Active Thread Ltd
Anonymous
Not applicable
Ralph wrote:
The author of this object has used lower case for the text variable, so you could quickly change every instance with "Find & Replace..." provided you check the 'Case Sensitive' option.
Welcome Back and here I go again,
I took your advice and changed all the
room_areas TO roomAreaText

A. This is how it looks:

IF ROOM_POLY_STATUS=0 then Temp_CalcArea=ROOM_CALC_AREA !! Method 1 and 2
IF ROOM_POLY_STATUS=1 then Temp_CalcArea=ROOM_CALC_AREA !! Method 3/Net
IF ROOM_POLY_STATUS=2 then Temp_CalcArea=ROOM_AREA !! Method 3/Gross

Temp_CalcAreaINT = INT (Temp_CalcArea) !!!!!<<<<<TO GET THE INTEGER

area_form="" !*** format as set in the Preferences
rrr=request ("Area_dimension","",area_form)
!! roomAreaText = str (area_form, Temp_CalcArea)
roomAreaText = str (area_form, Temp_CalcArea)

But to my surprise from the variable Temp_CalcAreaINT not only I do not get an integer but a value of ZERO?!

B. Then tried using from the "cook book" string=STR(item,6,1) gives you ‘123.5’ and applied it to:
roomAreaText = str (area_form, Temp_CalcArea,0) so I at lease get the area to show with out decimals I get an error?

C. On top of it all what is the variable area_form?

I have got a big headache with this, I hope I have not given it to you.
Thanks,
Joseph