-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap_robot_2017_landOfficers20180907.py
More file actions
614 lines (497 loc) · 24.6 KB
/
map_robot_2017_landOfficers20180907.py
File metadata and controls
614 lines (497 loc) · 24.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
# ArcPy.Mapping Module
# Map_Robot_v2017_inset
#
# land officer mapping tool
# zooms into file number of interest
# populates some info in text fields on map template
# new version has an inset map to show details of a selected parcel
# the main map ("Layers") will show the entire tenure to better show where
# it is on the land base
#
# October 2013
#
# Changes in layout for PMV
# layout also means text updater needed updating because they removed some fields
# and added others
#
#
# ------------------------------------------------------------------------
''' --------------------------------------------------------------
Date Started: October 25, 2012
Author: Denis Potvin
lost track of modifications.
this latest version:
- cleaned up some code
- mxd should have only Direct connect to BCGW
- fixed where clause1 for the client name
--------------------------------------------------------------'''
import arcpy, math, getpass, sys, re, os, textwrap
'''
# for accessing XTools toolbox
if arcpy.GetInstallInfo("desktop")["Version"] == '10.1':
toolboxPath = r'E:\sw_nt\DataEast\XToolsPro 10.1\Toolbox\XTOOLS PRO.tbx' # new ver of Xtools for 10.1
else:
toolboxPath = r'E:\sw_nt\DataEast\XToolsPro 10.2\Toolbox\XTOOLS PRO.tbx' # old ver of Xtools for 10.0
arcpy.AddToolbox(toolboxPath)
arcpy.gp.toolbox = toolboxPath
'''
#print "arg0 = " + sys.argv[0]
class myMXD(object):
''' creates a class to take in tenure stage, file number, parcel numbers, dimensions
inset map will zoom into the parcel, main map will zoom to entire extent
scale will be rounded off, a bunch of text fields will auto populate
and the world will be a better place
'''
mapDoc = "CURRENT" # Map Document Object
#mapDoc = r'W:\srm\sry\Local\projlib\2014-15\Auth_Lands_PMV\mxds\MapRobot2014.mxd' # !!! for PMV batch maps
mainDF = None # main data frame object
detailDF = None # detail inset map data frame object
mainDefQry = None # definition query for main map
detailDefQry = None # definition query for detail inset map
fileStage = None # tenure stage (Application, Tenure, Inventory,
fileNum = None
intridSID = None
dims = None
bcgw = r'Database Connections\BCGW.sde'
mxd = None
insetLocation = None
def __init__(self, fileStage, fileNum, intridSID, dims, insetLoc):
self.mxd = arcpy.mapping.MapDocument(self.mapDoc)
self.mainDF = arcpy.mapping.ListDataFrames(self.mxd, "Layers")[0]
self.detailDF = arcpy.mapping.ListDataFrames(self.mxd,"InsetDetail")[0]
print (self.mainDF.name)
print (self.detailDF.name)
self.insetLocation = insetLoc
# Defn query to filter out the other tenures/parcels.
# replace is to change ; to , for the SQL "IN" statement to work properly
# !!! CHANGE THIS PART FOR PMV MASS PRODUCTION MAPPING !!!
self.detailDefQry = "CROWN_LANDS_FILE = '" + fileNum + "' and TENURE_STAGE = '" + fileStage + "' AND INTRID_SID in (" + intridSID.replace(";",",") + ")"
#self.detailDefQry = "\"CROWN_LANDS_FILE\" = '" + fileNum + "'"
#self.detailDefQry = "CROWN_LANDS_FILE = '" + str(fileNum) + "'" # mass production mapping - only wanted the file num and nothing else
if insetLoc == "None":
self.mainDefQry = self.detailDefQry # no inset, both queries same
else:
self.mainDefQry = "CROWN_LANDS_FILE = '" + fileNum + "' and TENURE_STAGE = '"+ fileStage + "'"
#self.mainDefQry = "CROWN_LANDS_FILE = '" + str(fileNum) + "'" # for mass production mapping for PMV
self.fileNum = fileNum # file number of interest
# moving the inset Data frame to the desired location
posX, posY = self.insetPlace(insetLoc) # calling module to get X,Y
self.detailDF.elementPositionX = posX
self.detailDF.elementPositionY = posY
arcpy.RefreshActiveView()
# ----------------------------------------------------------------------
# insetPlace returns the X,Y location of the anchor point for the
# data frame depending on where the user wants to see the inset map
def insetPlace(self, insetLoc):
# potential anchor points for bottom Left of your inset map
minX = 0.725
minY = 2.95
maxX = 4.775
maxY = 6.75
noX = 9 # no inset map - move off the layout
noY = 8 # no inset map - move off the layout
# creating a dictionary to hold the possible locations of
# where the inset map would be
# inset map location is anchored to bottom left of the data frame
myDict = {"None": [noX,noY],
"Bottom Left": [minX, minY],
"Bottom Right": [maxX, minY],
"Top Left": [minX, maxY],
"Top Right": [maxX, maxY] }
codeList = myDict.keys() # get the keys
for itm in codeList:
#arcpy.AddMessage("checking out inset map placement: " + str(itm))
myLine = myDict[itm] # storing the selected list from the dictionary
if insetLoc == itm:
locX = myLine[0] # 1st item in the list
locY = myLine[1] # 2nd item in the list
break
return locX, locY # for location of inset map
# ----------------------------------------------------------------------
# insetPlace returns the X,Y location of the anchor point for the
# data frame depending on where the user wants to see the inset map
def dataFrameFilter(self, df, defQry, insetmap):
# get layer object
arcpy.AddMessage("beginning layer filter of data frame" + df.name)
arcpy.AddMessage(defQry)
lyr = arcpy.mapping.ListLayers(self.mxd, "Tantalis Files", df)[0]
arcpy.AddMessage(lyr.name)
arcpy.AddMessage("defined the lyr for Tantalis Files?")
# ARGH! REMEMBER TO CLEAR DEFINITION QUERY FIRST
# otherwise there'll be nothing to query if it's the 2nd time !
lyr.definitionQuery = ""
# Do selection and zoom in
print ('defQry:', defQry)
defQry = defQry.strip()
defQry = str(defQry)
#print '1 selected count', arcpy.GetCount_management(lyr)
arcpy.SelectLayerByAttribute_management(lyr,"CLEAR_SELECTION")
#print '2 selected count', arcpy.GetCount_management(lyr)
#arcpy.RefreshActiveView()
#print '3 selected count', arcpy.GetCount_management(lyr)
arcpy.SelectLayerByAttribute_management(lyr,"NEW_SELECTION", defQry)
self.SelectedSetChecker(lyr) # check for no polys or zero area
df.zoomToSelectedFeatures()
arcpy.AddMessage("zoomed to my selected feature! ")
arcpy.SelectLayerByAttribute_management(lyr,"CLEAR_SELECTION")
lyr.definitionQuery = defQry # filter the layer to just the ones you want
# main map, tiny polygon, and no inset, then zoom out
if df.name == "Layers" and df.scale < 10000 and insetmap <> "None":
df.scale = 10000
else: # otherwise do the scale rounding as per routine
df.scale = self.scalefixer(df.scale)
# ----------------------------------------------------------------------
# scaleFixer will round up the scale
# to the nearest 1000 or 10000
def scalefixer(self, currScale):
if currScale > 10000:
fixit = 4
else:
fixit = 3
fixneg = fixit * -1
newScale = math.ceil(currScale*10**fixneg)*10**fixit
return newScale
# ----------------------------------------------------------------------
def doDimensions(self, dFrame, lyr):
# Set Up Stuff
tmpDrive = "T:"
tmpFGDBname = "\\tmpfgdb_" + getpass.getuser() + ".gdb"
tmpFGDB = tmpDrive + tmpFGDBname
dimFC = tmpFGDB + "\\DimensionsFC"
tmpFC1 = tmpDrive + "\\tmpFC1.shp"
#tmpFC2 = tmpFGDB + "\\tmpFC2"
# Create a new temp FGDB if it doesn't already exist
if not arcpy.Exists(tmpFGDB):
arcpy.AddMessage("creating new " + tmpFGDB)
arcpy.CreateFileGDB_management(tmpDrive, tmpFGDBname)
else:
# if FGDB exists, then remove all the old layers
arcpy.AddMessage("Deleting old dimensions feature class if exists")
delList = [dimFC, tmpFC1]
for feat in delList:
self.delLayer(feat)
arcpy.AddMessage("finished deleting old temp feature classes")
arcpy.AddMessage("converting polygon to polyline")
arcpy.PolygonToLine_management(lyr, tmpFC1,"IGNORE_NEIGHBORS")
#dimLayer = arcpy.mapping.Layer(dimFC) # create layer object from dimFC feat class
arcpy.SplitLine_management(tmpFC1, dimFC)
arcpy.AddMessage("Splitting up the lines of polyline layer")
mainLyr = arcpy.mapping.ListLayers(self.mxd, "Dimensions", self.mainDF)[0]
detailLyr = arcpy.mapping.ListLayers(self.mxd, "iDimensions", self.detailDF)[0]
arcpy.AddMessage("updating the dimensions layer")
# changing the dimensions layer source to the new one
mainLyr.replaceDataSource(tmpFGDB, "FILEGDB_WORKSPACE", "DimensionsFC")
detailLyr.replaceDataSource(tmpFGDB, "FILEGDB_WORKSPACE", "DimensionsFC")
arcpy.AddMessage(tmpFGDB + " is my temp fgdb name")
arcpy.AddMessage("Dimensions data source changed: ")
#arcpy.AddMessage(upLyr.dataSource)
# !!! turning off the dimensions lyr on the main data frame if dimensions was already used on the inset map
# !!! otherwise dimensions is turned on for both... not ideal.
if dFrame == self.detailDF:
arcpy.AddMessage("inset measurements only")
mainLyr.visible = False
detailLyr.visible = True
arcpy.AddMessage("main: " + str(mainLyr.visible))
else:
arcpy.AddMessage("main map measurements only")
mainLyr.visible = True
detailLyr.visible = False
arcpy.AddMessage("main: " + str(mainLyr.visible))
arcpy.RefreshActiveView()
return lyr
# ----------------------------------------------------------------------
def delLayer(self,fc):
if arcpy.Exists(fc):
arcpy.AddMessage("Deleting old feature : " + fc)
arcpy.Delete_management(fc)
return # go back go waaaay bck
# ------------------------------------------------------------------------
# ---- SELECTED SET CHECKER ----
# check to see if selected set has > 0 features
# if yes then check to ensure the area of the polygons is <> 0
def SelectedSetChecker(self, lyr):
# counting rows in my selected set
rowcount = int(arcpy.GetCount_management(lyr).getOutput(0))
arcpy.AddMessage(str(rowcount) + " rows in selected lyr")
if rowcount == 0:
arcpy.AddError("The file you chose: " + str(self.fileNum) + "(" + str(self.fileStage) + ") - has zero polygons")
raise ValueError, "Sorry, does not exist in the BCGW"
else:
# check for zero area
rows = arcpy.SearchCursor(lyr) # going thru the precinct lyr
row = rows.next()
sumarea = 0
while row:
#Bruce Rea commented out the following line and replaced with Hectares area field
#tmp = row.getValue("SHAPE.AREA")
#tmp = row.getValue("TENURE_AREA_IN_HECTARES")
tmp = row.getValue("FEATURE_AREA_SQM")
if tmp == None:
tmp = 0
sumarea = sumarea + tmp
row = rows.next()
if sumarea == 0:
arcpy.AddError("The file you chose: " + str(self.fileNum) + " (" + str(self.fileStage) + ") - has zero area")
raise ValueError, "Check Tantalis to see if a shape has been entered"
del row, rows, rowcount
return
# ---- END OF MODULE: SELECTED SET CHECKER ----
def splitLineOnSpaces2(self,inString,maxLineBreak):
# https://docs.python.org/2/library/textwrap.html
arcpy.AddMessage("Splitting up the line string")
lineList = textwrap.wrap(inString, width=maxLineBreak)
return lineList
# ----------------------------------------------------------------------
# updates the text fields on the map
def txtUpdater(self, lyr):
arcpy.AddMessage("resetting variable values")
tantarea = 0
rows = arcpy.SearchCursor(lyr)
row = rows.next()
arcpy.AddMessage("starting get value statements")
purpose = row.getValue("TENURE_PURPOSE")
subpurpose = row.getValue("TENURE_SUBPURPOSE")
tentype = row.getValue("TENURE_TYPE")
subtype = row.getValue("TENURE_SUBTYPE")
tantarea = row.getValue("TENURE_AREA_IN_HECTARES")
dispID = row.getValue("DISPOSITION_TRANSACTION_SID")
legdesc = row.getValue("TENURE_LEGAL_DESCRIPTION")
arcpy.AddMessage(legdesc)
# calling Netherton's script to add carriage returns to the mega long legal description
# first arg is the legal descr, second is the max line length
#
lineList = []
maxlen = 88 # max line length on the map for legal descr
if legdesc is not None:
if len(legdesc) > maxlen:
# split the legal description into lines no longer than max len
#lineList = self.splitLineOnSpaces(legdesc, maxlen)
lineList = self.splitLineOnSpaces2(legdesc, maxlen)
else:
# legal description fits on one line
lineList.append(legdesc)
#arcpy.AddMessage(lineList)
arcpy.AddMessage("subliminal messaging here")
# join the split line using a carrage return
if len(lineList) > 11:
arcpy.AddMessage("creating a text file for the long legal desc")
#folder = r"\\spatialfiles.bcgov\work\srm\sry\Workarea\land_officers\PMV\legalDescr"
folder = r"W:\srm\sry\Workarea\land_officers\map_robot_2017\LongLegalDescr"
legfile = folder + r"\legal_descr_" + self.fileNum + ".txt"
filehand = open(legfile, "w")
filehand.write(legdesc)
filehand.close()
arcpy.AddMessage("completed text file writing")
lineList[11] = '(Truncated due to length. See next page for full legal description.)'
lineList = lineList[:12]
arcpy.AddMessage("truncated the extra long for the map")
var = '\n'.join(lineList)
#arcpy.AddMessage(var)
arcpy.AddMessage("finished a whole bunch of getValue statements")
if tantarea == None:
tantarea = 0
arcpy.AddMessage("...!!! WARNING - one of your shapes has zero area according to Tantalis")
dispID = row.getValue("DISPOSITION_TRANSACTION_SID")
# Adding up tenure area in hectares if there's more than one polygon
row = rows.next()
while row:
tmp = row.getValue("TENURE_AREA_IN_HECTARES")
if tmp == None:
tmp = 0
arcpy.AddMessage("...WARNING - one of your shapes has zero area according to Tantalis")
tantarea = tantarea + tmp
row = rows.next()
arcpy.AddMessage('updating text fields')
for elm in arcpy.mapping.ListLayoutElements(self.mxd, "TEXT_ELEMENT"):
if elm.name == "txtFileNo":
arcpy.AddMessage('getting file num')
elm.text = "File No: " + str(self.fileNum)
elif elm.name == 'txtClient':
elm.text = self.ClientName(dispID) # >>> Calling Module to get Client name
#arcpy.AddMessage("skipping client name?")
elif elm.name == 'txtPurpose':
elm.text = str(purpose)
elif elm.name == 'txtSubPurpose':
elm.text = str(subpurpose)
elif elm.name == 'txtType':
elm.text = str(tentype)
elif elm.name == 'txtSubType':
elm.text = str(subtype)
elif elm.name == 'txtMapsheets':
elm.text = self.mapsheetoverlay(lyr) # >>> Calling Module Mapsheet overlay
elif elm.name == 'txtTantalisArea':
if tentype == 'LICENCE':
elm.text = 'Area: ' + str(round(tantarea, 2)) + ' ha +/-'
else:
elm.text = 'Area: ' + str(round(tantarea, 2)) + ' ha' # removed "Tantalis" prefix to "Area"
elif elm.name == 'txtDispNo':
elm.text = 'Disposition No: ' + str(dispID)
elif elm.name == 'txtLegalDescr1':
if legdesc is None:
elm.text = "No legal description"
else:
elm.text = var
del row, rows
return
# ------------------------------------------------------------------------
# ---- MODULE: Mapsheet overlay procedure ----
def mapsheetoverlay(self, lyr):
mapsheets = '' # resetting the variable for mapsheets
map20k = self.bcgw + '\\WHSE_BASEMAPPING.BCGS_20K_GRID' # mapsheet layer from BCGW
self.delLayer("map20klyr")
arcpy.MakeFeatureLayer_management (map20k, "map20klyr")
# doing the overlay
arcpy.AddMessage('checking for 20k mapsheet overlaps')
arcpy.SelectLayerByLocation_management ("map20klyr", "INTERSECT", lyr)
# going thru the selected map20k lyr features
rows = arcpy.SearchCursor("map20klyr")
row = rows.next()
mapsheets = row.getValue("MAP_TILE_DISPLAY_NAME")
arcpy.AddMessage(mapsheets)
row = rows.next()
while row:
mapsheets = mapsheets + ", " + row.getValue("MAP_TILE_DISPLAY_NAME")
arcpy.AddMessage(mapsheets)
row = rows.next()
self.delLayer("map20klyr")
del rows, row
return mapsheets
# ------------------------------------------------------------------------
# --- MODULE: Getting Client Name from BCGW tables ---
def ClientName(self, dispID):
# the query table exists in memory
# do the query and spit out the client name
# the two tables we need to join
arcpy.AddMessage("Obtaining Client Information")
arcpy.AddMessage("Please Stand by...")
tmpDrive = "T:"
tmpFGDBname = "\\tmpfgdb_" + getpass.getuser() + ".gdb"
tmpFGDB = tmpDrive + tmpFGDBname
dimFC = tmpFGDB + "\\DimensionsFC"
if not arcpy.Exists(tmpFGDB):
arcpy.AddMessage("creating new " + tmpFGDB)
arcpy.CreateFileGDB_management(tmpDrive, tmpFGDBname)
tmplist = ["t1View", "t2View"]
for tmpX in tmplist:
self.delLayer(tmpX)
arcpy.AddMessage("Please Stand by...part 2")
t1 = self.bcgw + '\\WHSE_TANTALIS.TA_TENANTS' # gobetween table
t2 = self.bcgw + '\\WHSE_TANTALIS.TA_INTERESTED_PARTIES'
tmpT1 = tmpFGDB + "\\tmpT1"
tmpT2 = tmpFGDB + "\\tmpT2"
# fields for joining the tables
t1Field = 'DISPOSITION_TRANSACTION_SID'
joinField = 'INTERESTED_PARTY_SID'
contField = 'PRIMARY_CONTACT_YRN'
# only pulling out client identified as "Primary Contact"
# editing out and trying AddFieldDelimiters
# http://desktop.arcgis.com/en/arcmap/latest/analyze/arcpy-functions/addfielddelimiters.htm
# whereClause = t1Field + " = " + str(dispID) + " AND \"PRIMARY_CONTACT_YRN\" = \'Y\'"
wcList = [t1Field, contField]
wc1 = arcpy.AddFieldDelimiters(self.bcgw, t1Field)
wc2 = arcpy.AddFieldDelimiters(self.bcgw, contField)
whereClause = "({0} = {1}) AND ({2} = '{3}')".format(wc1, str(dispID), wc2, 'Y')
arcpy.AddMessage(whereClause)
legal = 'LEGAL_NAME' # field names in the TA_INTERESTED_PARTIES table
first = 'FIRST_NAME'
last = 'LAST_NAME'
txtClientName = 'Interest Holder: ' # resetting txtClientName
# doing a selected set to just show me the Disposition)
#arcpy.CopyRows_management(t1, tmpT1) !!! removed Sep 1
#arcpy.MakeTableView_management (tmpT1, "t1View", wc1)
where1 = "({0} = {1})".format(wc1, str(dispID))
arcpy.AddMessage('using where1 clause')
arcpy.AddMessage(where1)
# arcpy.MakeTableView_management (tmpT1, "t1View", where1) !!! changed Sep 1
arcpy.MakeTableView_management (t1, "t1View", where1)
arcpy.AddMessage("created t1View")
#arcpy.AddMessage("using " + whereClause)
#tmp2 = fieldLister("t1View")
result = int(arcpy.GetCount_management("t1View").getOutput(0))
arcpy.AddMessage("rows: " + str(result))
rows = arcpy.SearchCursor("t1View")
row = rows.next()
t1IPSID = str(row.getValue(joinField))
#arcpy.AddMessage(t1IPSID + ' is the INTERESTED_PARTY_SID')
whereClause2 = joinField + ' = ' + t1IPSID
#arcpy.CopyRows_management(t2, tmpT2) #!!! removed Sep 1
# arcpy.MakeTableView_management(tmpT2, "t2View", whereClause2) # !!! changed Sep 1
arcpy.MakeTableView_management(t2, "t2View", whereClause2)
arcpy.AddMessage("created t2View")
#arcpy.AddMessage("using " + whereClause2)
#tmp2 = fieldLister("t2View")
result = int(arcpy.GetCount_management("t2View").getOutput(0))
arcpy.AddMessage("rows: " + str(result))
rows = arcpy.SearchCursor("t2View")
row = rows.next()
lgl = str(row.getValue(legal))
fst = str(row.getValue(first))
lst = str(row.getValue(last))
arcpy.AddMessage("first try: " + lgl)
# if legal name is null, make txtClientName = first + last names
if lgl == "None":
arcpy.AddMessage('no LEGAL_NAME value')
txtClientName = txtClientName + fst + " " + lst
arcpy.AddMessage('using individual first, last name: ' + txtClientName)
else:
txtClientName = txtClientName + lgl
# cleaning up variables from memory
del row, rows, t1, t2, tmpX, lgl, fst, lst, whereClause2, whereClause
print ('cleaning up temp client tables')
self.delLayer(tmpT2)
self.delLayer(tmpT1)
return txtClientName
def MakeTheDamnPDF(self, outfile):
arcpy.RefreshActiveView()
# make PDF file here
#pdffolder = r"\\spatialfiles.bcgov\work\srm\sry\Workarea\land_officers\PMV\maps"
#pdfpath = pdffolder + "\\" + str(obj.fileNum) + ".pdf"
if os.path.exists(outfile):
os.remove(outfile)
arcpy.AddMessage("Killed old PDF file")
#Create the file
arcpy.mapping.ExportToPDF(self.mxd, outfile )
arcpy.AddMessage("created new PDF file for " + self.fileNum)
# -------------------------------------------
print ('__name__ is', __name__)
if __name__ == '__main__':
ten_stage = sys.argv[1]
file_num = sys.argv[2]
intrid_sid = sys.argv[3]
dimensions = sys.argv[4]
inset_map = sys.argv[5]
try:
# making my MXD object here, should start the __init__ sequence
obj = myMXD(ten_stage, file_num, intrid_sid, dimensions, inset_map)
if inset_map == "None":
arcpy.AddMessage("no inset map")
# just draw the main data frame
obj.dataFrameFilter(obj.mainDF, obj.mainDefQry, inset_map)
tantlyr = arcpy.mapping.ListLayers(obj.mxd, "Tantalis Files", obj.mainDF)[0]
obj.txtUpdater(tantlyr)
if dimensions == 'YES':
obj.doDimensions(obj.mainDF, tantlyr)
else:
# turn off the dimensions lyr
arcpy.AddMessage("turning off the dim lyr ")
else:
arcpy.AddMessage("inset map set to " + str(inset_map))
# do both main and inset data frames
obj.dataFrameFilter(obj.mainDF, obj.mainDefQry, inset_map)
obj.dataFrameFilter(obj.detailDF, obj.detailDefQry, inset_map)
tantlyr = arcpy.mapping.ListLayers(obj.mxd, "Tantalis Files", obj.detailDF)[0]
obj.txtUpdater(tantlyr)
if dimensions == 'YES':
obj.doDimensions(obj.detailDF, tantlyr)
# make PDF file here
#pdffolder = r"\\spatialfiles.bcgov\work\srm\sry\Workarea\land_officers\PMV\maps"
'''
pdffolder = r"W:\srm\sry\Workarea\land_officers\PMV\maps"
pdfpath = pdffolder + "\\" + str(obj.fileNum) + ".pdf"
arcpy.AddMessage("pdfpath is " + pdfpath)
obj.MakeTheDamnPDF(pdfpath)
'''
except Exception, e:
arcpy.AddMessage(str(e))
arcpy.RefreshActiveView()
arcpy.AddMessage("!!! this is the end !!!")