Hi Brains Trust. I thought this was a simple thing, but I can't quite figure it out. I want to be able to enter multi-line text into a Models string parameter, but it seems to only accept single line of text. Destination will be a string field in a feature class.
Thanks for the tip. I tried that in the Code Block and it still moved the following text to a new line....so I decided to try something else. I've created a python script with the function in it loaded as a script in my Toolbox and model with an input parameter (the path to my .txt file) and an output parameter (the new single-line string). I can get it to run the function successfully, removing "\n" and replacing it with "", and I WAS struggling to get the value out as a parameter I can feed into another model step, but have just discovered I had called the function result incorrectly.
Here's my methodology to get the text file input to a value I can use in Field Calculator:
And the code as a sample:
import re
import arcpy
inFile = open(arcpy.GetParameterAsText(0)).read()
def Result(Value):
inValue = Value
newValue = inValue.replace("\n", "")
re.sub('\s{2,}', ' ', inValue) # To remove more than one space
#print (newValue)
return newValue
outText = Result(inFile)
arcpy.AddMessage(outText)
#print(outText)
arcpy.SetParameterAsText(1, outText)
A big thank you to @Luke_Pinner for your pointers. I would not have got this far without them.
This might help others who are at Pro 3.1
https://pro.arcgis.com/en/pro-app/latest/arcpy/geoprocessing_and_python/parameter-controls.htm
# set self.params for use in other function
self.params = arcpy.GetParameterInfo()
# Multiline block of text
self.params[1].controlCLSID = '{E5456E51-0C41-4797-9EE4-5269820C6F0E}'