|
POST
|
I am running a similiar script to copy & paste annotations, which is why I posted in this thread. The copy & paste part of my script works fine. I have two annotation Feature Classes, but only want the parentheses added to one Annotation Feature Class. Which, is why I attempted to specify the Feature Class to add the parentheses. I probably should have set up a conditional statement. Your suggestion of "(" + !TextString! + ")" works using Field Calculator. Parentheses are added to selected values within the TextString field. Since your script is just a geoprocessing script, you could build the Selection and field calculation in Model Builder and export that as a Python Script. If you had been using cursors to do this then it would be the same expression, just set to a specific field in a cursor operating on the correct layer. A more sophisticated Field Calculator expression could add parentheses only where they did not already exist and otherwise leave the field as it is, so that even if you did not select the records in advance the output would be fine: def AddParentheses(TextString):
Output = TextString
if Output[0] != "(":
Output = "(" + Output + ")"
return Output Expression: AddParentheses(!TextString!)
... View more
09-16-2013
07:26 AM
|
0
|
0
|
3514
|
|
POST
|
I changed the text to match my field name. My field name is TextString. So, my line of script reads: "(" + !TextString! + ")" But, a Syntax Error is returned. Changing the outer double quotes to single quotes eliminates the syntax error, yet does not add the parentheses. I have a couple of Annotation Feature Classes with the field TextString. Then, I attempted to specify which Feature Class to apply the parentheses. '(" + (History)!TextString! + ")' The script does not have any errors. Yet, does not add the parentheses. I have no idea what you think you were doing in the second calculation, but that version definitely should not work. Aren't you just using a single feature class for the anno? If two feature classes are involved you never mentioned that. Screen shot the table and the field calculator dialog set up you used with my original expression. I want to see exactly what you have and what you did. Use the Field Calculator field list to build the expression and to insert the field name in the calculation. Quotes should be fine, but so should single quotes (only for Python, not for VB Script).
... View more
09-16-2013
06:37 AM
|
0
|
0
|
3514
|
|
POST
|
Okay I found a way to make it work... although I still think there should be an easier way. I created a new field and used Field Calculator to define the values from the column I was working with. However, if I just did them all at once, all the <NULL> values became zero which I couldn't have but I also couldn't define them as No Data because it's a number field and won't accept text. So first I used FC to make all the <NULL> values a value outside my existing range of values, then calculate the rest of the values normally. Then I classified the values to that the new, outside value was in a class on its own and I changed the label to "No Data". I think this is harder than it should be but at least it works I suppose. However my issue now is that, because I had to use a higher value than the rest, "No Data" appears on TOP of the rest of the values in the legend where I think it should be at the bottom, under 0. On your earlier issue, I suspected you had a join involved. Null values are created 2 ways with joins. First, if no record in the joined table matches the table it is joined to, then the entire record is Null. This is the only way joined data can appear when it has no matching value and the only way to overcome it is to add a record to the joined table that matches the join field value, or remove those records from the primary table. The second occurs when a record match between tables exists in the join field, but the field you are using to symbolize has a Null value. In this case you must directly open the table that you intend to make a join table outside of the join all by itself. Then you can calculate the values in the original table and when the table is joined the values will not be null anymore. Bottom line is that in both cases you have to edit the original table you intend to join to both ensure a complete record match and complete field data before creating a join. Your solution is fine and actually not that difficult or involved compared to most problem solving in GIS. You got off easy. Get used to the feeling that there should be an easier way and finding out there isn't with this software. That is the norm. Anyway, as far as the number sorting, what is wrong with using -1 (or some other negative number) as a value for the Nulls? That would make the no- data values appear at the bottom of your list.
... View more
09-16-2013
06:25 AM
|
0
|
0
|
2282
|
|
POST
|
:S Well it isn't working for me. Every time I try to use Field Calculator on a number field it is grayed out. Why would that be? No idea without any information on what version of ArcMap you are using, what database you are using, if you have added any joins to your data, etc. Based I what I know of your set up all I can say is it works for me and definitely should work for you if you are working with normal unjoined geodatabase or shapefile data.
... View more
09-16-2013
05:20 AM
|
0
|
0
|
4466
|
|
POST
|
dear sir see the attachment for detail. its not working. Screen shot the actual field calculator screen. It does work, so something is wrong in the way it was transferred, but I can't tell from the result screen, since I don't use that to evaluate failures. Maybe at work I can recheck it. But the calculation works. The expression should not contain the word "def " in front of the AutoIncrement(!CID!). "def " should only occur in the codeblock. Did you type that word in the expression, or did the results tab insert that word in the expression? Edit: After running the calculation and looking at the results tab inputs, I have confirmed that you should not have the word "def " in the expression portion of the calculation, only in the codeblock portion.
... View more
09-16-2013
05:11 AM
|
0
|
0
|
5335
|
|
POST
|
Yes, I tried that too. But because you want to symbolize Quantities, you need a number field and the only way to use Field Calculator is with a Text field so unfortunately this won"t work. Field calculator works with number fields perfectly fine. Selecting Null values and overwriting them with the Field Calculator is no different between a text field and a number field. Why would you think otherwise?
... View more
09-16-2013
05:08 AM
|
0
|
0
|
4466
|
|
POST
|
I am not sure I have a solution, but I am curious why you didn't use the TableControl Redraw method? tableWindow.TableControl.RemoveAndReloadCache() tableWindow.TableControl.Redraw()
... View more
09-15-2013
07:47 AM
|
0
|
0
|
2397
|
|
POST
|
Thanks for That! Where is this documented? I'm having a hard time finding this kind of info. The only reason it is hard to find it is that it doesn't exist. 😉 It is found in the user forum only as far as I have seen. Users had to do the same for VBA back when it used to work. So be grateful for the furums.
... View more
09-13-2013
01:42 PM
|
0
|
0
|
5680
|
|
POST
|
Thanks, But I bet your fc is a line feature class. My feature class is a point. Does XMax work for points?? No. It does not. There is no extent for a point, only for a buffer polygon around a point. For the X coordinate of the point itself you calculate the X of the point's Centroid. So it is: !Shape.Centroid.X! Here is the help that lists the valid geometry calculations allowed for each feature class type through the Geometry calculator. There are several others available through the Field Calculator, like extent, but an extent means an object has at least the potential to have both height and width, which a point cannot have.
... View more
09-13-2013
12:04 PM
|
0
|
0
|
5680
|
|
POST
|
This seems very easy, but I cannot figure it out. I need to calculate the X-Coordinate and Y-Coordinate to the appropriate fields in my featureclass (XCoord, YCoord). I am trying something like this to no avail: arcpy.CalculateField_management(Maxtbl, "XCoord", "!shape.extent.XMax!", "PYTHON_9.3", "") Maxtbl is set to: r"V:\is\work\mb\Util\MaximoMobile\geodb\TestSnappingSigns.gdb\MaximoSigns_Test" (my feature class). The shape properties/methods don't seem to be documented very well--where do I find those? Many of the geometry calculation examples are contained in this help page. This specific example seems to match the one you are doing, but is written as though you are doing the calculation in Desktop: Parser: Python Expression: !shape.extent.XMax! This was built using ModelBuilder and I know it works for my data. # Import arcpy module import arcpy # Local variables: CENTERLINE_ROUTES_MERGED = "\\\\Agency\\agencydfs\\Trans\\rfairhur\\Layers\\Centerline_Synch.gdb\\CL_Maint\\CENTERLINE_ROUTES_MERGED" # Process: Calculate Field arcpy.CalculateField_management(CENTERLINE_ROUTES_MERGED, "EXTENT_MAXX", "!Shape.extent.XMax!", "PYTHON_9.3", "") It appears the syntax is identically configured to yours (assuming the fc name and field name were changed for our respective databases), so perhaps the problem is with the rest of your model. Possibly a lock is being placed on the fc that prevents the calculation from occurring or you mistyped something in the fc name. Try capitalizing the word Shape in the calculation, since at 10.0 or later it gets picky about capitalization and in my fgdb Shape is capitalized.
... View more
09-13-2013
11:41 AM
|
0
|
0
|
5680
|
|
POST
|
I had the chance to test my code and it worked. So this is the calculation you need and all you should need to do is match your Route ID case field. I did not test a Null value in the RID field, so it is possible that if Null values can be in your Route ID field that the code would need to be modified slightly.
... View more
09-13-2013
11:24 AM
|
0
|
0
|
5335
|
|
POST
|
The string is not working. I suspect that is because I asked the wrong question. I have an Annotation Feature Class that is displaying the information as integers within ArcMap, but the field type is a string. Than the text should be calculated to a simple Python calculation of: "(" + !AnnoText! + ")" where you are calculating the annotation text field and that text field name is AnnoText. Change AnnoText to match your actual annotation text field name. The same simple calculation in VB Script is: "(" & [AnnoText] & ")"
... View more
09-13-2013
09:38 AM
|
0
|
0
|
3514
|
|
POST
|
hello python hero and legends. i have more then 23 routes generated by using network analyst. later on, i have converted the route into point shapefile. new formed point shapefile have many hundred of points for each routes. i have created a new column and i want to populate that column with sequential numbers for each point. a python script is available for such calculation but this scripts generates sequential number starting from 1st point to last one regardless the route class. i am looking for some advance calculation. i want sequential numbering for each route in new column. like route type seq.no 1 point 1 1 point 2 1 point 3 1 point 4 2 point 1 2 point 2 2 point 3 . . . . so on. i need all this is a single python script. looking forward your great contribution. Nadeem Fareed I have adapted the standard Python AutoIncrement Field Calculation to use a dictionary to keep track of the Route ID count, which I believe will do what you want: Parser: Python Show Codeblock: Checked Pre-Logic Script Code: recDict = {}
def autoIncrement(RID):
global recDict
pStart = 1 # adjust start value, if required
pInterval = 1 # adjust interval value, if required
if RID in recDict:
recDict[RID] = recDict[RID] + pInterval
else:
recDict[RID] = pStart
return recDict[RID] Expression: autoIncrement(!RID!) # Put your Route ID field name in the parentheses. The records will sequence in the order that they are encountered in the point fc, which will be the order of the points along the route if that is the order they are stored in the point fc by your route conversion to point method.
... View more
09-13-2013
03:34 AM
|
0
|
0
|
5335
|
|
POST
|
All, I am writing a similiar script. I need the output to have parentheses added around an integer. For example, instead of 31, I need the output to be (31). Where can I locate information on how to add parentheses? In python to make an integer variable into a string with parentheses added around it you would do something like: parenInt = "(" + str(myInt) + ")" where myInt is an integer value variable and parenInt is a string of the interger surrounded by parantheses.
... View more
09-12-2013
12:21 PM
|
0
|
0
|
2666
|
|
POST
|
Here is the second shot just to show it could deal with a lot of labels. Please assign points to my posts by pressing the up arrow on the right side of each post above the number.
... View more
09-11-2013
05:01 PM
|
0
|
0
|
6639
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 7 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-09-2026
12:59 AM
|