|
POST
|
I did not notice the .mxd rather than pdf, but it does not seem to effect it. I appreciate the advice, I think I will play around with my export parameters some. I am thinking about exporting the "current" individual pages then appending them at the end. If you think of anything else please let me know, I will post if I discover the answer and any other things that come up that might help. Thanks
... View more
06-08-2015
12:02 PM
|
0
|
0
|
2632
|
|
POST
|
Spatial join will work in this case, but this is a small part of a larger script where I would run into problems with this. I feel I am very close getting this way to work and would like to continue down this path. I really appreciate the help.
... View more
06-08-2015
11:16 AM
|
2
|
0
|
673
|
|
POST
|
Delete row/cursor did not work. I also noticed two things, it is just writing the results of the last page on all the pages, not the first page results like I thought. Also while I watch it export each page it is updating the text element in arcmap when it goes to each page while exporting, but not in the pdf.
... View more
06-08-2015
11:13 AM
|
0
|
5
|
2632
|
|
POST
|
Sorry about that. It seemed like I could only post in one area. I will not double post in the future.
... View more
06-08-2015
10:19 AM
|
0
|
0
|
673
|
|
POST
|
I will try that. I was playing around with deleting the text element but not the cursor and rows. I will start using da, was just re-diving into an old script and also using what is familiar, time to upgrade my knowledge.
... View more
06-08-2015
10:18 AM
|
0
|
0
|
2632
|
|
POST
|
I am trying to loop through exporting data drive pages, select data from another layer based on the page getting exported, and write a row of the results of the selection to a text element. Each page should have different results in text element. For each page getting exported I I want to select all the parcels within the current page/feature getting exported and write the results to the text element. What I have so far only writes the results for the first page on every page. When it runs it does seem to select the parcels per page while exporting, but it does not re-write the results to the text element. Not sure what I am missing? # Always run script in the mxd you are working on.
mxd = arcpy.mapping.MapDocument("CURRENT")
# Overwrites any existing features.
arcpy.env.overwriteOutput = True
# Uses the Dataframe called "Layers".
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
# Parcel Text Element
ParcelText2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "ParcelsText2")[0]
# Data Driven Pages Export Sheets
ExportSheets = arcpy.mapping.Layer("Sheets_11x17")
# Parcels
Parcels = arcpy.mapping.Layer("Parcels")
# Data Driven Pages mxd abbreviation
ddp = mxd.dataDrivenPages
# Loop through DDP's
for pageNumb in range(1, mxd.dataDrivenPages.pageCount + 1):
ddp.currentPageID = pageNumb
# DDP Export Sheet duplicate which has the page definition Query
SelectedSheet = arcpy.mapping.Layer("Sheets_11x172")
# Exports Row page
ExportSheetsPage = ddp.pageRow.PLAN_NUMBER
# Select Parcels withing my SelectedSheet
arcpy.SelectLayerByLocation_management(Parcels, "WITHIN", SelectedSheet)
# Use SearchCursor to get Parcels value and write to Parcel Text Element
rows = arcpy.SearchCursor(Parcels)
textValue = ""
for row in rows:
textValue += row.getValue("MAP_PARCEL")
ParcelText2.text = textValue
# Export Sheets
ddp.exportToPDF(r"Y:\GIS\GIS_Work\Working\parcel_test\maps\test.mxd")
... View more
06-08-2015
09:55 AM
|
0
|
12
|
9419
|
|
POST
|
I am trying to loop through exporting data drive pages, select data from another layer based on the page getting exported, and write a row of the results of the selection to a text element. Each page should have different results in text element. For each page getting exported I I want to select all the parcels within the current page/feature getting exported and write the results to the text element. What I have so far only writes the results for the first page on every page. When it runs it does seem to select the parcels per page while exporting, but it does not re-write the results to the text element. Not sure what I am missing? # Always run script in the mxd you are working on.
mxd = arcpy.mapping.MapDocument("CURRENT")
# Overwrites any existing features.
arcpy.env.overwriteOutput = True
# Uses the Dataframe called "Layers".
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
# Parcel Text Element
ParcelText2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "ParcelsText2")[0]
# Data Driven Pages Export Sheets
ExportSheets = arcpy.mapping.Layer("Sheets_11x17")
# Parcels
Parcels = arcpy.mapping.Layer("Parcels")
# Data Driven Pages mxd abbreviation
ddp = mxd.dataDrivenPages
# Loop through DDP's
for pageNumb in range(1, mxd.dataDrivenPages.pageCount + 1):
ddp.currentPageID = pageNumb
# DDP Export Sheet duplicate which has the page definition Query
SelectedSheet = arcpy.mapping.Layer("Sheets_11x172")
# Exports Row page
ExportSheetsPage = ddp.pageRow.PLAN_NUMBER
# Select Parcels withing my SelectedSheet
arcpy.SelectLayerByLocation_management(Parcels, "WITHIN", SelectedSheet)
# Use SearchCursor to get Parcels value and write to Parcel Text Element
rows = arcpy.SearchCursor(Parcels)
textValue = ""
for row in rows:
textValue += row.getValue("MAP_PARCEL")
ParcelText2.text = textValue
# Export Sheets
ddp.exportToPDF(r"Y:\GIS\GIS_Work\Working\parcel_test\maps\test.mxd")
... View more
06-08-2015
09:52 AM
|
0
|
3
|
4445
|
|
POST
|
Warning, I too am not very advanced. Also, I used this in the field calculator, not inside one of my scripts. Also, I think there are different rules on when to use " " or [ ] depending on the type of file. Where I am calling for a feature class in a database you are using an xlsx table. ?? I hope this helps some ?? Try this. def FindLabel ([OID]): strWhereClause = "OID" = \'{0}\".format([OID]) Instead of this: def FindLabel ( 😞 return def FindLabel ([OID]): strWhereClause = "TunnelRoomOID" = \'{0}\".format([OID])
... View more
03-18-2015
10:59 AM
|
1
|
1
|
2242
|
|
POST
|
Ian, That's it, learned something new. Thank you so much. - Matt
... View more
03-13-2015
08:47 AM
|
0
|
2
|
2767
|
|
POST
|
I am having a little trouble figuring out where I am going wrong. If I have "NW" in my direction field I want to move the point a certain distance, but if it is "NE" I want the move to be opposite. I think I am almost there but it will only take my last Update for all the features. import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
arcpy.env.overwriteOutput = True
fc = arcpy.GetParameterAsText(0)
NWxOffset = 200
NWyOffset = 200
NExOffset = -220
NEyOffset = -200
search = arcpy.SearchCursor(fc)
value = ""
for row in search:
value = row.getValue("direction")
with arcpy.da.UpdateCursor(fc, ["SHAPE@XY"]) as cursor:
if value == "NW":
for row in cursor:
cursor.updateRow([[row[0][0] + NWxOffset, row[0][1] + NWyOffset]])
elif value == "NE":
for row in cursor:
cursor.updateRow([[row[0][0] + NExOffset, row[0][1] + NEyOffset]])
arcpy.RefreshActiveView
... View more
03-13-2015
08:20 AM
|
0
|
4
|
7708
|
|
POST
|
That is it. Thank you! Just one minor thing in case someone else is looking to do this, the f in FindLabel should be a capital F. Also when filling in the spots relatefieldoflayer and PathToRelatedTable don't forget your " " and [ ]s! def FindLabel( [relatefieldoflayer] 😞 strWhereClause = '"RelateFieldOfTable" = \'{0}\''.format([relatefieldoflayer]) strpTable = "PathToRelatedTable" cursor = arcpy.da.SearchCursor(strpTable, "LableField", strWhereClause) result = "" for row in cursor: strLabel = str(row[0]) result += strLabel + "\n" return result.rstrip()
... View more
07-25-2014
07:32 AM
|
4
|
4
|
2242
|
|
POST
|
Dan, Thank you for taking time to review and respond. Yes, you are correct, it will take using an advanced expression. If you click on my link you will see an example of it in VBScript. What I cannot figure out is how to write that same advance expression in python.
... View more
07-25-2014
05:36 AM
|
0
|
0
|
2242
|
|
POST
|
Anyone know how to label from a related table in python? I figured out how to using VBScript form here: https://gisnuts.com/terra/blog/2012/05/16/label-features-with-attributes-from-related-records Cannot figure it out in python. If it can be done in VBScript I am hoping that means it can be accomplished in Python.
... View more
07-24-2014
01:04 PM
|
0
|
9
|
6597
|
|
POST
|
Anyone know how to label from a related table in python? I figured out how to using VBScript form here: https://gisnuts.com/terra/blog/2012/05/16/label-features-with-attributes-from-related-records Cannot figure it out in python. If it can be done in VBScript I am hoping that means it can be accomplished in Python.
... View more
07-24-2014
01:03 PM
|
0
|
0
|
3376
|
|
POST
|
Need some help with something similar. I have fields 'numbered' in order like so, AW/01, AW/02, AW/03 and I need to add one to each; so new set would go AW/02, AW/03, AW/04. How do I run the autoIncrement ignoring the first 3 characters [0:2]? Thanks for any help. -Matt
... View more
05-22-2014
07:38 AM
|
0
|
0
|
6636
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-11-2015 04:38 AM | |
| 4 | 07-25-2014 07:32 AM | |
| 1 | 11-23-2015 07:18 AM | |
| 2 | 06-08-2015 11:16 AM | |
| 2 | 06-08-2015 12:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|