<SPAN class="comment token"># -*- coding: cp1252 -*-</SPAN> <SPAN class="keyword token">import</SPAN> sys <SPAN class="keyword token">import</SPAN> traceback <SPAN class="keyword token">import</SPAN> subprocess <SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\xxESRI\Desktop10.4\ArcCatalog\12C_oracle.sde"</SPAN> txtPath <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\FCList.txt"</SPAN> txt <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>txtPath<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"r"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> line <SPAN class="keyword token">in</SPAN> txt<SPAN class="punctuation token">.</SPAN>readlines<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> fcName <SPAN class="operator token">=</SPAN> line<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">":"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>RegisterWithGeodatabase_management<SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} ist registriert"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> txt<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> txt<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">pass</SPAN> tb <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>exc_info<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> tbinfo <SPAN class="operator token">=</SPAN> traceback<SPAN class="punctuation token">.</SPAN>format_tb<SPAN class="punctuation token">(</SPAN>tb<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> pymsg <SPAN class="operator token">=</SPAN> <SPAN class="string token">"PYTHON ERRORS:\nTraceback Info:\n"</SPAN> <SPAN class="operator token">+</SPAN> tbinfo <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\nError Info:\n "</SPAN> <SPAN class="operator token">+</SPAN> \ str<SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>exc_type<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN> <SPAN class="string token">": "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>exc_value<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>pymsg<SPAN class="punctuation token">)</SPAN> msgs <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Arcpy ERRORS:\n"</SPAN> <SPAN class="operator token">+</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetMessages<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>msgs<SPAN class="punctuation token">)</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Currently this functionality does not exist within arcpy, however, one workaround is to insert 1 record of the spatial type you want. From here, register the table where arcpy will discover the geometry type. Once this is complete you can delete the data from the table.
Do you have an method to populate the data into the tables? If you need the data within anyways you need to do this task either way, and then you can run your existing script.
If not, how do you plan to specify the geometry types anyways? You would need to specify them somewhere, then you could create a sample feature for each type of geometry, and have a line of code to copy this feature into the FC. e.g.
__author__ <SPAN class="operator token">=</SPAN> <SPAN class="string token">'WebbL'</SPAN> <SPAN class="keyword token">import</SPAN> sys <SPAN class="keyword token">import</SPAN> traceback <SPAN class="keyword token">import</SPAN> subprocess <SPAN class="keyword token">import</SPAN> arcpy <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\xxESRI\Desktop10.4\ArcCatalog\12C_oracle.sde"</SPAN> txtPath <SPAN class="operator token">=</SPAN> r<SPAN class="string token">"C:\Users\FCList.txt"</SPAN> txt <SPAN class="operator token">=</SPAN> open<SPAN class="punctuation token">(</SPAN>txtPath<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"r"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">for</SPAN> line <SPAN class="keyword token">in</SPAN> txt<SPAN class="punctuation token">.</SPAN>readlines<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN> fcName <SPAN class="operator token">=</SPAN> line<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">":"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> <SPAN class="comment token">#Add a feature of required geometry type</SPAN> fcGeometryType <SPAN class="operator token">=</SPAN> line<SPAN class="punctuation token">.</SPAN>split<SPAN class="punctuation token">(</SPAN><SPAN class="string token">":"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">]</SPAN> inputGeometryFeat <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN>os<SPAN class="punctuation token">.</SPAN>path<SPAN class="punctuation token">.</SPAN>join<SPAN class="punctuation token">(</SPAN>geometryTemplateFolder<SPAN class="punctuation token">,</SPAN> fcGeometryType<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">]</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>Append_management<SPAN class="punctuation token">(</SPAN>inputGeometryFeat<SPAN class="punctuation token">,</SPAN> fcName<SPAN class="punctuation token">,</SPAN> <SPAN class="string token">"NO_TEST"</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>RegisterWithGeodatabase_management<SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"{0} ist registriert"</SPAN><SPAN class="punctuation token">.</SPAN>format<SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="comment token">#Clean up the template geometry</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>DeleteFeatures_management<SPAN class="punctuation token">(</SPAN>fcName<SPAN class="punctuation token">)</SPAN> txt<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">try</SPAN><SPAN class="punctuation token">:</SPAN> txt<SPAN class="punctuation token">.</SPAN>close<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="keyword token">except</SPAN><SPAN class="punctuation token">:</SPAN> <SPAN class="keyword token">pass</SPAN> tb <SPAN class="operator token">=</SPAN> sys<SPAN class="punctuation token">.</SPAN>exc_info<SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">]</SPAN> tbinfo <SPAN class="operator token">=</SPAN> traceback<SPAN class="punctuation token">.</SPAN>format_tb<SPAN class="punctuation token">(</SPAN>tb<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">[</SPAN><SPAN class="number token">0</SPAN><SPAN class="punctuation token">]</SPAN> pymsg <SPAN class="operator token">=</SPAN> <SPAN class="string token">"PYTHON ERRORS:\nTraceback Info:\n"</SPAN> <SPAN class="operator token">+</SPAN> tbinfo <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\nError Info:\n "</SPAN> <SPAN class="operator token">+</SPAN> \ str<SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>exc_type<SPAN class="punctuation token">)</SPAN><SPAN class="operator token">+</SPAN> <SPAN class="string token">": "</SPAN> <SPAN class="operator token">+</SPAN> str<SPAN class="punctuation token">(</SPAN>sys<SPAN class="punctuation token">.</SPAN>exc_value<SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>pymsg<SPAN class="punctuation token">)</SPAN> msgs <SPAN class="operator token">=</SPAN> <SPAN class="string token">"Arcpy ERRORS:\n"</SPAN> <SPAN class="operator token">+</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetMessages<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN> <SPAN class="operator token">+</SPAN> <SPAN class="string token">"\n"</SPAN> <SPAN class="keyword token">print</SPAN><SPAN class="punctuation token">(</SPAN>msgs<SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
Thanks, Ahmed. Unfortunately, your options for workarounds are limited to:
1. Insert 1 record in the table2. Manually update entity via ArcCatalog and register3. Create all feature classes from Arcpy, not SQL
Thank you Christian for your response ,
regarding the workaround it wont easily apply in my case because the size,number of the tables and the relations it would take a lot more than registering the features manually!
Will appreciate sharing any other workaround to fix it it ...
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.