AddWarning

この ArcGIS 2.7 ドキュメントはアーカイブされており、今後更新されません。 コンテンツとリンクが古い場合があります。 最新のドキュメントをご参照ください

概要

Adds a custom warning message (severity of 1) to the messages of a script tool or Python toolbox tool.

When a tool is run, arcpy is fully aware of the application it is called from. One major effect of this is that you can write messages in Python and your messages automatically appear on the tool dialog box, in the history, and the Python window.

構文

AddWarning (message)
パラメーター説明データ タイプ
message

The warning message to add.

String

コードのサンプル

AddWarning example

Add a custom warning message to a script tool.

import arcpy

fc = arcpy.GetParameterAsText(0)

# Get the count from GetCount's Result object
feature_count = int(arcpy.GetCount_management(fc).getOutput(0))

if feature_count == 0:
    arcpy.AddWarning("{0} has no features.".format(fc))
else:
    arcpy.AddMessage("{0} has {1} features.".format(fc, feature_count))

関連トピック