|
POST
|
Hi Rebecca, 1. I added in mxd.save, makes no difference to the error. 2. The pipe, I believe indicates that 'data' is a feature dataset in the file geodatabase. I have used it successfully in other scripts, but not sure if it works for this instance? Hopefully this helps provide a bit more info. thanks
... View more
11-28-2016
09:41 PM
|
0
|
0
|
2078
|
|
POST
|
Good day everyone, I am playing around with the following code to fix broken data sources for file gedatabases. There's something I am getting wrong in it and I am getting the following error messages displayed. If anyone can point out what I'm doing wrong I would greatly appreciate it. Thanks very much, Chris import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == 'roads':
lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','roads')
elif lyr.name == 'railways':
lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','railways')
elif lyr.name == 'rivers':
lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','rivers')
elif lyr.name == 'lakes':
lyr.replaceDataSource('X:/GIS/geo_databases/labelling_features.gdb|data','FILEGDB_WORKSPACE','lakes')
elif lyr.name == 'bridge_polygons':
lyr.replaceDataSource('X:/GIS/geo_databases/planning_data.gdb|data','FILEGDB_WORKSPACE','bridge_polygons')
del mxd
Result = True
arcpy.SetParameterAsText(0,Result)
... View more
11-28-2016
11:05 AM
|
0
|
5
|
3392
|
|
POST
|
Thought I'd provide a quick update. I've moved this functionality over to the following python script. Works well. import os
import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
locPath = str(os.path.basename(mxd.filePath))
LOC = locPath[0:12]
returnLOC = LOC.upper()
arcpy.SetParameterAsText(0, returnLOC)
... View more
11-24-2016
08:39 AM
|
2
|
0
|
4190
|
|
POST
|
Quick update. I changed over to the following python script: import arcpy
locno = arcpy.GetParameterAsText(0)
year = locno[3:7]
workspace = "O:/plan/luam/1p2007/" + year + "/" + locno + "/data_for_item.gdb"
arcpy.env.workspace = workspace
inFc = 'in_memory\AddressSelect'
numRecords = int(arcpy.GetCount_management(inFc).getOutput(0))
if numRecords == 0:
arcpy.AddError('Incorrect address. Please try again.')
result = False
else:
result = True
arcpy.SetParameterAsText(1, result) I tried it both using AddWarning and AddError. AddWarning gives the following to the output then continues to run through all tools/scripts providing either the message 'precondition is false' or 'inputs are not current': AddError provides the following, and seems to be a bit 'cleaner' and I think easier for the end user to know that something is not right: Something I find interesting is the script with AddWarning does display as Completed at the top left of the form while the AddError script shows Executing Test For Records... is that because in the case of AddWarning, the model did complete and with AddError it did not?
... View more
11-23-2016
08:05 AM
|
1
|
0
|
4069
|
|
POST
|
Super. Thanks for your time Curtis. Sent from my iPhone
... View more
11-22-2016
07:42 PM
|
0
|
0
|
4069
|
|
POST
|
Upon further investigation, it looks like maybe it is working. When Row Count = 0 it continues going through all tools/scripts it just doesn't execute them, due to either "precondition is false" or "inputs are not current". The following is what is displayed. Now that I think it's working, would there be a way to add in a arcpy.AddWarning("Incorrect address, try again") in addition to or in lieu of all of the precondition is false... inputs are not current... Thanks! Executing: FinalModel22 "7 windermure rd sw" M-4 Start Time: Tue Nov 22 13:01:22 2016 Executing (GetLocNo): GetLocNo Start Time: Tue Nov 22 13:01:23 2016 Running script GetLocNo... Completed script GetLocNo... Succeeded at Tue Nov 22 13:01:25 2016 (Elapsed Time: 2.50 seconds) Executing (Select): Select "Construction Layers\CALGIS.ADDRESS_POSSE" in_memory\AddressSelect "ADDRESS =UPPER('7 windermure rd sw')" Start Time: Tue Nov 22 13:01:25 2016 WARNING 000117: Warning empty output generated. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.73 seconds) Executing (Get Count): GetCount in_memory\AddressSelect Start Time: Tue Nov 22 13:01:26 2016 Row Count = 0 Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Select Layer By Location): SelectLayerByLocation "Construction Layers\OPF - Ownership Parcel Fabric\CALGIS.OPF_PARCEL" INTERSECT in_memory\AddressSelect # NEW_SELECTION Start Time: Tue Nov 22 13:01:26 2016 The process did not execute because the precondition is false. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Zoom To Selected Feature): ZoomToSelected Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Append): Append 'Construction Layers\OPF - Ownership Parcel Fabric\CALGIS.OPF_PARCEL' site_polygon NO_TEST # # Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Append (2)): Append 'Construction Layers\OPF - Ownership Parcel Fabric\CALGIS.OPF_PARCEL' "PROPOSED - proposed_LUD_polygon - OUTLINE" NO_TEST # # Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Update Proposed Lud Polygon Info): UpdateProposedLudPolygonInfo LOC2017-0016 M-4 Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Update Site Polygon Info): UpdateSitePolygonInfo LOC2017-0016 Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Set Scale): SetScale400 Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Executing (Create Site Location): CreateSiteLocation # Start Time: Tue Nov 22 13:01:26 2016 All the inputs are not current. Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 0.00 seconds) Succeeded at Tue Nov 22 13:01:26 2016 (Elapsed Time: 3.44 seconds)
... View more
11-22-2016
12:14 PM
|
0
|
3
|
4069
|
|
POST
|
Good day everyone, I think I'm having some trouble understanding how to make use of Get Count. I have the following: What I want to see happen is if Row Count = 0 > End the model. If Row Count > 0 continue the model. What I see is when Row Count > 0 the model continues and when Row Count = 0 it just seems to spin it's wheels for a bit (30 seconds) then end. I don't know if maybe it has something to do with Select Layer By Location using AddressSelect as it's Selecting Features? Or maybe I'm just using Get Count completely wrong and there's a different way I should be approaching this. Thanks for the help, Chris
... View more
11-22-2016
08:07 AM
|
0
|
5
|
4757
|
|
POST
|
Perfect Curtis! Thanks, exactly what I was looking for. Chris
... View more
11-18-2016
10:35 AM
|
0
|
0
|
2376
|
|
POST
|
Cheers. Thanks Curtis, I'll check this out in the morning! Sent from my iPhone
... View more
11-17-2016
11:14 PM
|
0
|
0
|
2376
|
|
POST
|
Good day everyone, I have a model which has 2 string variable model parameters (LocAddress and LuCode). LocAddress is always going to be a different value but LuCode is always going to be one of a list of 8 options. I am having difficulty figuring out how I can put together a drop down list for the user to select from rather than have them type in the value. Here is how the form currently looks: Appreciate any help. Thanks!
... View more
11-17-2016
08:36 AM
|
0
|
3
|
3278
|
|
POST
|
Thanks Joshua, I'll look into absolute pathing. Chris Sent from my iPhone
... View more
10-18-2016
07:11 AM
|
0
|
0
|
1025
|
|
POST
|
Hello everyone, I have a parameter named LocNo. It is used as a parameter in a model or two. Currently I have the user manually enter the LocNo value when the model starts. LocNo also happens to be the first 12 characters in the name of the mxd file. Is there a way that I can grab the first 12 characters and use them as the value passed into the parameter? For example here is a part of the model that shows how the LocNo is used: If I can grab those first 12 characters from the filename and insert that into the parameter in the model I'm sure it would save on having some human error introduced. Thanks for the help, Chris
... View more
10-18-2016
06:52 AM
|
0
|
3
|
5722
|
|
POST
|
Good day everyone, I have a python script that: creates a new folder using user input for part of the folder name copies 6 files plus one file geodatabase into the folder then opens up one of the mxd files The following layers in the source file geodatabase have the following database locations: layer: transnet_centerline_for_labeling: layer: bridge_polygons: In the python script I use copytree to copy the file geodatabase to the destination location: Somehow the database location for these 2 layers is being changed in the file geodatabase when it is in the new location. For example: layer: transnet_centerline_for_labeling: layer: bridge_polygons: Of course H:\geo_databases does not exist, so the layers display with red exclamation marks: Does anybody have any idea why this path may be changing to a folder that doesn't exist. Is there something in how the database source path is defined that the layer is looking to what ever drive it happens to be mapped to? Although it's not just a difference of the drive letter, the change is from X:\GIS\geo_databases to H:\geo_databases. Thanks for the help, Chris
... View more
10-18-2016
06:38 AM
|
0
|
2
|
1263
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-10-2020 03:34 PM | |
| 1 | 02-23-2021 11:53 AM | |
| 1 | 02-16-2021 09:15 AM | |
| 1 | 12-10-2020 07:46 AM | |
| 1 | 01-18-2019 09:54 AM |
| Online Status |
Offline
|
| Date Last Visited |
04-22-2021
04:31 PM
|