<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Extracting Coordinate System from CAD File Name in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024427#M59839</link>
    <description>&lt;P&gt;Having an issue running the following script. It seems to work when I print the values of the functions, but &lt;STRONG&gt;I think?&amp;nbsp;&lt;/STRONG&gt;my problem is that I don't know how to assign those functions (or variables in this case) to the geoprocessing tool correctly. Thoughts?&lt;/P&gt;&lt;P&gt;I have ran the CAD drawing manually through Pro 2.5 and it works, so the I don't see an issue being with the data.&lt;/P&gt;&lt;P&gt;&lt;U&gt;Error&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 39, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 1123, in CADToGeodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;raise e&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 1120, in CADToGeodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;retval = convertArcObjectToPythonObject(gp.CADToGeodatabase_conversion(*gp_fixargs((input_cad_datasets, out_gdb_path, out_dataset_name, reference_scale, spatial_reference), True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in &amp;lt;lambda&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: Object: Error in executing tool&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

#Temp/Processing GDB
working = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\W_DGN_Import.gdb"

#Final/Production GDB
final = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\DGN_Import.gdb"

#CAD Dataset
cad = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\JODKH-BNDY-TOPO_SPILWest1202.dgn"

#CoordinateSystems
SPCEast = "NAD_1983_2011_StatePlane_Illinois_East_FIPS_1201_Ft_US"
SPCWest = "NAD_1983_2011_StatePlane_Illinois_West_FIPS_1202_Ft_US"

#OutputName
def opn(x):
    folder = os.path.splitext(os.path.basename(x))[0]
    return  str(folder.rsplit('_',1)[0])

#If statement to extract Coordinate System
def cs(x):
    folder = os.path.splitext(os.path.basename(x))[0]
    return  str(folder.split('_',2)[1])

#Match extraction to identify input coordinate system
def csm(y):
    if y is 'SPILEast1201':
        return SPCEast
    else:
        return SPCWest

#Execute Functions
outputname = opn(cad)
coordsys = cs(cad)
coordsysmatch = csm(cs)
#CAD to Geodatabase; use SPC from csm
arcpy.conversion.CADToGeodatabase([cad], [working], [outputname], '1000', [coordsysmatch])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 08 Feb 2021 16:51:40 GMT</pubDate>
    <dc:creator>AdOl2</dc:creator>
    <dc:date>2021-02-08T16:51:40Z</dc:date>
    <item>
      <title>Extracting Coordinate System from CAD File Name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024427#M59839</link>
      <description>&lt;P&gt;Having an issue running the following script. It seems to work when I print the values of the functions, but &lt;STRONG&gt;I think?&amp;nbsp;&lt;/STRONG&gt;my problem is that I don't know how to assign those functions (or variables in this case) to the geoprocessing tool correctly. Thoughts?&lt;/P&gt;&lt;P&gt;I have ran the CAD drawing manually through Pro 2.5 and it works, so the I don't see an issue being with the data.&lt;/P&gt;&lt;P&gt;&lt;U&gt;Error&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&amp;lt;string&amp;gt;", line 39, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 1123, in CADToGeodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;raise e&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\conversion.py", line 1120, in CADToGeodatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;retval = convertArcObjectToPythonObject(gp.CADToGeodatabase_conversion(*gp_fixargs((input_cad_datasets, out_gdb_path, out_dataset_name, reference_scale, spatial_reference), True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "c:\program files\arcgis\pro\Resources\arcpy\arcpy\geoprocessing\_base.py", line 511, in &amp;lt;lambda&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;RuntimeError: Object: Error in executing tool&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import os

#Temp/Processing GDB
working = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\W_DGN_Import.gdb"

#Final/Production GDB
final = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\DGN_Import.gdb"

#CAD Dataset
cad = r"C:\Users\a\Documents\ArcGIS\Projects\DGN_Import\JODKH-BNDY-TOPO_SPILWest1202.dgn"

#CoordinateSystems
SPCEast = "NAD_1983_2011_StatePlane_Illinois_East_FIPS_1201_Ft_US"
SPCWest = "NAD_1983_2011_StatePlane_Illinois_West_FIPS_1202_Ft_US"

#OutputName
def opn(x):
    folder = os.path.splitext(os.path.basename(x))[0]
    return  str(folder.rsplit('_',1)[0])

#If statement to extract Coordinate System
def cs(x):
    folder = os.path.splitext(os.path.basename(x))[0]
    return  str(folder.split('_',2)[1])

#Match extraction to identify input coordinate system
def csm(y):
    if y is 'SPILEast1201':
        return SPCEast
    else:
        return SPCWest

#Execute Functions
outputname = opn(cad)
coordsys = cs(cad)
coordsysmatch = csm(cs)
#CAD to Geodatabase; use SPC from csm
arcpy.conversion.CADToGeodatabase([cad], [working], [outputname], '1000', [coordsysmatch])&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:51:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024427#M59839</guid>
      <dc:creator>AdOl2</dc:creator>
      <dc:date>2021-02-08T16:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Coordinate System from CAD File Name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024434#M59840</link>
      <description>&lt;P&gt;Are you looking to build this into a bigger tool (e.g. process more than one dataset)?&lt;/P&gt;&lt;P&gt;The documentation &lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/conversion/cad-to-geodatabase.htm" target="_blank"&gt;CAD To Geodatabase (Conversion)—ArcGIS Pro | Documentation&lt;/A&gt;&amp;nbsp;shows that the only argument supplied as a list is the list of CAD files.&lt;/P&gt;&lt;P&gt;Try removing the other lists, like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.conversion.CADToGeodatabase([cad], working, outputname, '1000', coordsysmatch)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 16:53:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024434#M59840</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-08T16:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Coordinate System from CAD File Name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024448#M59841</link>
      <description>&lt;P&gt;Also your feature dataset name is probably invalid as it contains hyphens -&amp;nbsp;JODKH-BNDY-TOPO.&lt;/P&gt;&lt;P&gt;You will probably need to do a .replace("-","_") or similar.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Feb 2021 17:09:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024448#M59841</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2021-02-08T17:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Extracting Coordinate System from CAD File Name</title>
      <link>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024865#M59884</link>
      <description>&lt;P&gt;You were correct David. What I thought the [] were used for was incorrect.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Feb 2021 14:26:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/extracting-coordinate-system-from-cad-file-name/m-p/1024865#M59884</guid>
      <dc:creator>AdOl2</dc:creator>
      <dc:date>2021-02-09T14:26:18Z</dc:date>
    </item>
  </channel>
</rss>

