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

incompatible expressions

Aussie John
Newcomer
if roof_angle<>0 then e=roof_angle +"º"

gives an error incompatible expression

Is there any way to combine numbers and text in a string?
Cheers John
John Hyland : ARINA : www.arina.biz
User ver 4 to 12 - Jumped to v22 - so many options and settings!!!
OSX 10.15.6 [Catalina] : Archicad 22 : 15" MacBook Pro 2019
[/size]
7 REPLIES 7
Rob
Graphisoft
Graphisoft
STR (numeric_expression, length, fractions)
The first form of the function creates a string from the current value
of the numeric expression. The minimum number for numerical
characters in the string is length, while fractions represents
the numbers following the floating point. If the converted value has
more than length characters, it is expanded as required. If it has
fewer characters, it is padded on the left (length > 0) or on the
right (length < 0).

John I have just copied that from AC help to explain what you have to do, so:

if roof_angle#0 then e=STR(roof_angle,3,2) +"º"

where

"3" stands for the number of digits of the integer part (assumingly 0° - 360°)
"2" stands for the number of digits after fl. point (assumingly 2 )

so result could be something like this 268.32°

...and do not forget to declare variable 'e' as a STRING type in the parameters script
::rk
tsturm
Newcomer
How does a person declare parameters in the Parameter Script?

I need to declare a parameter as a STRING.
Terrence Sturm, Architect
_______________
MBP OSX 10.15.4 Quad Core Intel i7 2.2hz
AC 17 build 5019
AC 22 build 7000
AC 23 build
AC 24 build 5000
All that is needed to initialize a string variable is
varName='[any text, I use a space]'
It can be in the master or parameter script, or the script in which you are using it. For cases like this I initialize the variable right before I use it, for clarity.

John, you should also investigate the format_string feature of the STR command. It allows you to directly express dimensional data. A little tricky to set up, but powerful. I'll try to post more later.

HTH,
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
tsturm
Newcomer
Now James,

How would you do a number variable?

String is
VARNAME='anynamehere'
Number is ??

These Varnames can be written in the mastter script or parameter script, right?

What affect would creating a new parameter in the parameter list do? TThe place wfere you can declare if it is a line type or a material type. You can declare textt here as well.

TIA
Terrence Sturm, Architect
_______________
MBP OSX 10.15.4 Quad Core Intel i7 2.2hz
AC 17 build 5019
AC 22 build 7000
AC 23 build
AC 24 build 5000
While I might not be following your question...

Parameters can only be created in the main library part window. Variables can be initialized anywhere, and in fact non-string variables don't need to be initialized. If you use a legal variable name that hasn't been used previously, GDL assumes it's zero and moves on.

String variables need to be initialized, because, as above, a new variable is assumed to be the number zero, not an empty string.

The MATERIAL directive, although it can take an integer argument, will assume the argument is text,
MATERIAL unInitializedVar
will give a 'not found' error, even though the argument is really zero, and you might expect the material to come up 'General'.

DEFINE MATERIAL (e.g.) isn't the same as creating a material-type parameter. It just sets up a local material that can be SET like any other material in the project or in a parameter in the main list.
James Murray

Archicad 27 • Rill Architects • macOS • OnLand.info
tsturm
Newcomer
So James,

variables can be defined from just about anywhere but parameters can only be defined in the parameter list? (see attached image)

How do you declare a parameter in the Parameter Script window?
And when you do, what is done to tell the difference between a string and a number? How does the PARAMETERS command differ from the VARNAME command?

You mentioned before to use the VARNAME command.
All that is needed to initialize a string variable is
varName='[any text, I use a space]'
Why did you write the equation as you did? Why the 'any text, I use a space'? Are there two expressions needed to complete the statement?

What about the way I wrote it?
 VARNAME='any text' 
Could I also write it as
 VARNAME=anytext 
or do I need the quotes only when the string of text has spaces as in the first example, but that both examples will work depending on the string used.

And by using the VARNAME, am I not declaring a string variable or the string itself. What would be the variable in a your example?
varName='[any text, I use a space]'
In the GDL manual, it states there are four commands which can be used in the Parameter Script: VALUES, PARAMETERS, LOCK, HIDEPARAMETER.

Just trying to understand all the differences and what the reasons are for it all.

Perhaps I have been doing something wrong for so long and never knew I was.

TIA
Terrence Sturm, Architect
_______________
MBP OSX 10.15.4 Quad Core Intel i7 2.2hz
AC 17 build 5019
AC 22 build 7000
AC 23 build
AC 24 build 5000
Lingwisyer
Guru

Reviving this thread,

 

How do you get this to work with arrays?

name = STR ("%2.0", i) + " " + sg_customName[i][2]

 

 

 

Ling.

 

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win11 | i9 10850K | 64GB | RX6600 Win10 | R5 2600 | 16GB | GTX1660