import arcpy import comtypes import comtypes.client import comtypes.gen.esriDataSourcesNetCDF ws_factory = comtypes.client.CreateObject("esriDataSourcesNetCDF.NetCDFWorkspaceFactory", interface = esriDataSourcesNetCDF.INetCDFWorkspaceFactory)
Frank,Thank you so much for your help. Your solutions worked like a charm. When I ran your script, the dir listed everything in the __dict__ of esriArcMapUI, as it should. esriArcMapUI.py was intact. With help from the person who wrote the example code that I used as a base, I have discovered that the comtypes generation of wrappers for ArcObjects occasionally fails, creating blank wrapper files. This seems to happen when a wrapper file already exists and GetModule() is called to build it again. I tested the wrapping process many more times, with both existing wrappers and a cleared out gen cache directory. I got a failure once, and that was for an existing wrapper. No failures for an empty cache. Also, the failures all produced readable but empty files. I have not encountered any instances of missing wrappers (where there should be one) or of corrupted, unreadable wrappers. I did also run your second, debug script quite a few times, and dir() reported as expected. The debug logs also showed no errors. So, I have modified my code to check for existing (the more secure open(filepath) way) wrappers and whether those existing modules are blank or not before I make any calls to GetModule(). Works great. I'll just be sure to rerun the wrapping process after ArcObjects updates. Thanks, again, Frank. I only wish I could give you some MVP points. Grrrr.Cheers,TiGIS SpecialistDurham, NH
import os import comtypes.client # change com_dir to whatever it is for you com_dir = r'C:\Program Files (x86)\ArcGIS\Desktop10.0\com' coms = [os.path.join(com_dir, x) for x in os.listdir(com_dir) if os.path.splitext(x)[1].upper() == '.OLB'] map(comtypes.client.GetModule, coms) # check add whatever you want here. import comtypes.gen.esriArcMapUI import comtypes.gen.esriGeodatabase print dir(comtypes.gen.esriArcMapUI)
import logging # grab rootlogger _loggy = logging.getLogger() _loggy.setLevel(logging.DEBUG) _loggy.addHandler(logging.FileHandler("derpdebug.log")) import os import comtypes.client # change com_dir to whatever it is for you com_dir = r'C:\Program Files (x86)\ArcGIS\Desktop10.0\com' coms = [os.path.join(com_dir, x) for x in os.listdir(com_dir) if os.path.splitext(x)[1].upper() == '.OLB'] map(comtypes.client.GetModule, coms) # check add whatever you want here. import comtypes.gen.esriArcMapUI import comtypes.gen.esriGeodatabase print dir(comtypes.gen.esriArcMapUI)
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.