Hi all,
I'm attempting to create a python script with one of the steps being creating a attachment match table and then adding an attachment to a fc whenever someone creates a new product.
When doing the process manually I have zero issues, but when I try and script the step I keep getting this error: "RuntimeError: Object: Error in executing tool".
When I have the code segment in a try/except statement it runs without actually outputting the 'out_match_table'. Even when I copy/paste the working code from running the tool from ArcGIS Pro it still gives me the error. Currently using ArcGIS Pro 3.2.1
import arcpy
arcpy.env.overwriteOutput = True
working_gdb = r'path to my gdb'
aprx = arcpy.mp.ArcGISProject('CURRENT')
layout = aprx.listLayouts('Layout')[0]
map_frame = layout.listElements("mapframe_element", "Map Frame")[0]
extent = map_frame.camera.getExtent()
polygon = extent.polygon
# append
product_ingest_polygon = f'{working_gdb}\\Product_Ingest'
arcpy.management.Append([polygon], product_ingest_polygon, "NO_TEST")
# generate attachment match table
in_dataset = product_ingest_polygon
in_folder = r"path to product folder"
out_match_table = f"{working_gdb}\\Product_Ingest_match_table"
in_key_field = "Prod_Name"
in_file_filter="",
in_use_relative_paths='RELATIVE',
match_pattern="EXACT"
arcpy.management.GenerateAttachmentMatchTable(in_dataset, in_folder, out_match_table, in_key_field, in_file_filter, in_use_relative_paths, match_pattern)
Solved! Go to Solution.
I suspect the commas generating a tuple may be an issue
working_gdb = r'path to my gdb'
product_ingest_polygon = f'{working_gdb}\\Product_Ingest'
in_dataset = product_ingest_polygon
in_folder = r"path to product folder"
out_match_table = f"{working_gdb}\\Product_Ingest_match_table"
in_key_field = "Prod_Name"
in_file_filter="",
in_use_relative_paths='RELATIVE',
match_pattern="EXACT"
in_file_filter
('',)
in_use_relative_paths
('RELATIVE',)
# ----- versus ---------------------
in_dataset = product_ingest_polygon
in_folder = r"path to product folder"
out_match_table = f"{working_gdb}\\Product_Ingest_match_table"
in_key_field = "Prod_Name"
in_file_filter=""
in_use_relative_paths='RELATIVE'
match_pattern="EXACT"
in_file_filter
''
in_use_relative_paths
'RELATIVE'
I suspect the commas generating a tuple may be an issue
working_gdb = r'path to my gdb'
product_ingest_polygon = f'{working_gdb}\\Product_Ingest'
in_dataset = product_ingest_polygon
in_folder = r"path to product folder"
out_match_table = f"{working_gdb}\\Product_Ingest_match_table"
in_key_field = "Prod_Name"
in_file_filter="",
in_use_relative_paths='RELATIVE',
match_pattern="EXACT"
in_file_filter
('',)
in_use_relative_paths
('RELATIVE',)
# ----- versus ---------------------
in_dataset = product_ingest_polygon
in_folder = r"path to product folder"
out_match_table = f"{working_gdb}\\Product_Ingest_match_table"
in_key_field = "Prod_Name"
in_file_filter=""
in_use_relative_paths='RELATIVE'
match_pattern="EXACT"
in_file_filter
''
in_use_relative_paths
'RELATIVE'
@DanPatterson that was exactly it! Really appreciate the info.
First time I've run into that being an issue...will keep that in mind for the future