|
POST
|
Thanks for this post, I'm sure this information will come in handy for quite a few people. For those wishing to get started with less hassle, there are pre-built binaries already available at http://www.lfd.uci.edu/~gohlke/pythonlibs/#pycuda
... View more
04-19-2011
10:57 AM
|
0
|
0
|
1855
|
|
POST
|
Python does support the degree symbol, that \x00 sequence you're seeing is the escaped version of the string so that it will work in ASCII. You're safer using a unicode object with an escaped character. Sets will not work here, Python sets are unordered meaning you can only assume that all the elements will be there, but when asking for them you will get them back in an arbitrary manner. You can use zip to unify two lists in the way you're looking for. I would rewrite the script like this: symbols = (u'\u00b0', u"'", u"''")
Update_cursor = arcpy.UpdateCursor(feature_class)
for rows in update cursor:
coord = row.latitude
merged_items = zip(coord.split(u"-"), symbols)
merged_value = "".join(x + y for (x, y) in merged_items)
row.new_field = merged_value
Update_cursor.updateRow(row) The 'u' in front of the quotes signifies it's a unicode object -- this gives you more predictable behavior when working with extended characters. Then zip gives you a list of tuples of the form [(num1, sym1), (num2, sym2), (num3, sym3)]. Then you add each of the two items together into a single string, leaving you with a list of string, and then join each of those together into a single string.
... View more
04-13-2011
05:08 PM
|
0
|
0
|
1531
|
|
POST
|
Lower case 'f' on the param.filter attribute, and .list is lower case as well.
... View more
04-04-2011
04:54 PM
|
0
|
0
|
671
|
|
POST
|
Use either if mxd.supports("dataDrivenPages"):
or if hasattr(mxd, "dataDrivenPages"):
... View more
04-04-2011
01:22 PM
|
0
|
0
|
1151
|
|
POST
|
I don't think this is an event loop problem at all, no even loop is spun up just by importing arcpy (however, there is an event loop running in ArcMap and friends that WILL conflict with the easygui event loop). This looks like a locale issue -- try setting your locale to English - US in ArcGIS administrator under the Advanced... button and see if this still is an issue. If so, try using python's locale module to reset the locale to en_US after importing arcpy.
... View more
04-04-2011
01:21 PM
|
0
|
0
|
712
|
|
POST
|
You need to save the MXD when you're done. import arcpy, os
mxd = arcpy.mapping.MapDocument("M:/nih/AsbestosAbatement/Floorplans/BLDG_6A/Floorplanpdf.mxd")
for lyr in arcpy.mapping.ListLayers(mxd, "BuildingFloorLines"):
layer.definitionQuery = "[FLR] = '02'"
mxd.save()
print 2 If you're currently in arcmap and want to act on the active map: import arcpy, os
mxd = arcpy.mapping.MapDocument("current")
for lyr in arcpy.mapping.ListLayers(mxd, "BuildingFloorLines"):
layer.definitionQuery = "[FLR] = '02'"
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
print 2
... View more
03-31-2011
05:45 AM
|
0
|
0
|
566
|
|
POST
|
Do not change the active data frame in Geoprocessing scripts. Before a geoprocessing tool runs, it takes a snapshot of the active data frame's layers, and then restores it when it finishes executing. By changing the active data frame in between the snapshot and the restore, it gets into a confused state and may drop layers.
... View more
03-25-2011
03:58 PM
|
0
|
0
|
886
|
|
POST
|
Try this: row.fieldoutput=(row.field or '')+(row.field2 or '')
... View more
03-17-2011
11:32 AM
|
0
|
0
|
715
|
|
POST
|
Ah, I see now. Need to strip the quotes. multimxds = [filename[1:-1] for filename in string.split(arcpy.GetParameterAsText(0), ";")]
... View more
03-16-2011
05:08 PM
|
0
|
0
|
3164
|
|
POST
|
Could you post the output from the geoprocessing window?
... View more
03-15-2011
10:09 PM
|
0
|
0
|
3164
|
|
POST
|
Could you put an AddMessage in your loop to see what file it's failing on? #MY CODE
import arcpy, os, sys, string
#overwirte existing PDFs
arcpy.OverWriteOutput = 1
multimxds = string.split(arcpy.GetParameterAsText(0), ";")
outputfolder = arcpy.GetParameterAsText(1)
#set variable for PDF name
#trying to set folder path
folderpath = outputfolder
#export to pdf
#trying to export to pdf using title name and folder parameter
for mxdloop in multimxds:
arcpy.AddMessage("Opening map document %s" % mxdloop)
mxd = arcpy.mapping.MapDocument(mxdloop)
name = mxd.title
pdf = folderpath + '\\' + name + ".pdf"
arcpy.mapping.ExportToPDF(mxd, pdf, 'PAGE_LAYOUT', 640, 480, 400)
... View more
03-15-2011
08:32 AM
|
0
|
0
|
3164
|
|
POST
|
import os
self.params[0].value = os.path.splitext(mxd.filePath)[0] + ".jpg" The map document object is not a string.
... View more
03-15-2011
08:29 AM
|
0
|
0
|
846
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 09-26-2012 02:46 AM | |
| 2 | 01-06-2011 08:22 AM | |
| 1 | 03-25-2014 12:18 PM | |
| 1 | 08-12-2014 09:36 AM | |
| 1 | 03-31-2010 08:56 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:22 AM
|