|
POST
|
Looks Like I will learn how to create representations, and try the Disperse Markers which I have come across in my researching this subject. Thanks for the advice.
... View more
07-14-2016
12:48 PM
|
0
|
0
|
5516
|
|
POST
|
I have the following and needed help on getting this to work. I am unsure about the xml modification of sddraft syntax and order within the script. Any suggestions would be appreciated. # ArcPy script to overwrite a published map document as a service via Server. import arcpy,sys print("Imported ArcPy") import xml.dom.minidom as DOM # Set variables mxd = r'sample.mxd' server_con = 'ARCGIS_SERVER' connection_file_path = r"GIS Servers\ARCGIS on xyz (publisher)" service_name = "themap" inFolderType = "EXISTING" inFolder = "Test" inStartup = "STARTED" newType = 'esriServiceDefinitionType_Replacement' # Set output path sddraft = r'C:\Users\dunderwood\AppData\Local\ESRI\Desktop10.2\Staging\ARCGIS on GIS on xyz (publisher)\mapservice.sddraft' sd_file = r'C:\Users\dunderwood\AppData\Local\ESRI\Desktop10.2\Staging\ARCGIS on GIS on xyz(publisher)\mapservice.sd' # Method to create a SD file to overwrite an existing service xml = sddraft doc = DOM.parse(xml) descriptions = doc.getElementsByTagName('Type') for desc in descriptions: if desc.parentNode.tagName == 'SVCManifest': if desc.hasChildNodes(): desc.firstChild.data = 'esriServiceDefinitionType_Replacement' outXml = xml f = open(outXml, 'w') doc.writexml(f) f.close() # 1 Create a service definition draft analysis_result = arcpy.mapping.CreateMapSDDraft(mxd, sddraft) print("SDdraft file created") # 2 Stage and create Service Definition file arcpy.StageService_server(sddraft, sd_file) print("Service Definition file created") # 3 Publish the SD file as a service arcpy.UploadServiceDefinition_server(sd_file, connection_file_path, service_name,"#",inFolderType,inFolder,inStartup) print("Service published successfully")
... View more
07-14-2016
12:44 PM
|
0
|
3
|
2979
|
|
POST
|
I know that symbology has limited functionality in placing symbols. Maplex can be used to create as text symbols, which I did. I also tried using leader lines which I don’t like. My question is, do you have any recommendations on how to address overlapping features symbology? Is creating feature representations a viable option? Thank you.
... View more
07-14-2016
11:41 AM
|
0
|
7
|
7806
|
|
POST
|
I have the following and trying to write to file when using tool getparameterastext. Its not writing though? #Import Modules
import csv,os,arcpy
#Set path location of Excel (CSV) file
path = r'C:\Users\dunderwood\Documents\PyScriptTools\Tools\ToolData'
arcpy.env.workspace = path
#Set variables
ifile = open('PublishedMapsInfo.csv','r')
ofile = open('Results.csv','w')
reader = csv.reader(ifile)
writer = csv.writer(ofile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
featureclass = arcpy.GetParameterAsText(0)
#CSV Module terminology row is horizontal & field is vertical;column is horizontal & row is vertical for excel
for row in reader:
for field in row:
if field == featureclass:
final = (row[4] + " " + featureclass)
writer.writerow([final])
#arcpy.AddMessage('All Mxds associated with fc = {}'.format(viewmessage))
#Close Excel (CSV) file
ifile.close()
ofile.close()
... View more
06-16-2016
04:11 PM
|
0
|
1
|
711
|
|
POST
|
Interesting, I added what you suggested and get All Mxds associated with fc = view results not defined, this means it is not recognizing the loop statements. This works fine as a stand alone, so I know the loop syntax works fine. However, the AddMessage is the issue with a loop statement.
... View more
06-15-2016
10:46 AM
|
0
|
0
|
711
|
|
POST
|
Yes it is on a loop. for row in reader:
for field in row:
if field == featureclass:
viewresults = (row[4] + " " + featureclass)
... View more
06-15-2016
10:34 AM
|
0
|
1
|
1691
|
|
POST
|
I removed the print statement. I receive an error as follows. Traceback (most recent call last): File "...\ReadMxdFCCSV.py", line 34, in <module> arcpy.AddMessage('All Mxds associated with fc = {}'.format(viewresults)) NameError: name 'viewresults' is not defined Failed to execute (readmxdFC). Despite previously setting viewresults as a variable Any Idea why I am having this error ?
... View more
06-15-2016
07:07 AM
|
0
|
3
|
1691
|
|
POST
|
I am getting a returned value of None with the following excerpt of my code. print viewresults + str(arcpy.AddMessage('All Mxds associated with fc = {}'.format(viewresults))) What does None refer to ?
... View more
06-14-2016
03:46 PM
|
0
|
5
|
1691
|
|
POST
|
Apparently you can't see AddMessage in python shell. I commented out the AddMessage function. I used just arcpy.AddMessage which does work when testing with featureclass. I need to get it to work with final which I think it is having trouble being a looped result. The code below produced the following in below results window. # Import Modules
import csv,os,arcpy
#Set variables
ifile = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
#featureclass = input("Name of the feature class ? ")
featureclass = arcpy.GetParameterAsText(0)
#Set path location of Excel (CSV) file
path = r'C:\Users\dunderwood\Documents\My Python Scripts\WriteMxdInfoToExcel'
arcpy.env.workspace = path
#Create Function
#def myMsgs(message):
# arcpy.AddMessage(message)
# print(message)
#CSV Module terminology row is horizontal & field is vertical;column is horizontal & row is vertical for excel
for row in reader:
for field in row:
if field == featureclass:
final = row[4] + " " + featureclass
#print(final)
#myMsgs(message)
arcpy.AddMessage('All Mxds associated with fc = {}'.format(featureclass))
#Close Excel (CSV) file
ifile.close()
... View more
06-10-2016
10:53 AM
|
0
|
0
|
1691
|
|
POST
|
Great advice, I just recently came across that article. I do see the results window, but it doesn't display the actual information I want. I want to see the information that I can see when I run the script as a stand alone. The python shell results is what I want to see in the above window for the tool. Maybe the Add Message was never correctly displaying, does it differ from a print when viewing in the python shell ?
... View more
06-10-2016
07:27 AM
|
0
|
1
|
1691
|
|
POST
|
Make sense, I will make note of creating better naming conventions. Interesting how when I run it as a tool the results yield successful but the add message doesn't appear. Maybe my tool parameters are set incorrectly. The tool works fine as I use a dropdown to navigate to location of featureclass. This is straight forward. The output I am not entirely sure about.
... View more
06-09-2016
03:59 PM
|
0
|
5
|
2032
|
|
POST
|
I believe this reflects your comments. #Import Modules
import csv,os,arcpy
#Set variables
ifile = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)
#Set path location of Excel (CSV) file
path = r'C:\Users\dunderwood\Documents\My Python Scripts\WriteMxdInfoToExcel'
arcpy.env.workspace = path
#Create Function
def myMsgs(message):
arcpy.AddMessage(message)
print(message)
#CSV Module terminology row is horizontal & field is vertical;column is horizontal & row is vertical for excel
for row in reader:
for field in row:
if field == featureclass:
final = row[4] + " " + featureclass
#print(final)
message = final
myMsgs(message)
#Close Excel (CSV) file
ifile.close()
... View more
06-09-2016
02:47 PM
|
0
|
7
|
2032
|
|
POST
|
Thank you for taking the time to further explain. Will this work in a script that I am using with a tool I created? To automatically display message to results? I tested out the function but it is not automatic when run and seen in python shell. However, as mentioned, my actual goal is to use it as a tool. I will take a look at the Blog, thanks.
... View more
06-09-2016
02:46 PM
|
0
|
0
|
2032
|
|
POST
|
Good points, I have used py 3 several times and had issues not being able to print until I learned about needing parenthesis. So good practice to use them in py 2 as well since it will work. I would only use the r' raw for paths that were not for my pc, but I will include it every time now. I made the other suggested changes and trying to grasp what Rebecca and Dan said to arrive at the edited code which states message has not been defined after running the script. #Import Modules
import csv,os,arcpy
#Set variables
ifile = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)
#Set path location of Excel (CSV) file
path = r'C:\UsersWriteMxdInfoToExcel'
arcpy.env.workspace = path
#Create Function
def myMsgs(message):
arcpy.AddMessage(msessage)
print (message)
#CSV Module terminology row is horizontal & field is vertical;column is horizontal & row is vertical for excel
for row in reader:
for field in row:
if field == featureclass:
final = row[4] + " " + featureclass
print (final)
myMsgs(message)
#Close Excel (CSV) file
ifile.close()
... View more
06-09-2016
11:22 AM
|
0
|
0
|
2032
|
|
POST
|
I am trying to have Add message for the variable, but I am having trouble calling the function with the variable. #Import Modules
import csv,os,arcpy,time
#Set variables
ifile = open('PythonShellSave.csv','r')
reader = csv.reader(ifile)
featureclass = input("Name of the feature class ? ")
#featureclass = arcpy.GetParameterAsText(0)
#Set path location of Excel (CSV) file
path = 'C:\Users\WriteMxdInfoToExcel'
os.chdir(path)
# Create function
def myMsgs(message):
arcpy.AddMessage(message)
#CSV Module terminology row is horizontal & field is vertical;column is horizontal & row is vertical for excel
for row in reader:
for field in row:
if field == featureclass:
final = row[4] + " " + featureclass
print final
myMsgs (final)
#Close Excel (CSV) file
ifile.close()
... View more
06-09-2016
10:45 AM
|
0
|
3
|
3035
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-03-2016 06:52 AM | |
| 1 | 05-10-2016 10:27 AM | |
| 1 | 02-06-2017 01:22 PM | |
| 1 | 05-01-2018 07:23 AM | |
| 1 | 03-03-2017 02:46 PM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:24 AM
|