Hello,

I'm new to python so hopefully the solution is simple.

I am trying to generate random integers between 1 and 1000 to populate the field "Rand2".

The "Rand2" field is Float.

####

Pre-Logic Script Code:

import arcpy

# Set the randomGenerator environment to 4 MERSENNE_TWISTER

arcpy.env.randomGenerator = "4 MERSENNE_TWISTER"

# Calculate a random number using the arcgis.rand() function

result = arcpy.CalculateValue_management("arcgis.rand('INTEGER 1, 1000')")

# Get the value from the result object from CalculateValue and print

randomValue = float(result.getOutput(0))

print randomValue

Expression:

Rand2=

randomValue[!Rand2!]

####

Field calculator runs for a while then delivers an "Error running expression" message (See image for full message).

Can anyone tell me how to clean this up?

Thanks

Rich

I'm new to python so hopefully the solution is simple.

I am trying to generate random integers between 1 and 1000 to populate the field "Rand2".

The "Rand2" field is Float.

####

Pre-Logic Script Code:

import arcpy

# Set the randomGenerator environment to 4 MERSENNE_TWISTER

arcpy.env.randomGenerator = "4 MERSENNE_TWISTER"

# Calculate a random number using the arcgis.rand() function

result = arcpy.CalculateValue_management("arcgis.rand('INTEGER 1, 1000')")

# Get the value from the result object from CalculateValue and print

randomValue = float(result.getOutput(0))

print randomValue

Expression:

Rand2=

randomValue[!Rand2!]

####

Field calculator runs for a while then delivers an "Error running expression" message (See image for full message).

Can anyone tell me how to clean this up?

Thanks

Rich

randomValue = float(result.getOutput(0))

should be

randomValue = float(result.getOutput[0])