arcpy.GetMessages is specific to getting messages from a tool which has executed.http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/GetMessages/000v0000000p000000/
import arcpy arcpy.AddMessage("This is just a message...") arcpy.AddWarning("This text is green...") arcpy.AddError("This text is red...") arcpy.GetMessages() # this will make the tool bomb out foo = bar
Based on my reading of his description, it looks like he's trying to run this as a script tool, not from the Python window. Hence, he would need arcpy.GetMessages() to return the document title to the geoprocessing window.
Code is absolutely fine.I suspect you dont have a title in your map document. If you dont have a title, mxd.title will equal ''.In this case the AddMessage doesn't return anything.The title it is returning is from:File > Map Document Properties > Title: ________Can you be sure you got something in there?Also as a check, take your code into the Python window.mxd = arcpy.mapping.MapDocument("current") mxd.title(the arcpy.AddMessage isn't going to do what you want in the Py Window
mxd = arcpy.mapping.MapDocument("current") mxd.title
Okay most of that stuff in here before was redundant so it seems.New toolbox, new Script. No changes made to validation. No input at all. Just a straight run of the script does not work.import arcpymxd = arcpy.mapping.MapDocument("current")arcpy.AddMessage(mxd.title)Hopefully that is a bit easier to answer cos I reckon I must be missing something really, really simple.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.