Reference to active document in ArcMap Failed from PyScripter

2948
5
05-02-2016 07:14 PM
JohnBonifas1
New Contributor III

...If I try to set a reference to the currently open map in ArcMap, it will work in ArcMap's python console, but it will not work in PyScripter:

b.png

a.png

I really hope that I'm just doing something wrong, otherwise I lose the great benefits I get from writing and debugging code in PyScripter.

Thanx.

0 Kudos
5 Replies
curtvprice
MVP Esteemed Contributor

Sorry -- the PyScripter Python process is separate from the Python process under ArcMap - so it definitely can't access a "current" document. You could work with a saved .mxd document, but you can't interact with ArcMap from another Python session.

The way I test tricky things in arcpy.mapping is by trying them out using ArcMap's Python command window.

JohnBonifas1
New Contributor III

...Programmers who are reading this will instantly realize how crummy that is. I as a programmer can imagine how impossible it would be to try to develop scripts in Microsoft Office without the VBA Editor. It has 100% reliable access to *ALL* of the host applications' objects.

Does anybody have inside information (Mr. Patterson....?) as to when ArcGIS 10 will have *ROBUST* support for external python editors. This is ridiculous!! 

0 Kudos
Luke_Pinner
MVP Regular Contributor

John Bonifas wrote:

...Programmers who are reading this will instantly realize how crummy that is. I as a programmer can imagine how impossible it would be to try to develop scripts in Microsoft Office without the VBA Editor. It has 100% reliable access to *ALL* of the host applications' objects.

Does anybody have inside information (Mr. Patterson....?) as to when ArcGIS 10 will have *ROBUST* support for external python editors. This is ridiculous!!

Your analogy is poor. The VBA Editor is built in to the host Office application, it is not an external editor.  A better analogy would be to compare the built in ArcGIS python window. This does have access to the current map document. 

DanPatterson_Retired
MVP Emeritus

and to add to Luke's comments, I use Pythonwin and Pyscripter with ArcMap 10.4.1 and ArcGIS Pro 1.2 all the time.  In fact, I have only used the builtin IDE once or twice.  Pycharm seems to have issues with some, but for the most part, setting up an external IDE to run with ArcWhatever doesn't seem to be an issue for most.  I am sure the esri developers aren't using the builtin IDE for development an testing

0 Kudos
Luke_Pinner
MVP Regular Contributor

Dan, I agree with you re. ease of using external editors with arcpy. I think the OPs complaint was more about not being able to control a running application/map doc from python.  Which to my mind is more in the realm of arcobjects.