I am having trouble replacing the data source on CAD files using arcpy.
Everything I have tried runs into this error:
Runtime error type 'exceptions.ValueError' : Layer: Unexpected error
Here is a list of arguments I have tried:
layer.replaceDataSource("C:/CAD_DIR/CAD_File_1.dxf', 'CAD_WORKSPACE', 'Polyline')
layer.replaceDataSource("C:/CAD_DIR/CAD_File_1', 'CAD_WORKSPACE', 'Polyline')
layer.replaceDataSource("C:/CAD_DIR/', 'CAD_WORKSPACE', 'CAD_File_1/Polyline')
layer.replaceDataSource("C:/CAD_DIR/', 'CAD_WORKSPACE', 'CAD_File_1.dxf/Polyline')
layer.replaceDataSource("C:/CAD_DIR/', 'CAD_WORKSPACE', 'CAD_File_1.dxf.Polyline')
layer.replaceDataSource("C:/CAD_DIR/', 'CAD_WORKSPACE', 'CAD_File_1.Polyline')
It appears to take more time to think about going wrong when I put the 'CAD_File_1*' part in the 'Dataset_Name' section, that is to the right of 'CAD_WORKSPACE'. But it still fails.
I have noticed that it treats the CAD file as a Feature Dataset and the particular feature type, in this case Polyline, as the Feature Class which may be the issue.
I have also tried this when pointing at a 'Polyline' layer:
layer.replaceDataSource("C:/CAD_DIR/', 'CAD_WORKSPACE', 'CAD_File_1.dxf)
It doesn't produce the same error or in fact any error but the data does not update.