1

I'm having trouble using an in line variable derived from the Parse Path tool in ArcGIS ModelBuilder to create a definition query for a layer file.

I'm importing an xyz file to a feature class, and using Parse Path to obtain %Value%. I would like to set a defintion query to something like the one shown below. I have a short Python script that was used to manually enter the def query, but would much rather use %Value% to derive it.

enter image description here

Thank you!

  • 1
    Can you describe this in more detail, please? I think you will need to use ArcPy rather than ModelBuilder only but I am not clear about your precise requirement. – PolyGeo Sep 12 '13 at 13:03
  • Sure. Ive added the model I'm working with. – Hyperion Sep 12 '13 at 14:49
2

I made a test model based on the central branch of your model in the area surrounding the 'DefinitionQuery' script. Firstly, in your definition query model parameter, I believe for the SQL Expression you need double quotes surrounding the field name ("REF_SURVEY_ID" = '%Value%').

The other thing I am thinking is the logic/order of your tools. In my test I applied the 'DefinitionQuery' script on the Make XY Event Layer output and then applied symbology and finally, saved to a layer file for exporting or emailing as attachment.

To do this I added an output to my DefinitionQuery script so that I could set a precondition on the 'Apply Symbology From Layer' tool. This way I made sure that the DefinitionQuery was applied to my XY Event layer before further processing (you cannot set a tool as a precondition for something if it does not have an output). This idea comes from this esri forum post I found: Preconditions for Python scripts.

I added a boolean output parameter to my DefinitionQuery script and I set this value it in the python code (arcpy.SetParameter(2, 1)).

DefinitionQuery Model

DefinitionQuery Script Properties

2

It looks like the Definition Query tool you have written using Python script takes a single input of type SQL Expression.

I think you will have more success if the only input to this tool is a String representing the Value i.e. hardwire the field and operator (at least for initial testing) or make them separate inputs (if you prefer).

1

You can use make query table insted of DQ.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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