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

Converting integer/numeric data to text data

Anonymous
Not applicable
Hi, as the title says I was wondering if there is a way to convert an integer/numeric data into a text data (please bear with my scripting ignorance).
What I'm trying to create is a label for my roofs. It's a simple triangle with 2 different text values that indicates the roof slope (only 2d). What I've done so far is: I created a new Integer Parameter named as 'Roof Slope' and I'm using that value in order to change the length in the triangle sides and also replace the text accordingly (so far everything works). The problem is that I need that same value from the 'Roof Slope Parameter' to show up also as TEXT, replacing the one of the two originally texts that I have in there. Is there a way to achieve that??
Thanks!
10 REPLIES 10
sinceV6
Advocate
Hi.

Look into the string functions in the GDL reference guide. The STR and STR{2} functions.

Best regards.
Anonymous
Not applicable
Thanks for your quick responce sinceV6. I tried the STR command as it says on the reference guide but it didn't work. Here is my script:
mul2     A/0.474913, B/0.443089
add2     19'-3.5711", -24'-8.9653"
pen     penAttribute_1
hotspot2 -18'-8.8737", 24'-8.9653"
hotspot2 -18'-8.8737", 25'-8.9653"
hotspot2 -17'-8.8737", 25'-8.9653"
hotspot2 -19'-0.2224", 25'-3.0683"
hotspot2 -18'-3.0084", 25'-11.6875"
pen     penAttribute_2
line_property       0
line2    -18'-8.8737", 24'-8.9653", -18'-8.8737", 24'-8.9653" + (RoofSlope * 1")
line2    -18'-8.8737", 24'-8.9653" + (RoofSlope * 1"), -17'-8.8737", 24'-8.9653" + (RoofSlope * 1")
line2    -17'-8.8737", 24'-8.9653" + (RoofSlope * 1"), -18'-8.8737", 24'-8.9653"
define style{2}    "AC_STYLE_1" "Georgia", 8'-1.2222",      0

paragraph		"AC_PRG_3"      2, 0'-0.0000", 0'-0.0000", 0'-0.0000", 2'-3.5591"
    pen     penAttribute_3
    set style "AC_STYLE_1"
        "12"
endparagraph
textblock		"AC_TEXTBLOCK_3" 0'-0.0000",      8, 0'-0.0000", 3'-3.3701", 3'-3.3701", 3'-3.3701", 
        "AC_PRG_3"
richtext2		-18'-3.0084", 25'-8.9653" - (12" - (RoofSlope * 1")), "AC_TEXTBLOCK_3"

paragraph		"AC_PRG_4"      2, 0'-0.0000", 0'-0.0000", 0'-0.0000", 3'-3.3701"
		STR(RoofSlope)	
endparagraph
textblock		"AC_TEXTBLOCK_4" 0'-0.0000",      6, 0'-0.0000", 3'-3.3701", 3'-3.3701", 3'-3.3701", 
        "AC_PRG_4"
richtext2		-18'-8.8737", 25'-3.0683" - ((12" - (RoofSlope * 1")) / 2), "AC_TEXTBLOCK_4"
The problem is in fifth line from the bottom STR(RoofSlope)...Any ideas??
sinceV6
Advocate
Yes. You are missing parameters.
The function is: STR (numeric_expression, length, fractions) or STR (format_string, numeric_expression). All explained in the reference guide.

In your case, try something like:

STR(RoofSlope,6,2)

Best regards.
Anonymous
Not applicable
Thank you very much for your help!! It worked like you said. The problem is that I have no knowledge in scripting and although I spent a few hours in reading this quide, most of those symbols still look Chinese to me (I would have say Greek but I'm Greek)
sinceV6
Advocate
Glad I could help.

At first glance, the guide is not that friendly. It is more technical sort of writing; but once you get how it is structured, it's an invaluable resource (along with the other GDL books out there).

Best regards.
Anonymous
Not applicable
Hello again, I was wondering if you could help me a bit more in my attemt to create this Roof Slope Label. What I'm trying to add in the script (and it's going to affect only the text positioning) is this :
-If the object is mirrored along the y axis then mirror also the text along it's anchor point (I'm not sure if it keeps the anchor point or I should use one of the hotspots that I have)
-If the object is mirrored along the x axis, then do nothing.
Probably sounds a very easy command but I've tried so many different things without any luck...

Thanks!!
sinceV6
Advocate
Hi.
Sure thing.
It kind of depends how your object is scripted and the parameters you have. A screenshot of the problem and how the object works would help a lot, otherwise is just guessing.

I'm assuming you want readable text? Check if the solution I posted here:

http://archicad-talk.graphisoft.com/viewtopic.php?t=47251

Read the thread and other solutions, and eee if that helps.

Best regards.
Anonymous
Not applicable
Once again thanks for your quick responce!! So, here is the code that I have so far :
mul2     A/0.474913, B/0.443089
add2     19'-3.5711", -24'-8.9653"
pen     penAttribute_1
hotspot2 -18'-8.8737", 24'-8.9653"
hotspot2 -18'-8.8737", 24'-8.9653" + (RoofSlope * 1")
hotspot2 -17'-8.8737", 24'-8.9653" + (RoofSlope * 1")
hotspot2 -19'-0.2224", 25'-3.0683" - ((12" - (RoofSlope * 1")) / 2)
hotspot2 -18'-3.0084", 25'-11.6875" - (12" - (RoofSlope * 1"))
pen     penAttribute_2
line_property       0
line2    -18'-8.8737", 24'-8.9653", -18'-8.8737", 24'-8.9653" + (RoofSlope * 1")
line2    -18'-8.8737", 24'-8.9653" + (RoofSlope * 1"), -17'-8.8737", 24'-8.9653" + (RoofSlope * 1")
line2    -17'-8.8737", 24'-8.9653" + (RoofSlope * 1"), -18'-8.8737", 24'-8.9653"
define style{2}    "AC_STYLE_1" "Georgia", 8'-1.2222",      0

