Solved

expression and set attribute

  • 16 December 2019
  • 9 replies
  • 12 views

Badge

Hello

 

 

I 'm tring to set any value to AttibuteManager Transformer as you can see in the attachement.

 

I have created an RandomNumberGenerator to fill a list but it doesn't work.

 

I try also a rand function. Without success.

 

Short, how to set random value in an AttibuteManager Transformer ? (the easiest way ...)

 

Subsidiary question, how to create correct expression with the "text editor_attribute value" ?

 

any help will be welcome.

thanks

 

icon

Best answer by jerome 16 December 2019, 12:01

View original

9 replies

Userlevel 5
Badge +25

The RandomNumberGenerator should work, as for the rand() function, you need to make sure you use the Artithmetic editor for that rather than the Text editor, which you have done now.

0684Q00000ArKVIQA3.png

(note the different icon)

The rand() function will result in a random floating point value, if you need integers you'll need to wrap it in an int() function so you'll get 

@int(@rand()*10))

Can you tell us what the output of the RandomNumberGenerator is and what you were expecting?

Badge

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

Userlevel 5
Badge +25

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

The Help of the Artithmetic editor covers those functions as well.

As for the RandomNumberGenerator, without seeing your workspace I can't really say what's going on. Could you share that by any chance?

Userlevel 2
Badge +17

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ...  Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

I believe that the RandomNumberGenerator helps you. Try this setting.

0684Q00000ArM7wQAF.png

 

See also these links to learn more about math expressions.

This expression would work for you, FYI.

@int(@rand()*25)%25
Badge

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

Sorry I forget to put my screenshot... But nothing is wrong when setting the transformer

@takashi : thanks I found an approximate formula with round.Safe_attribute1.PNG

Userlevel 5
Badge +25

Sorry I forget to put my screenshot... But nothing is wrong when setting the transformer

@takashi : thanks I found an approximate formula with round.Safe_attribute1.PNG

Note that there's nothing going into the RandomNumberGenerator. If you want to apply the random number to the 186 features shown at the top you'll need to run them through the RandomNumberGenerator. You can name the attribute to Utilisation straight away, saving you one step in the AttributeCreator.

Badge

Wonderful it works.

You're right I have never seen the arithmetic editor . It works better.

I try to generate random integer between 0 and 24.

 

But what s the correct syntaxe for expression : @int, evaluate ... Is there documentation about the syntax of expressions ?

 

Otherwise, my list _random_number, genererated by RandomNumberGenerator, does'nt return any value (missing in my field)

 

Ok .. I understand now how it works.

Thanks . my data is full.

Badge

The RandomNumberGenerator should work, as for the rand() function, you need to make sure you use the Artithmetic editor for that rather than the Text editor, which you have done now.

0684Q00000ArKVIQA3.png

(note the different icon)

The rand() function will result in a random floating point value, if you need integers you'll need to wrap it in an int() function so you'll get 

@int(@rand()*10))

Can you tell us what the output of the RandomNumberGenerator is and what you were expecting?

How to choose a random value in a string list ?

Userlevel 5
Badge +25

How to choose a random value in a string list ?

To include a random number in a string attribute you'll need to use the Text Editor and then wrap the function in an Evaluate() function. E.g.

@Evaluate(@int(@rand()*10))

Reply