2

I am currently using in my ArcGIS 10.3 toolbox script;

# Get the spatial reference
spatialRef = arcpy.Describe(template).spatialReference.name 

#Loop through shapfiles in folder and reproject
for fc in fcList:
fcspatialRef = arcpy.Describe(fc).spatialReference.name
if fcspatialRef != spatialRef:
    arcpy.Project_management(fc, outFolder + "\\" + fc, template) 

# Print shapefile Project results 
arcpy.AddMessage("\n" + fc)

# Return any errors   
except:
arcpy.AddMessage(arcpy.GetMessages())   

Is there a way to seperate these results in the geoprocessing dialog window by a line spacing because it looks cluttered?

arcpy.AddMessage("\n" + fc)   

kind of works but gets;

Running script Project...

abc.shp

xyz.shp

123.shp

How can I make the list like this please?;

![enter image description here][1]


closed as too broad by PolyGeo Apr 14 '15 at 23:18

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

5

I just created a simple Python script tool with no parameters using ArcGIS 10.3 for Desktop by adding the script below to a toolbox.

import arcpy

fc = r"C:\temp\abc.shp"

arcpy.AddMessage(fc + "\n")
arcpy.AddMessage(fc)
arcpy.AddMessage(fc + "\n")

When I ran the tool it produced the expected output below:

Start Time: Tue Apr 14 18:20:45 2015
Running script Script...
C:\temp\abc.shp

C:\temp\abc.shp
C:\temp\abc.shp

Completed script Script...
Succeeded at Tue Apr 14 18:20:45 2015 (Elapsed Time: 0.02 seconds)

All looks to be working to me.

Please note that every time you use:

arcpy.AddMessage(fc + "\n")

you will get the contents of fc and then a blank line, while

arcpy.AddMessage(fc)

will give you only the contents of fc, while

arcpy.AddMessage("\n")

will give you just a blank line, and

arcpy.AddMessage("\n" + fc)

will give you a blank line and then the contents of fc.

I am unclear of the relevance of the code below to your question.

arcpy.AddMessage(arcpy.GetMessages())
2

If you do not want the space seperator between the processed fc names than just do not include the '\n' in the add message statement:

e.g.

if fcspatialRef != spatialRef:
    arcpy.Project_management(fc, outFolder + "\\" + fc, template)
    arcpy.AddMessage('Reprojected...{}'.format(fc))

Result looks like:

Reprojected...abc.shp
Reprojected...xyz.shp
Reprojected...123.shp

UPDATE:

If you want extra spaces at the beginning of the script running just add additional add message statments before the project code:

e.g.

arcpy.AddMessage('\n\n\n') # adds three returns

if fcspatialRef != spatialRef:
        arcpy.Project_management(fc, outFolder + "\\" + fc, template)
        arcpy.AddMessage('Reprojected...{}'.format(fc))
0

try this:

arcpy.AddMessage(fc + "\r")
  • Nathan same affect in the loop, line spaces between all shapefiles; outside loop, no affect. – Mark W Apr 14 '15 at 10:21
0

using;

arcpy.AddMessage("\n")

At start of my script got the line space I needed.

Not the answer you're looking for? Browse other questions tagged or ask your own question.