paragraph		"AC_PRG_3"      2, 0'-0.0000", 0'-0.0000", 0'-0.0000", 2'-3.5591"
    pen     penAttribute_3
    set style "AC_STYLE_1"
        "12"
endparagraph
textblock		"AC_TEXTBLOCK_3" 0'-0.0000",      8, 0'-0.0000", 3'-3.3701", 3'-3.3701", 3'-3.3701", 
        "AC_PRG_3"

add2 -18'-3.0084", 25'-8.9653" - (12" - (RoofSlope * 1"))
viewRotation = 0
rrr = request("View_Rotangle", "", viewRotation)
mul2 1 - 2*symb_mirrored, 1
if symb_rotangle > 91 and symb_rotangle < 271 then
rot2 180
else
rot2 0
endif
richtext2		0, 0, "AC_TEXTBLOCK_3"
del 3

paragraph		"AC_PRG_4"      2, 0'-0.0000", 0'-0.0000", 0'-0.0000", 3'-3.3701"
		STR(RoofSlope,2,0)	
endparagraph
textblock		"AC_TEXTBLOCK_4" 0'-0.0000",      6, 0'-0.0000", 3'-3.3701", 3'-3.3701", 3'-3.3701", 
        "AC_PRG_4"
add2 -18'-8.8737", 25'-3.0683" - ((12" - (RoofSlope * 1")) / 2)
viewRotation = 0
rrr = request("View_Rotangle", "", viewRotation)
if symb_rotangle > 91 and symb_rotangle < 271 then
rot2 180
else
rot2 0
endif
richtext2		0, 0, "AC_TEXTBLOCK_4"
del 3
I've placed also a screenshot that shows the problem when I mirror the object along the x axis.
The script that controls the rotation of my text I found it on the net and after some tries that I did it seems to work but only for the mirroring along the y axis.
I've tried also to replace it with the code that you sent me
===CORRECT TEXT ORIENTATION===

MUL2 1 - 2 * SYMB_MIRRORED, 1 
ROT2 -SYMB_ROTANGLE * (SYMB_ROTANGLE <> 0)
but I get a message that says "Use of real types can result in precision problems". I clicked "OK" but it didn't work....
Roof Slope Image.jpg
sinceV6
Advocate
Don't really have time to try it, but I would look into the paragraph and textblock definitions, as textblocks do have an anchor parameter

TEXTBLOCK name, width, anchor, angle........
So that might be the problem when mirroring.

It looks like you saved this from the floor plan as an object, right? It would work OK with the original code, but when trying to make it parametric, you need to review the whole thing.

For simple texts like these, I would ditch the paragraph/textblock/richtext scenario, unless you need the options they provide, and use simple TEXT2 commands.