GDL
About building parametric objects with GDL.
SOLVED!

GDL - Combining Strings and and Text Array

Lingwisyer
Guru

Hi all,

 

Is there someway to combine the following? sg_customName[i][2] is a text array.

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

 

I have used the custom name by itself for some options and i string for others, but I would like to add the option to prefix the custom name.

 

 

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
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Peter Baksa
Graphisoft
Graphisoft

The menu is not new, but it has to be added manually through Work Environment > Menus > All menus in alphabetical order.

In the linked object's master script this is suspicious:

sg_customName_temp[i][2]  = 0

This is clearly not a string, and gets written back to sg_customName.

Péter Baksa
Software Engineer, Library
Graphisoft SE, Budapest

View solution in original post

9 REPLIES 9
runxel
Legend

I don't get it. Are you doing this in a loop with 'i' being the counter?

Can't see why it shouldn't work?!

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
DGSketcher
Legend

I have come across situations like that which look correct but GDL won't handle the parts. In such situations I would break that line into some local variables and then add the variables together. It may be you only need to separate out the STR function.

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

Inserting the various parts into their own local variables does not change anything, still resulting in an incompatible types error when it comes to putting them together... It has to do with the array, as there is no issue when using a non-array text parameter.

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

Did you maybe mix datatypes inside the array? An array in GDL can either hold integers, floats, or strings, but mixing is disallowed.

Lucas Becker | AC 27 on Mac | Graphisoft Insider Panelist | Author of Runxel's Archicad Wiki | Editor at SelfGDL | Developer of the GDL plugin for Sublime Text | My List of AC shortcomings & bugs | I Will Piledrive You If You Mention AI Again |

POSIWID – The Purpose Of a System Is What It Does /// «Furthermore, I consider that Carth... yearly releases must be destroyed»
Lingwisyer
Guru

The array contains two columns of text / strings...

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
Peter Baksa
Graphisoft
Graphisoft

Is your data coming from external files? There is a known issue about the input addons, they convert number-like strings to numbers.

Are your arrays, variables always initialized as strings? During script check, global variables contain dummy values and requests might not return anything, which can lead to mis-initialization if you don't handle it correctly. Variables are initialized to zero unless said otherwise. Use Library Developer menu > Check library scripts for warnings to receive information about uninitialized variables.

Péter Baksa
Software Engineer, Library
Graphisoft SE, Budapest

The object is completely internalised. The only Global used is glob_scale. The object can be found in this thread. The line in question above has been commented out.

 

Is that a new menu in 26? I am scripting in 22.

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
Solution
Peter Baksa
Graphisoft
Graphisoft

The menu is not new, but it has to be added manually through Work Environment > Menus > All menus in alphabetical order.

In the linked object's master script this is suspicious:

sg_customName_temp[i][2]  = 0

This is clearly not a string, and gets written back to sg_customName.

Péter Baksa
Software Engineer, Library
Graphisoft SE, Budapest
Lingwisyer
Guru

*facepalm*

 

Resizing so many arrays and having issue with some not resizing that I did not notice that... Thanks Peter.

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

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!