cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 
2024 Technology Preview Program

2024 Technology Preview Program:
Master powerful new features and shape the latest BIM-enabled innovations

GDL
About building parametric objects with GDL.

Convert Text to Real Number

Gerald Lock
Contributor

I've searched the GDL User Manual and through this forum (and the old deprecated one) but I'm unable to find any mention of a function to convert a string to a real number.

Is this possible?

 

I have an object parameter that I've define set values for to make them available in a drop-down.

The problem is GDL values only seem to show as a drop-down when the paramater type is set to string.

I want to use the selected value in a numeric expression, but am obviously unable to.

 

I could convert every single value in the list to a separate numeric variable using if..then but this seems tedious.

Surely there's a way to look at a string and extract a numeric value from it (or return 'zero' if there is none)?

3 REPLIES 3
Barry Kelly
Moderator

@Gerald Lock wrote:

I have an object parameter that I've define set values for to make them available in a drop-down.

The problem is GDL values only seem to show as a drop-down when the parameter type is set to string.

I want to use the selected value in a numeric expression, but am obviously unable to.


If it is not too late, change your parameter type to length, angle, real number or integer (depends what you need it for).

You can still have a VALUES list of numbers, and then you do not need to convert them.

 

BarryKelly_0-1721373099654.png

 

 

Otherwise you can use the SPLIT command to extract the number form the string.

In you case I would assume it would be something like ... n = SPLIT (string_variable, "%n", num)

'num' will be your number.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

This isn't working for me

Values (sw) set:

GeraldLock_0-1721374277977.png

but drop-down not functional

GeraldLock_1-1721374318923.png

 

 

oops, just realised I forgot to remove the "" in the values definition.

solved!

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!