|
POST
|
Jeremy: Here is a bat file example that calls a python script: @echo off
set pyexePath="C:\Python26\ArcGIS10.0\python.exe"
set pylogPath="C:\GIS\ServerProcesses\Bezier_Removal\Bezier_Remover_Simplify.log"
set BezRemove_pyPath="C:\GIS\ServerProcesses\Bezier_Removal\01_Bezier_Remover.py"
echo Start time: %time% > %pylogPath%
REM Run the python script
echo ------ Update time: %time%
echo ------ Removing Bezier curves from RDCL in Transportation GDB --------
echo ------ Removing Bezier curves from RDCL in Transportation GDB -------- >> %pylogPath%
%pyexePath% %BezRemove_pyPath% >> %pylogPath%
echo End time: %time% >> %pylogPath% Here is the python script that this bat file is calling: # ---------------------------------------------------------------------------
# Bezier_Remover.py
# Created on: 2011-11-15 15:27:13.00000
# (generated by ArcGIS/ModelBuilder)
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import sys, string, os
import arcpy
import arcpy.mapping
from arcpy import env
import smtplib #E-mail library
# Set environment
arcpy.env.overwriteOutput = True
# Local variables:
RDCL_SRCH__2_ = "RDCL_SRCH"
TRANS_RDCL_SRCH = r"\\Server\GIS\Enterprise\Data\transportation\Transportation.gdb\TRANSPORTATION_RDCL_SRCH"
try:
print("Densifying TRANSPORTATION_RDCL to remove Bezier Curves")
# Process: Densify
arcpy.Densify_edit(TRANS_RDCL_SRCH, "DISTANCE", "25 Feet")
except:
print arcpy.GetMessages(2)
SUBJECT = "Road Densify Script Failed"
TO = "person@mail.org"
FROM = "Process_Server"
text = "Removal of Bezier Curves in Roads failed"
BODY = string.join((
"From: %s" % FROM,
"To: %s" % TO,
"Subject: %s" % SUBJECT ,
"",
text
), "\r\n")
server = smtplib.SMTP('mail server address',mail server port #) #server = smtplib.SMTP(HOST)
server.sendmail(FROM, [TO], BODY)
server.quit() This is a very simple script that I have had running successfully on my Windows Server 2008 server for about 2 months now. The script simply removes Bezier curves from a polyline feature class as the web application that uses this data, fails when working with Bezier curves. I hope this helps you to solve your problem
... View more
03-01-2012
07:35 AM
|
0
|
0
|
3107
|
|
POST
|
Jeremy: I am also in the process of migrating python scripts from a Windows Server 2003 server to a Windows Server 2008 server. I thought it was going to be a straight forward process, but it has been more difficult than I had expected. Do you call your python scripts from a bat file? That is how I call my python scripts. I did not need to modify the python scripts in the Windows Server 2008 server environment, but I did need to modify my bat files that called the python scripts. Some of the differences in the bat file syntax included: 1.) Need to call the python scripts using their full path - I was able to call the script in Windows Server 2003 because it recognized the relative path 2.) Need to call other dependent files (script log files) using their full path - I was able to call the script in Windows Server 2003 because it recognized the relative path 3.) In order to make the bat file code more readable, I set variables for the path to the python script and log files and used these variables to reference the files throughout the bat file (again due to the fact that relative paths to dependent files of the bat file are not recognized) Unlike yourself, my code to generate an E-mail if errors were encountered worked without modification when I moved from Windows Server 2003 server to a Windows Server 2008 server
... View more
03-01-2012
06:25 AM
|
0
|
0
|
3107
|
|
POST
|
Miroslav: I have also created a script that performs this task but I do not need to specify credentials as you say when I open the new mxd. Are you using the ReplaceDataSource method to make this server switch? Also, I have the script loop through all subfolders in a user selected folder where it targets mxd files and changes the SDE connection from one SDE server to another. The problem I have is that the memory keeps building up until the script locks up. Do you perform this script on one mxd at a time or is it a batch process? If its a batch process and you do not have a memory buildup, I would be interested in taking a look at your python code. Thanks.
... View more
02-29-2012
08:15 AM
|
0
|
0
|
550
|
|
POST
|
Felix: As a workaround you might want to write a script that just saves the file through python before running the BrokenLinks script. Maybe the Save operation flushes out old SDE connections, but the SaveACopy operation does not. Are the mxds that you are processing currently saved as v9.3 or earlier? Or have these mxds been created or saved previously in v10? I had some issues where I tried to run python scripts on v9.3 mxds where they crashed python in v10 and I was unable to open the mxd in v10. If I save the file in v9.3 or I saved the mxd back to v9.3 in python, the mxd would then open in v10. It seems that this Save operation in v9.3 was flushing out bad or corrupt objects for v10.
... View more
02-29-2012
05:03 AM
|
0
|
0
|
1996
|
|
POST
|
Felix: I had a similar problem when I performed an SDE conversion from 9.1 to 9.3 using VBA. In this case, we created another SDE database on a new server with ArcGIS v9.3. After running this conversion, some layers were still looking for the 9.1 connections which caused the mxd to hang when opening because the 9.1 database and server was now retired. I was unable to locate the old connections, so I added a dummy domain name to route the connections with the old server name to the new server name. This solved the problem, but the mxd still contains references to the old server. The only way to fix this is to recreate the entire mxd (time consuming and we have hundreds of files like this). It seems that the newly saved mxd might still have references to the old server which causes it to hang. I guess saving it again outside of python removes these references as you are then able to open the mxd in a normal amount of time. Do you have any 3rd party software that is used in this mxd? This could be a cause of your problems. Also, I would contact tech support and log an incident with them to see if the SaveACopy is supposed to flush out references to old servers. I would be interested in the results as I will need to perform this operation on thousands of mxds when my organization migrates from Oracle Client 10g to either 11 or 12 depending upon when my organization is ready for this upgrade.
... View more
02-27-2012
07:38 AM
|
0
|
0
|
1996
|
|
POST
|
I have never had to perform this operation before, but maybe you should save the layer to disk in the new projected coordinate system. Then try calculating the area on the new layer instead of the reprojected original layer.
... View more
02-27-2012
05:31 AM
|
0
|
0
|
2939
|
|
POST
|
To All Python Users: I am trying to write several python scripts that would loop through mxds in a user selected directory and either analyze the properties of the mxd or make changes to the mxd. Unfortunately, with either type of python script, the python script crashes when it gets to an mxd that is referencing a mxt that is not on the machine where the python script is running from. This is the message you get when you open the mxd in ArcMap. "Unable to find the following template used by this map document: C:\Program Files\...\layers.mxt You can still use this map document but customizations such as macros stored in that template won't be available. Would you like to browse to the template file to access those customizations? Yes No" Other than putting exceptions into the code for these mxds (there could be 100s or 1000s), I was wondering if there was a way for python to be able to bypass this message so the python script can keep running. Any help or hints regarding this topic are greatly appreciated. Thank you.
... View more
02-15-2012
09:53 AM
|
0
|
3
|
2657
|
|
POST
|
Thanks for your reply with code Ben. I believe that might work, but I think the following Post has a better solution: replaceDataSource not working in the same python forum The method that appears to work best is the UpdateLayer method. This incorporates RemoveLayer and AddLayer in the same method and the task of tracking the index of the layer is bundled up for free with this method.
... View more
02-14-2012
08:08 AM
|
0
|
0
|
1343
|
|
POST
|
Thanks Jeff. The UpdateLayer method with the False parameter for symbology appears to do exactly what I need. Preliminary testing worked perfectly and now I need to test with more complex mxds where there are multiple dataframes and layers in a Group Layer that need to be replaced.
... View more
02-14-2012
06:40 AM
|
0
|
0
|
1314
|
|
POST
|
Thank you Mathew, but this solution does not solve my problem. But you did point me to an area in the Help documentation where the InsertLayer method is found. I believe the InsertLayer method might work for me as it works with Group Layers, according to the Help documentation, and you can insert it before or after a target layer anywhere in the Group, not just at the top or bottom. In my scenario I can have a group layer with 5 layers in it and I want to replace either the 2nd, 3rd, or 4th layer.
... View more
02-14-2012
05:01 AM
|
0
|
0
|
1343
|
|
POST
|
To All ArcGIS Python Users: I would like to create a python script where I can remove a layer from an mxd and replace it with a new layer that is placed in the exact same location. It is essential that this script would be able to replace the layer in a Group Layer as this is how it exists in hundreds of mxds. I had a VBA script that performed this type of task, but it did not work with Group Layers as I was unable to get the layer index within the Group Layer. As such I had to perform the Group Layer individual layer replacement manually which was quite time consuming. Does python give you the ability to obtain the index of a specific layer within a Group Layer? Any help or hints regarding this topic are greatly appreciated. Thank you.
... View more
02-14-2012
03:55 AM
|
0
|
4
|
4890
|
|
POST
|
Jake: Besides a Mosaic Dataset, what do you think would be the best way to store raster images outside of SDE to get excellent performance in ArcMap, where I would be able to use the replaceDataSource in python to get an automated solution that can be performed during non-business hours? In response to your last post, many of the the current SDE image layers can be found in group layers and not necessarily at the bottom of the TOC, so your approach would by no means be the universal solution for my organization. In the past I had resourced these same images from IMS to SDE using a programmatic approach in VBA, but group layers also presented a problem. I had to resource these layers manually after getting an inventory of how often this occurred on my network. I was hoping the replaceDataSource in python for ArcMap v10.0 would make this task easier, but it appears that this option was not accounted for at this point in python.
... View more
02-13-2012
09:42 AM
|
0
|
0
|
1314
|
|
POST
|
Jake: Do you know if it will be a capability of python scripting in ArcGIS v10.1 to convert SDE raster images to a mosaic dataset? I would need to perform this task on 10s of thousands of layers so a manual approach is extremely impractical. Thanks.
... View more
02-13-2012
09:11 AM
|
0
|
0
|
1314
|
|
POST
|
Jake: In the original post, the posting person was trying to convert rasters from one SDE database to another. In your response, you said it would be better to use a mosaic dataset to store the raster data. As such, I would want to convert raster data from SDE to a mosaic dataset for layers that I have saved in many mxds. I thought you were indicating that this can be done, but your last post said this is not possible with replaceDataSource. Is there any other python method that could be used to make this conversion? Your feedback is greatly appreciated. Thanks.
... View more
02-13-2012
08:24 AM
|
0
|
0
|
1314
|
|
POST
|
Jake: What would be the replaceDataSource syntax if one was converting from a raster in SDE to a mosaic dataset in a file geodatabase? This is the syntax I am using, which follows the ArcGIS Help, but I am getting an error message:
elif layr.datasetName == "ORTHO2005.ORTHOS2005":
print("The dataset name in Resource_mxd is " + layr.datasetName)
layr.replaceDataSource(r"\\gis\GIS\Work\arcmap\mosaic_2010.gdb", "FILEGDB_WORKSPACE", "orthos_2010")
In this code, "orthos_2010" is the mosaic dataset that contains 2010 Orthophotos. I am not specifying where the data originates in SDE, other than making sure that the focus layer to be converted has a datasetName = ORTHO2005.ORTHOS2005, as I did not need to do this for vector datasets that I resourced from SDE to a file geodatabase. Your assistance is greatly appreciated. Thanks.
... View more
02-13-2012
07:37 AM
|
0
|
0
|
2762
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 02-11-2026 10:42 AM | |
| 1 | 12-22-2025 10:08 AM | |
| 1 | 09-26-2025 06:10 AM | |
| 1 | 09-04-2025 02:19 PM | |
| 1 | 08-29-2025 08:29 AM |
| Online Status |
Online
|
| Date Last Visited |
an hour ago
|