Skip to main content
10 events
when toggle format what by license comment
Mar 14, 2022 at 23:00 history edited PolyGeo CC BY-SA 4.0
deleted 61 characters in body
Jan 12, 2011 at 23:27 comment added blah238 Added an answer that implements what I was describing, pretty handy in case you delete the "gen" folder or reinstall comtypes or don't want to do that initial wrapping of all the libraries. Slightly less typing too for all those imports!
Jan 12, 2011 at 17:31 comment added blah238 Alternatively, you could just put the import statement for one (or all) of the generated ESRI modules in a try/except, and in the except, try to run GetModule on that OLB (or all), and then try the import again. I am not sure if that could be done in a separate module due to scoping however.
Jan 12, 2011 at 3:43 comment added celticflute A thought I had (but have never implemented) is that you could create a text file that contains a flag that gets set after OLBs are initially wrapped. A wrapping function could check that flag to see if it should wrap modules again. Might work. (ini files anyone?)
Jan 12, 2011 at 3:39 comment added celticflute >> Would wrapping only the OLBs actually needed by your script significantly reduce that initial wrapping time? Yes, but, in my case at least, initial wrapping is only about 20 secs. tops. I am running production scripts that make feature-based graphics for feature classes having 10,000+ features. The processing time is already huge, so an initial 20 secs (or even a little longer) hasn't seemed a problem to me.
Jan 12, 2011 at 3:29 comment added celticflute >> Would wrapping only the OLBs actually needed by your script significantly reduce that initial wrapping time?
Jan 11, 2011 at 18:05 comment added blah238 Never mind that last part, looks like the wrappings are permanent by default (in the comtypes\gen files), and by calling my WrapModules function I am forcibly recreating them even if they already exist. I think you did mention this in your original answer I linked in my question.
Jan 11, 2011 at 17:21 comment added blah238 Thanks for the detailed suggestions. The structure of the script did not seem to play a role, and this structure lets me use it as a helper module for use in other scripts. Fortunately I didn't have to mess with the comtypes\gen files! Another question for you: Would wrapping only the OLBs actually needed by your script significantly reduce that initial wrapping time? That might be a handy function to have in a helper module like this. Alternatively, can the wrappings be made permanent in the filesystem so you do it once and then never have to again?
Jan 11, 2011 at 5:01 history edited celticflute CC BY-SA 2.5
Added caution to make sure ArcMap is running before running the Python script
Jan 11, 2011 at 4:49 history answered celticflute CC BY-SA 2.5