|
POST
|
I just tried my code block with the line you suggested. Assuming I've written it correctly, it still doesn't seem to work (I have tried chr(10), "chr(10)", {chr(10)} and "{chr(10}" as well without any luck). All come up with the below error.
... View more
03-15-2022
06:00 PM
|
0
|
3
|
2724
|
|
POST
|
So I've got a problem I'm trying to solve using a python expression in a "Calculate Value" step in Model Builder. In short, I'm trying to replace new line characters (\n) with "" to change a multi-line input text string (from a text file) to a single line of text (which will play nice with Field Calculator). However, it seems that I can't find a way to make the characters "\n" stay in my expression. As soon as I click out of the Code Block, the characters disappear and the following line of script moves down onto a new line. I've tried the 2 below combinations with the same result (3rd image). In a standalone python script, this doesn't happen. Would you consider this a bug?
... View more
03-14-2022
11:07 PM
|
0
|
6
|
2801
|
|
POST
|
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.
... View more
03-14-2022
10:41 PM
|
1
|
0
|
854
|
|
POST
|
Trying to fix the issue by turning the multiline text file into a single, long string. Started a new expression as per below, but the Code block keeps removing the \n and just moving the text onto a new line. becomes this: So I tried this too: but get this error: which is the same error I get from just running the field calculator with the original multiline text value. So frustating!
... View more
03-14-2022
07:23 PM
|
0
|
0
|
4399
|
|
POST
|
Nearly worked! It did indeed calculate the Value as you suggested (just using the Expression instead of the code block) but the calculate field step failed where it encountered the new line.
... View more
03-14-2022
05:43 PM
|
0
|
1
|
4401
|
|
POST
|
I feel like I'm getting closer - but still need guidance. I've created a Calculate Value Code Block as per below but have 2 problems (at least, 2 for now): 1. I can't figure out how to replace the written file path on line 4 with the pathway from the variable (which is a text file) i.e. path = (str_path). When I do, I get the below error. 2. When I run it successfully as per the original script, the output Value is still blank (at least as far as I can tell).
... View more
03-10-2022
10:58 PM
|
0
|
3
|
4436
|
|
POST
|
Thanks for the suggestion. I've had a look at that now and don't think that's really a viable option. Would it be possible to load the text in a text file (using the Text File variable) and use a python code to extract the text and calculate field?
... View more
03-10-2022
09:55 PM
|
0
|
0
|
4446
|
|
POST
|
I assume text boxes are not an option? Could a text file work in place of a text line/box?
... View more
03-10-2022
07:40 PM
|
0
|
0
|
4467
|
|
IDEA
|
I find it annoying when the first time I click in the Command Search box at the top of Pro that it thinks about loading all the tools for a while before working. Surely this can happen after project open in the background before someone accesses the search function.
... View more
03-10-2022
07:21 PM
|
0
|
0
|
2091
|
|
POST
|
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.
... View more
03-10-2022
07:19 PM
|
1
|
11
|
5348
|
|
POST
|
Found my own solution: Don't start a variable name that you need as a Parameter with numbers! Once I renamed them all to put the numbers anywhere but the beginning (i.e. Endorsement 8234?) it worked fine.
... View more
03-09-2022
11:12 PM
|
0
|
0
|
2148
|
|
POST
|
I have built a relatively simple model but have across an error I've not encountered before (and I do a fair bit in Model Builder). I'm trying to change some of my parameters to Optional, but the OK button is greyed out, and I'm seeing the below "Parameter Name and Data Type are required" message. You can see in the screenshot of the model that each parameter has a name, and they are all String type except for 4 (Long). The only 2 which are required are the first 2, then the rest are optional depending on what data is being loaded. The values are then called by the Calculate Field steps to fill in the relevant fields (will just calculate "" if the parameter is left empty).
... View more
03-09-2022
10:58 PM
|
0
|
1
|
2154
|
|
IDEA
|
Have you looked into Parallel running apps that let you run multiple instances of apps? This might help in your situation, though I've not tried it with Field Maps. Something like this.
... View more
03-09-2022
04:21 PM
|
0
|
0
|
2151
|
|
IDEA
|
Something that has annoyed me for a long time is the difficulty that I sometimes find with identifying where a set of grouped layers ends and a new layer/layer group starts. The below example shows a set of layers grouped together with individual layers both above and below the group. At a glance, it is hard to tell where the group stops though. It would be great if an improvement could be made that somehow highlights what layers are grouped together. Maybe a line/bracket down the side of the tree showing the grouping, a faint bounding box or a slight change in the background shading to show groups?
... View more
03-08-2022
08:22 PM
|
15
|
3
|
1593
|
|
POST
|
I think the Maintain Curve Segments setting has resolved the issue. The 2 breaks I've found previously are now connected. Will keep an eye out for others, but hopefully thats it! Thanks Dan.
... View more
03-03-2022
06:07 PM
|
1
|
0
|
2076
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 2 weeks ago | |
| 1 | 08-24-2025 06:11 PM | |
| 1 | a month ago | |
| 1 | 10-08-2024 09:01 PM | |
| 1 | 06-05-2025 12:17 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|