ESRI community,
I have the following tool wehere the user can enter in a formation, seam, and then a modifier. There is a feature class with three different fields for each one and I'm trying to tell arcpy to select all the records that have the user defined values in field1 and field2 and field3. I am beating my head against the wall becuase this works great in ArcGIS pro when i use the tool, or as a query defintion but I can't get the string right for the SQL because it seems this advanced logic can only use SQL in arcgis... any suggestions are helpful!!
import arcpy
from pathlib import Path
import os
point_layer_location = Path(arcpy.GetParameterAsText(0))
point_layer_name = arcpy.GetParameterAsText(1)
point_layer = str(point_layer_location / "{0}".format(point_layer_name))
fields = ['formation','seam','zone_modifier']
us_formation = arcpy.GetParameterAsText(2)
us_seam = arcpy.GetParameterAsText(3)
us_modifier = arcpy.GetParameterAsText(4)
arcpy.env.workspace = str(point_layer_location)
current_workspace = arcpy.env.workspace
arcpy.AddMessage("Current Workspace: " + str(current_workspace))
arcpy.env.overwriteOutput = True
target_horizon = arcpy.management.SelectLayerByAttribute(
in_layer_or_view= point_layer,
selection_type="NEW_SELECTION",
where_clause=f"formation = '{0}' And seam = '{1}' And zone_modifier = '{2}'".format(us_formation,us_seam,us_modifier),
invert_where_clause=None)
arcpy.AddMessage("records selected")
arcpy.management.CopyRows(in_rows= target_horizon,
out_table="Selected_Records")
arcpy.management.SelectLayerByAttribute(
in_layer_or_view= point_layer,
selection_type="CLEAR_SELECTION",
where_clause="",
invert_where_clause=None)
count1 = int(arcpy.management.GetCount(target_horizon).getOutput(0))
arcpy.AddMessage(f"Total Selected: ".format(count1))
arcpy.AddMessage("Process Complete and Selection Cleared")