|
POST
|
I had this issue and went the following route: If the field that is the ID is a number field, create a view for creating the next ID in sequence in SQL Server such as: SELECT MAX(FieldName) + 1 AS NEXT_ID
FROM owner.TABLENAME Then, in Model Builder, I created a model to assign the ID. Get Field Value: Using your view that you created: Field is NEXT_ID, Data Type is Long Make a Feature Layer of the feature class you are trying to update, then Select By Attribute as "FieldName IS NULL", then calculate "FieldName" with the "Value" from the next available ID Calculate Field (Python 9.3): Expression:
autoIncrement()
Code Block:
rec=0
def autoIncrement():
global rec
pStart = %Value%
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec += pInterval
return rec From here, you can import the Model Builder model into a Python script as: arcpy.ImportToolbox("C:\Path\To\Your\Toolbox\AutoID.tbx","test")
arcpy.ModelName_test() Make sure you add _test() to the end of your model name and "test" at the end of your toolbox.
... View more
02-04-2019
04:21 PM
|
0
|
2
|
11377
|
|
POST
|
Thank you, that one worked after removing the double 'arcpy'.
... View more
02-04-2019
07:07 AM
|
0
|
0
|
336
|
|
POST
|
I updated line 6 and 7 with your code but seems to still report an error: Traceback (most recent call last): File "C:\path\to\python\file.py", line 8, in <module> arcpy.arcpy.CreateDatabaseView_management(fc, os.path.join("Database Connections\\Server DB sde.sde",'v_{}'.format(fc), 'select * from {}'.format(fc))) File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\management.py", line 4069, in CreateDatabaseView raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000837: The workspace is not the correct workspace type. ERROR 000735: View Definition: Value is required Failed to execute (CreateDatabaseView). import arcpy
import os
arcpy.env.workspace = "Database Connections\\Server DB sde.sde"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.arcpy.CreateDatabaseView_management(fc, os.path.join("Database Connections\\Server DB sde.sde",'v_{}'.format(fc), 'select * from {}'.format(fc)))
... View more
01-31-2019
04:02 PM
|
0
|
1
|
3206
|
|
POST
|
I have created an SDE database in which I have copied feature classes from my production database from State Plane into WGS 84 for web mapping applications. The final step is to create views, and I am trying to automate the process as I have hundreds of feature classes. Below, I am trying to make a list of all the feature classes and use the name of the feature class. The middle parameter starts with a prefix of v_ then grabs the feature class name (ie: v_watermeters). The third variable is the SQL statement used to create the view definition, where it grabs all the fields (SELECT * FROM ) then I want to use the feature class name (ie: SELECT * FROM watermeters). I am having trouble with the third variable and concatenating the string values to make valid code. We are currently on ArcGIS 10.3.1 and SQL Server 2012. import arcpy
import os
arcpy.env.workspace = "Database Connections\\Server Database sde.sde"
featureclasses = arcpy.ListFeatureClasses()
for fc in featureclasses:
arcpy.arcpy.CreateDatabaseView_management(
fc, os.path.join("Database Connections\\Server Database sde.sde","v_"+str(featureclasses), "select * from "+featureclasses)
... View more
01-31-2019
03:03 PM
|
0
|
10
|
3831
|
|
POST
|
I had a similar issue, and I could not assign privileges with a blank feature dataset. Once I added a dummy feature class within the feature dataset, I was able to assign privileges then I removed the dummy feature class and added the real ones.
... View more
01-16-2019
10:26 AM
|
3
|
0
|
1525
|
|
POST
|
I have a folder of PDFs that are a 1:1 relationship with an MXD. Each plan is a floor of a building. In the screenshot below, WHBFD325 is only one floor, so no modifications need to be done to that. In the 4 files for WHBFD364, I would like to merge the 4 PDFs into one PDF with _1 being the first page, _4 being the last page. The merged file name would be WHBFD364. After the merge is complete, I would like the 4 files that end with _1, _2, _3, _4 to be deleted. I am not sure where to start, but any advice or links would really help me out. I am looking at the PDFDoc ArpPy commands, but nothing looks promising so far. PDFDocument—Help | ArcGIS for Desktop
... View more
12-27-2018
10:57 AM
|
0
|
1
|
1334
|
|
POST
|
Thank you Shana, I had to add a suffix directional field to the alternate name table so all 4 fields are mapped to each other (Prefix Direction, Name, Suffix Type, Suffix Direction). The Suffix Direction FIeld in both the streets table and alternate name table is NULL for the most part, but that still threw it off originally.
... View more
12-13-2018
03:49 PM
|
0
|
1
|
1047
|
|
POST
|
I have a table of alternate names with a common LOCALID field for a list of centerlines. An example is the LOCALID in the main centerline feature class is 244074. The current name in the centerline file is: Prefix: SE RoadName: CENTURY RoadType: BLVD The alias table has a record with the same LOCALID of 244074 with: Prefix: SW RoadName: 234TH RoadType: AVE The features join successfully: When I set up the Dual Range Addresses style locator, I follow the tutorial data and make sure match with no zones and match without house number are set to yes. The rest of my setup looks like: However, none of the alternate (alias) names are being recognized. Any suggestions or something I am missing?
... View more
12-10-2018
04:15 PM
|
0
|
3
|
1240
|
|
POST
|
Thank you, This seems to happen in other areas as well such as exporting TPKs via ArcPy and using Data Reviewer ArcPy functions.
... View more
11-26-2018
01:19 PM
|
0
|
0
|
1581
|
|
POST
|
Thank you, Randy. The 'domain.name' expression was the key.
... View more
10-25-2018
11:05 AM
|
0
|
0
|
2091
|
|
POST
|
Thank you, Joe, It is a start, but seem to be missing the value for the SortCodedValueDomain_management command. import arcpy
domains = arcpy.da.ListDomains("Database Connections\\Server DB Owner.sde")
for domain in domains:
print('Domain name: {0}'.format(domain.name))
if domain.domainType == 'CodedValue':
coded_values = domain.codedValues
for val, desc in coded_values.items():
arcpy.SortCodedValueDomain_management("Database Connections\\Server DB Owner.sde", Which Value?, "CODE", "ASCENDING")
print('{0} : {1}'.format(val, desc))
elif domain.domainType == 'Range':
print('Min: {0}'.format(domain.range[0]))
print('Max: {0}'.format(domain.range[1]))
... View more
10-25-2018
08:19 AM
|
0
|
4
|
2091
|
|
POST
|
Looking for a way in model builder or python to iterate through all domains in a GDB and Sort Coded Value on ASC order.
... View more
10-25-2018
07:40 AM
|
0
|
6
|
2252
|
|
POST
|
Any ideas on how to list unused domain values from within a coded domain? An example is we had PKWY EAST in a domain for street suffixes. I would like to generate a list of domain values that are not being used in a feature class.
... View more
08-23-2018
08:40 AM
|
0
|
6
|
2017
|
|
POST
|
Currently, we have our water system mains in a geometric network but they are not split at valves. I would like to batch split the water main complex edges at the valves while maintaining the attributes. I looked at the split line at points tool, but it wants a separate output. I am trying to do this operation from within an edit session to maintain current attributes. After the split, my plan is to assign a unique ID. I am looking at within an edit session or a Python script to accomplish this. Below is an image of our current geometry.
... View more
08-15-2018
10:58 AM
|
0
|
6
|
2752
|
|
POST
|
I had the same issue, and I found that having the background geoprocessing 64-bit patch installed is not compatible with Data Reviewer Arcpy functions. My solution was to run Python routines with DR Arcpy functions from a machine that has 32-bit Python installed, not 64 bit. Background Geoprocessing (64-bit)—Help | ArcGIS Desktop
... View more
08-13-2018
04:11 PM
|
0
|
0
|
1111
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | yesterday | |
| 1 | a month ago | |
| 1 | Monday | |
| 1 | a week ago | |
| 1 | a week ago |
| Online Status |
Online
|
| Date Last Visited |
13 hours ago
|