Select to view content in your preferred language

Arcpy Generate Attachment Match Table - RuntimeError: Object: Error in executing tool

180
2
Jump to solution
4 weeks ago
MichaelFowler1
Occasional Contributor

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)

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

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'

... sort of retired...

View solution in original post

2 Replies
DanPatterson
MVP Esteemed Contributor

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'

... sort of retired...
MichaelFowler1
Occasional Contributor

@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

0 Kudos