Select to view content in your preferred language

no message for addMessage

764
1
Jump to solution
05-11-2012 03:05 PM
ElaineKuo
Regular Contributor
System ArcGIS 9.3

Problem 1:
No message jumped out when finishing running addMessage in the code below.
Please kindly advise any modification to show the message.
Thanks.

##Script Name: Multi centroid  ##Description: Get centroid of shapefiles ##Created By: Elaine Kuo ##Date: 29/04/2012   #Import standard library modules import arcgisscripting import os  #Create the Geoprocessor object gp = arcgisscripting.create(9.3)  #Set the input workspace #GP.workspace = sys.argv[1] #Set the workspace. gp.Workspace= "G:/temp/test1"  #Set the output workspace #outWorkspace = sys.argv[2] #Set the workspace. List all of the feature classes in the dataset outWorkspace= "G:/temp"   # Create a list of all the features within the workspace. fcs = gp.ListFeatureClasses()  # Loop through every item in the list that was just generated for fc in fcs:      # Break out the name, no path or extension, using the describe object.     desc = gp.describe(fc)     featureName = desc.name      # Work the magic.     outFeatureClass = outWorkspace + os.sep + gp.ValidateTableName(featureName, outWorkspace)     gp.Toolbox = "Data Management"     gp.FeaturetoPoint(fc, outFeatureClass)       gp.AddMessage(gp.GetMessages(2))     print gp.GetMessages(2) 
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
BruceNielsen
Frequent Contributor
Elaine,

Because your addMessage & print statements are indented, they are being executed during each iteration of the for loop. Remove the indent, and they will only execute at the conclusion of the script.

The most likely reason no messages are being displayed is that no errors are occurring. Level 0 messages are normal, level 1 messages are warnings, and level 2 messages are critical errors. If you want to see all messages that occurred during the script, remove the error level: gp.getmessages().

View solution in original post

0 Kudos
1 Reply
BruceNielsen
Frequent Contributor
Elaine,

Because your addMessage & print statements are indented, they are being executed during each iteration of the for loop. Remove the indent, and they will only execute at the conclusion of the script.

The most likely reason no messages are being displayed is that no errors are occurring. Level 0 messages are normal, level 1 messages are warnings, and level 2 messages are critical errors. If you want to see all messages that occurred during the script, remove the error level: gp.getmessages().
0 Kudos