View by status   

Field Calculator and Python

  • 400

  • Might have missed this in other threads..but...I have been preparing course notes for the upcoming year using 10 and was pleasantly suprised to see that you could use Python code and defs for use in the field calculator.

    1  I was disappointed that the only load/save were to VBScript *.cal files....why not *.py files?
    2  When the Python radiobutton is toggled, why not popup the default Python editor so that scripting can be done from there rather than that tiny window that doesn't enforce Pythonic indentation.
    3  Why is there a "lock" on the shapefield???  There are numerous Avenue scripts that worked on the shapefield to perform tasks that still can't be done simply.

    So in short, load/save to *.py, open the default Python editor and remove locks on the shapefield
    Tags :
    Posted by   Dan_Patterson  to ArcGIS DesktopEducation Jul 15, 2010

Share this idea Report Abuse

Comments (7)

Please log in to post a comment.

May 30, 2013
Yes please!

Jan 26, 2012
Totally agree in regard to having the python window load up in the advanced mode, and +1 for label, and display expressions to utilize this window as well.

Aug 17, 2010
Thanks for the NIM on the workaround.  Now on to the Transform2D stuff :)

Aug 13, 2010
In regards to VbScript .cal files, you can save your Python calculation to a .cal file as well. The only thing that is not part of the .cal file structure is parser type. For example, if you load a python .cal file, you have to manually switch the parser on the UI to python. We have an enhancement in our system to support the parser as part of the .cal. The tracking number is NIM059618.

Jul 27, 2010
the old transform2D class is more what I am looking for, I still use 3.x to perform many shapefile transformations on polylines and polygons.  I am sure the functionality is there it just needs to be exposed without having to write code in Python to do the translation, rotation and scaling (which would inevitably be slow)

Jul 23, 2010
In regards to the lock on the shape field, can you try this again at 10? It should work. We have a field calculator sample in the help that will modify the shape via the field calculator:

Go down to the sample: "For a point feature class, shift the x coordinate of each point by 100."

If you have a case where field calculator is not working for the shape field, I would like to know about it.

Jul 16, 2010
I agree that it is awkward to create either Python or VB code in the advanced modes of the field calculator or the label expression dialog. It would be great to have at least syntax highlighting, and even better to have auto-complete suggestions, and if that is most simply implemented using already installed IDEs, then all the better.



Terms and Conditions   |    Feedback   |   FAQs
Previous MonthNext Month