ArcGIS Pro 3.2.1
I have a Python script that converts a selection to a definition query:
def qdef_selected_features(lyr):
desc = arcpy.Describe(lyr)
# Get a semicolon-delimited string of selected feature IDs
fid_list = desc.FIDSet.split(";")
# build the query definition
query = '{} IN ({})'.format(desc.OIDFieldName, ",".join(fid_list))
# apply the query definition back to the layer
lyr.definitionQuery = query
aprx = arcpy.mp.ArcGISProject('current')
m = aprx.activeMap
lyr = m.listLayers('MY_USER.ROADS')[0]
qdef_selected_features(lyr)Result:
OBJECTID IN (4, 5, 8, 9, 10, 14, 15, 16, 20, 24, 25, 26, 29, 30)
That script is the only Python script I ever use. I want to save it as the default script so that it opens automatically when I open the Python window.
Could functionality be added that lets me set a default Python script? That would be more efficient than opening the file via File Explorer and copying/pasting the script into the Python window each time I want to use it.