cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
GDL
About building parametric objects with GDL.
SOLVED!

Splitting Text in GDL

JeffH
Expert

We have our wall types all listed out like this in our composite list

- A _ Wall: MStud 6" Ins, Gyp.

 

In GDL, how would I strip out everything right of the "-" and then Left of the "_"

The end result needs to be " A ".

 

I am struggling to get the "WALL_COMPS_NAME" to work this way.

 

Any help would be greatly appreciated.

AC24 / AC26 / AC27
Win10
1 ACCEPTED SOLUTION

Accepted Solutions
Solution

 

if strstr(WALL_COMPS_NAME,"-") > 0 and strstr(WALL_COMPS_NAME,"_")>0 then
   Start_num_pos = strstr(WALL_COMPS_NAME,"-") !!!!Postion in characters of first - character
   End_num_pos = strstr(WALL_COMPS_NAME,"_") !!!!Postion in characters of first _ character
   new_text_ = strsub(WALL_COMPS_NAME,Start_num_pos+1,End_num_pos-Start_num_pos-1)  !!!!!!!!Makes new string from first character after - to character before _
endif

 

 

this works in AC18, AC22 and AC25

 

I hope this will help

I have been using ArchiCAD continually since ArchiCAD 4.5
Member of Architalk since 2003, but missed the migration from Architalk to Graphisoft Communities. Melbourne, Australia

View solution in original post

6 REPLIES 6
Yves
Expert

Hello,

With this function …

 

STRSUB (string_expression, start_position, characters_number)

Yves Houssier
Belgium
Archicad 19 -> 24
iMac - Mac Os 10,13
JeffH
Expert

the number is the part that won't work I believe. (We have a wall tag that is set up with exactly this method, that has been brushed aside for its limitations.)

 

 

sometimes we have a wall that is wall "A" to 8' , and wall type "D" above.

- A / D _Wall: MStud 6" Ins, Gyp.

 

"A / D" won't show correctly if I have this scripted to read the first 2 or 3 characters.  Id simply end up with "A /"

 

That is why I am trying to do a split to read everything between "-" & "_"

 

I have it working in properties & Classifications

But can't rely on calling that Unique ID for the property, because we have a few templates, so not every projects will have the same unique ID for the property that would be coded.

AC24 / AC26 / AC27
Win10
DGSketcher
Legend

Try the GDL function STRSTR to establish the position of "-" & "_", then apply those values to STRSUB as suggested by @Yves 

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

 

if strstr(WALL_COMPS_NAME,"-") > 0 and strstr(WALL_COMPS_NAME,"_")>0 then
   Start_num_pos = strstr(WALL_COMPS_NAME,"-") !!!!Postion in characters of first - character
   End_num_pos = strstr(WALL_COMPS_NAME,"_") !!!!Postion in characters of first _ character
   new_text_ = strsub(WALL_COMPS_NAME,Start_num_pos+1,End_num_pos-Start_num_pos-1)  !!!!!!!!Makes new string from first character after - to character before _
endif

 

 

this works in AC18, AC22 and AC25

 

I hope this will help

I have been using ArchiCAD continually since ArchiCAD 4.5
Member of Architalk since 2003, but missed the migration from Architalk to Graphisoft Communities. Melbourne, Australia
Lingwisyer
Guru
string = Bar_Scale1
len = STRLEN (string)
iDotPos = STRSTR (string, ":")
v1 = STRSUB (string, iDotPos + 1, 6)
v2 = SPLIT (v1, "%n", vl)

 

That is from my scale bar object.

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

This is the solution we were after.

Thanks!!!!

 

Thank you all for your help in this matter.

 

AC24 / AC26 / AC27
Win10