License Delivery maintenance is expected to occur on Saturday, November 30, between 8 AM and 11 AM CET. This may cause a short 3-hours outage in which license-related tasks: license key upload, download, update, SSA validation, access to the license pool and Graphisoft ID authentication may not function properly. We apologize for any inconvenience.
GDL
About building parametric objects with GDL.
SOLVED!

gdl unit of text

lmcardoso
Booster

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

lmcardoso_0-1637520533026.png

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

 

ArchiCAD 23/25/27 with Win 10
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
DGSketcher
Legend

@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"

Apple iMac Intel i9 / macOS Sonoma / AC27UKI (most recent builds.. if they work)

View solution in original post

11 REPLIES 11

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.

lmcardoso
Booster

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... 

ArchiCAD 23/25/27 with Win 10

If you share the object I can help ya get it to work.

lmcardoso
Booster

thanks a lot!! i really appreciate it

ArchiCAD 23/25/27 with Win 10

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?

lmcardoso
Booster

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

 

lmcardoso_0-1637526854813.png

 

ArchiCAD 23/25/27 with Win 10

okay try this

 

TEXT2 A/2, B/2, ""+STR("%.3m",(A*B))+"m2"

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

This is a great answer if you're trying to accommodate multiple different disciplines!