|
POST
|
The exportToPDF method of data driven pages is where you control these parameters.
... View more
12-13-2012
04:17 AM
|
0
|
0
|
1212
|
|
POST
|
So no responses on this? I'll assume i'm doing it correctly then? I would probably do something like this. import os
import sys
import traceback
import arcpy
sde_prod = r"Database Connections\GENERAL_DATA-PROD.sde"
sde_stage = r"Database Connections\STAGING-PROD.sde"
# I find this useful to add
if not arcpy.Exists(sde_prod) or not arcpy.Exists(sde_stage):
# Add contingency sde connection file on network
sde_prod = "somwhere1"
sde_stage = "somewhere2"
arcpy.env.workspace = sde_prod
fcList = arcpy.ListFeatureClasses("*PERM_ABA*")
try:
for fc in fcList:
arcpy.DeleteFeatures_management(fc)
print "Delete {0}".format(fc)
arcpy.Append_management(
os.path.join(sde_stage, fc), os.path.join(sde_prod, fc), "TEST")
print "Append {0}".format(fc)
except arcpy.ExecuteError:
# Get the tool error messages
msgs = arcpy.GetMessages(2)
# Return tool error messages for use with a script tool
arcpy.AddError(msgs)
# Print tool error messages for use in Python/PythonWin
print msgs
except:
# Get the traceback object
tb = sys.exc_info()[2]
tbinfo = traceback.format_tb(tb)[0]
# Concatenate information together concerning the error into a message
pymsg = "PYTHON ERRORS:\nTraceback info:\n{0}\nError Info:\n{1}".format(
tbinfo, sys.exc_info()[1])
msgs = "ArcPy ERRORS:\n{0}\n".format(arcpy.GetMessages(2))
# Return python error messages for use in script tool or Python Window
arcpy.AddError(pymsg)
arcpy.AddError(msgs)
# Print Python error messages for use in Python / Python Window
print "{0}\n".format(pymsg)
print msgs
... View more
12-11-2012
12:16 PM
|
0
|
0
|
2099
|
|
POST
|
Thanks for the response...so do I only have to put in "CURRENT" within the parenthesis or do I need to add in the file path as well? I'm trying it with just "CURRENT" and it's not going through... You can look at some of the examples in the help to get an idea of how to use the arcpy.mapping module.
... View more
12-11-2012
11:58 AM
|
0
|
0
|
1409
|
|
POST
|
Matt - you mean the mxd object was created from the currently open map document, right? mxd = arcpy.mapping.MapDocument("CURRENT")
....
mxd.save()
Yes exactly Curtis, sorry if it wasn't clear. I had meant to attach the code you did.
... View more
12-11-2012
07:13 AM
|
0
|
0
|
1409
|
|
POST
|
You cannot use mxd.save() while the target map document is open unless you call this from within the mxd using the "current" parameter for the path.
... View more
12-11-2012
06:14 AM
|
0
|
0
|
1409
|
|
POST
|
In the label placement properties did you try checking "remove duplicates"? Here is a link to finding duplicates without ArcInfo. You would then need to delete or export non-identical features to a new table. http://forums.arcgis.com/threads/4021-ArcGIS-10-Pre-Release-finding-duplicates?p=12085&viewfull=1#post12085
... View more
12-10-2012
10:04 AM
|
0
|
0
|
6518
|
|
POST
|
I possibly found a way to do it. Not all that fast though. You'll have to change all the field names to your data. It will return a label for every feature populated by every item in your target field that match the key field value. def FindLabel([QS], [TWP]):
val_list = []
keyField = "TWP"
keyVal = [TWP]
field = "QS"
fieldVal = [QS]
layer = "ats"
with arcpy.da.SearchCursor(
layer, field, "{0} = {1}".format(keyField, keyVal)) as cursor:
for row in cursor:
val1 = row[0]
val_list.append(val1)
returnVal = "\n".join(val_list)
return returnVal
... View more
12-10-2012
08:18 AM
|
0
|
0
|
6518
|
|
POST
|
I also came across this method. Seems like a similar issue. It's a process you'd probably want to automate as well if your labels ever change. http://forums.arcgis.com/threads/4675-Stacking-labels-multiple-records-single-point-two-attributes?p=13957&viewfull=1#post13957
... View more
12-10-2012
06:37 AM
|
0
|
0
|
6518
|
|
POST
|
There is no way I can think of to reference multiple rows as a single label using label expressions. You might be able to get around it by having a separate script that creates the labels in a text file and then the label expression references that. I can't imagine it would be very good performance wise though, especially if there are a lot of features. A better way may be to create a table that has a single field for each label line. So for our sample row field1 = 204, field2 = PM2A, field 3 = HAFO (4-10T) etc. Depending on how your data is set up you could try pivot tables http://resources.arcgis.com/en/help/main/10.1/index.html#//0017000000n8000000 Either way you'd probably want to create an annotation layer to reference instead of dynamically labelling each time.
... View more
12-10-2012
06:19 AM
|
0
|
0
|
6518
|
|
POST
|
I don't really like how this is used in a cursor loop. I imagine it would be cleaner to assemble a list of unique values and loop through that creating feature layers with definition queries to process on. Is your aoaName variable a unique value? Also, you don't seem to be calculating the same field you create. arcpy.AddField_management(Intersect_Fishnet, "CELL_LENGTH_KM", "FLOAT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "") arcpy.CalculateField_management(Fishnet_Layer, "CALC_LENGTH_KM", "!shape.length@kilometers!", "PYTHON", "") Probably not related, but also post how you create your Output_FileGDB variable.
... View more
12-10-2012
04:39 AM
|
0
|
0
|
1144
|
|
POST
|
I'm not sure I understand what you are trying to do with this line (besides you needing == isntead of =). if long( [POLE_PRIKEY] ) = long( [POLE_PRIKEY] ): Something like this should work though. def FindLabel([FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [POLE_PRIKEY]):
if long( [POLE_PRIKEY] ) == long( [POLE_PRIKEY] ):
labelText = '{0}\n{1}\n{2}'.format([FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT], [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT])
return labelText
else:
labelText = [FIBER_ASSEMBLY_UNITS_ASSEMBLY_UNIT]
return labelText In terms of accessing the data from a relate, I think you will need to look into using a join.
... View more
12-06-2012
01:12 PM
|
0
|
0
|
6518
|
|
POST
|
You are going to need to post your entire code because what you posted here makes little sense without the context of where your variables are coming from. Edit: All the examples seem to use lists fine.
... View more
12-06-2012
10:52 AM
|
0
|
0
|
1144
|
|
POST
|
I know there is a better way to do this, I just can't remember what it is. Something like this should get the result you want I believe. for elm in arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT"): if elm.name == "ATSList": elm.elementPositionX = 6.5 elm.elementPositionY = 1.0 entry = "\r\n".join(FieldValList) elm.text = "Within Theoretical:\r\n{0}".format(entry) Edit: Maybe that is better Edit2: If they are not string values in your list try this. "\r\n".join(map(str, FieldValList))
... View more
12-05-2012
01:19 PM
|
0
|
0
|
1358
|
|
POST
|
I'll post a simple example of straight joining a list of fields. It assumes the key field is the same name in both tables.
import arcpy
key_field = # common field to join on
field_list = [# list of field names to join]
update_lyr = # table to update, usually I limit this to the key_field only
avi_view = # table to join, usually I create this with a field map limited to my field_list but it isn't necessary
# This creates a list of input fields storing the name, type and length
avi_type_dict = dict((f.name, (f.type, f.length))
for f in arcpy.ListFields(avi_view))
# this adds all the fields in your field list and references the dict of types, lengths to make them the same
for f in avi_field_list:
arcpy.AddField_management(
forest_lyr, f, avi_type_dict [0], field_length=avi_type_dict [1])
# this loads all of the input rows into a dictionary
view_dict = {}
for row in arcpy.SearchCursor(avi_view):
view_dict[row.getValue(key_field)] = dict(
(f, row.getValue(f)) for f in field_list)
# this updates the target table
updateCursor = arcpy.UpdateCursor(update_lyr)
for row in updateCursor:
for f in field_list:
updateVal = view_dict[row.getValue(key_field)]
row.setValue(f, updateVal)
updateCursor.updateRow(row)
... View more
12-03-2012
08:47 AM
|
0
|
0
|
3165
|
|
POST
|
Must have had my blinders on, didn't even notice you left that out of the code you posted.
... View more
11-29-2012
10:23 AM
|
0
|
0
|
2289
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-17-2011 10:36 AM | |
| 1 | 08-16-2012 10:48 AM | |
| 1 | 10-31-2012 08:39 AM | |
| 1 | 07-16-2012 01:52 PM | |
| 1 | 03-15-2012 10:57 AM |
| Online Status |
Offline
|
| Date Last Visited |
08-22-2024
11:12 PM
|