That would definitely be ideal...but I don't know how to do that either, unfortunately. I didn't know you could do that. Is the methodology just a lookup of the definition query value and then an error message if it doesn't exist?
I'll add a little as well.
Our feature classes have an initial query of "NetworkID IS NULL", so that whenever someone opens up our template map, they'll ideally see nothing. They load the new project data, modify the fields in each feature class to match the NetworkID of their respective project, and then apply that definition query to each feature class to show only that NetworkID.
The problem is that not everyone remembers to do this. When they get to a certain point where they are to run a script that calculates/runs a lot of fields/tools, they're going to be doing so to a much wider range of data than intended.
Since we already have a query applied to show NetworkID IS NULL, I am thinking something like this:
class tool_name(object):
"""Implementation for addin_name_addin.button_tool_name (Button)"""
def __init__(self):
self.enabled = True
self.checked = False
def onClick(self):
for layer in layers: # will define above
if layer.isFeatureLayer:
if layer.name == 'SampleLayer1'
if layer.definitionQuery == """ 'NetworkID = 'SampleProject' """ # I would like to add two options (as shown, and if == none)
pythonaddins.MessageBox('Modify the ' + SampleLayer + ' definition query and retry.', 'Incorrect Definition Query', 0)
elif:
pass
elif: # going through the rest of my feature classes with this level of elif's
pass
elif:
pythonaddins.GPToolDialog(toolPath, 'ToolName')
I'm sure there are some issues with this, but it's just a stab in the dark. I'm not sure if the placement of the tool run command is correct, and I'm not sure if my quoting around my definition query is correct either, just to name some that I have concerns with.