We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2021-11-21 07:51 PM - last edited on 2021-11-24 03:46 PM by Laszlo Nagy
Hi,
I am a newbie in coding. sometimes i try to cook something but i end up spoiling the broth. i spent the last 30min reading the gdl editor on strings and integers but that thing is way to complex for me.
I am trying to change the units of the value of AxB but i cant seem to find it.
this is my object and now the area, which is no more than AxB is in millimiter but i want it in meters
this is my code
set line_type ln01
pen pen01
fill fill01
poly2_b{5} 5, 3, 0, pen01, pen02, pen03,
0, 0, 1, 0, 0, 1, 0,
0, 0, 1,
A, 0, 1,
A, B, 1,
0, B, 1,
0, 0, 1
define style{2} "AC_STYLE_1" "Arial", txsz , 0
paragraph "AC_PRG_7" 2, 0, 0, 0, 1
pen 1
set style "AC_STYLE_1"
""+"< "+STR(1000*A,1,0)+" >"
endparagraph
textblock "AC_TEXTBLOCK_7" 0, 5, 0, 1, 1, 1,
"AC_PRG_7"
richtext2 A/2, .2, "AC_TEXTBLOCK_7"
paragraph "AC_PRG_8" 2, 0, 0, 0, 1
""+"< "+STR(1000*B,1,0)+" >"
endparagraph
textblock "AC_TEXTBLOCK_8" 0, 5, 90, 1, 1, 1,
"AC_PRG_8"
richtext2 0.2, B/2, "AC_TEXTBLOCK_8"
IF txt01=1 THEN
DEFINE STYLE TEXT_1 Arial, txsz , 5 , 0
SET STYLE TEXT_1
TEXT2 A/2, B/2, ""+STR(1*A*B,1,0)+"m2"
ENDIF
Can anyone help me please?
p,s, yeah i guess my code is super complicated ahaha
Solved! Go to Solution.
2021-11-22 06:15 PM
@lmcardoso metric GDL coding is in meters by default, so you text should be...
TEXT2 A/2, B/2, "" + STR((A * B), 8, 3) + "m2"
2021-11-21 08:30 PM
you need to use STR{2} so you can set what you are after.
also you dont need the "set" for line_type or style to work.
2021-11-21 08:45 PM
thanks seneca, but for me that is still unknow to me.
i tried TEXT2 A/2, B/2, ""+STR{2}(1*A*Bsqm,1,0)+"m2"
but it doesnt work...
2021-11-21 08:54 PM
If you share the object I can help ya get it to work.
2021-11-21 08:56 PM
2021-11-21 09:26 PM
so maybe i am miss understanding, but if you change the code to
TEXT2 A/2, B/2, ""+STR(1000*(A*B),1,0)+"m2"
does this not get what you want?
2021-11-21 09:34 PM
i tried but that no it doesnt solve the problem. I guess its the units that are not right
what it should appear is 10,8m2 instead of 10800.
on your left a fil showing the area and on the right my object
2021-11-21 09:45 PM
okay try this
TEXT2 A/2, B/2, ""+STR("%.3m",(A*B))+"m2"
2021-11-21 11:54 PM
Another way, with reading the working units of the project
format_string = "%.0" !Defult
n = REQUEST ("Area_dimension", "", format_string)
!! Or
!!n = REQUEST ("Calc_area_unit", "", format_string)
_stUnit = "m"
if strstr (format_string, "mm") & not(_bUnitIsFound) then
_stUnit = " mm"
_bUnitIsFound = 1
endif
if strstr (format_string, "cm") & not(_bUnitIsFound) then
_stUnit = " cm"
_bUnitIsFound = 1
endif
if strstr (format_string, "m") & not(_bUnitIsFound) then
_stUnit = " m"
_bUnitIsFound = 1
endif
if strstr (format_string, "f") & not(_bUnitIsFound) then
_stUnit = " ft"
_bUnitIsFound = 1
endif
if strstr (format_string, "i") & not(_bUnitIsFound) then
_stUnit = " inch"
_bUnitIsFound = 1
endif
_stUnit = _stUnit + "²"
area_ = A * B
area_txt = str(format_string, area_) + _stUnit
Structural engineer, developer of free addon for sync GDL param and properties
2021-11-22 02:51 AM
This is a great answer if you're trying to accommodate multiple different disciplines!