# -*- coding: cp1252 -*-
import sys
import traceback
import subprocess
import arcpy
try:
arcpy.env.workspace = r"C:\xxESRI\Desktop10.4\ArcCatalog\12C_oracle.sde"
txtPath = r"C:\Users\FCList.txt"
txt = open(txtPath, "r")
for line in txt.readlines():
fcName = line.split(":")[0]
print (fcName)
arcpy.RegisterWithGeodatabase_management(fcName)
print ("{0} ist registriert".format(fcName))
txt.close()
except:
try:
txt.close()
except:
pass
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \
str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
print(pymsg)
msgs = "Arcpy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
print(msgs)
Solved! Go to Solution.
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.
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.
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 ...
Thanks, Ahmed. Unfortunately, your options for workarounds are limited to:
1. Insert 1 record in the table
2. Manually update entity via ArcCatalog and register
3. Create all feature classes from Arcpy, not SQL
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__ = 'WebbL'
import sys
import traceback
import subprocess
import arcpy
try:
arcpy.env.workspace = r"C:\xxESRI\Desktop10.4\ArcCatalog\12C_oracle.sde"
txtPath = r"C:\Users\FCList.txt"
txt = open(txtPath, "r")
for line in txt.readlines():
fcName = line.split(":")[0]
#Add a feature of required geometry type
fcGeometryType = line.split(":")[1]
inputGeometryFeat = [os.path.join(geometryTemplateFolder, fcGeometryType)]
arcpy.Append_management(inputGeometryFeat, fcName, "NO_TEST")
print (fcName)
arcpy.RegisterWithGeodatabase_management(fcName)
print ("{0} ist registriert".format(fcName))
#Clean up the template geometry
arcpy.DeleteFeatures_management(fcName)
txt.close()
except:
try:
txt.close()
except:
pass
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
pymsg = "PYTHON ERRORS:\nTraceback Info:\n" + tbinfo + "\nError Info:\n " + \
str(sys.exc_type)+ ": " + str(sys.exc_value) + "\n"
print(pymsg)
msgs = "Arcpy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
print(msgs)