IDEA
|
Just to be sure - if this SDE it it is a SCHEMA change so you have other problems. Changing a SCHEMA impacts everyone. So... this works well in a geodatabase but not sure in a workflow how it would work for you.
... View more
09-28-2022
09:15 AM
|
0
|
0
|
1046
|
IDEA
|
I agree - I had to create the following script to do that (currently does off but code for turning back on is also present. #0-EnableDisableAttributeRules.py
#
# Rules set to "Off" will enable attribute rules.
#
# Inputs: All feature classes in Geodatabase (rules off)
# Geodatabase path built from a couple different variables
# leftovers from ArcMap/ArcInfo days
#
# Outputs: All feature class in Geodatabase with attribute rules either turned on or off
#
# Dean - 11/2020
import os,arcpy,time,datetime,traceback,shutil
def DisableRules(FC,ruletypes):
desc = arcpy.Describe(fc).attributeRules
for rule in desc:
for rtype in ruletypes:
rtypeesri = "esriART" + rtype
print (rtypeesri)
if rule.isEnabled == True and rule.type == rtypeesri:
print("Disabling " + rtype + " rule: {}".format(rule.name))
arcpy.DisableAttributeRules_management(fc, rule.name)
def EnableRules(FC,ruletypes):
desc = arcpy.Describe(fc).attributeRules
for rule in desc:
for rtype in ruletypes:
rtypeesri = "esriART" + rtype
#print (rtypeesri)
if rule.isEnabled == False and rule.type == rtypeesri:
print("Enabling " + rtype + " rule: {}".format(rule.name))
arcpy.EnableAttributeRules_management(fc, rule.name)
#######################################
try:
logfile = "D:\\GISLogs\\DisableAttributeRulesAllOff.txt"
arcpy.Delete_management (logfile)
logfile = open(logfile, "w")
starttime = datetime.datetime.now()
logfile.write ('\n' + '\n' + "StartTime:" + str(starttime) + '\n' + '\n')
print ("StartTime:" + str(starttime))
Rules = "Off"
Tile = 'T7-4'
print (Tile)
Library = 'P:\\ORMAProFabric\\TaxmapPolkV302\\'
OutDb = Library + Tile + "\\Fabric\\TownEd.gdb"
FabricPath = OutDb
arcpy.env.workspace = FabricPath
datasets = arcpy.ListDatasets(feature_type='feature')
datasets = [''] + datasets if datasets is not None else []
ruletypes = ["Constraint","Calculation","Validation"]
#ruletypes = ["Calculation"]
for ds in datasets:
for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
print (fc)
path = os.path.join(arcpy.env.workspace, ds, fc)
if Rules == "On":
EnableRules(fc,ruletypes)
else:
DisableRules(fc,ruletypes)
except:
badness = traceback.format_exc()
print ('\n' + '\n' + "*** BADNESS ****" + '\n' + '\n')
print (badness)
logfile.write ('\n' + '\n' + "**** BADNESS *****" + '\n' + '\n')
logfile.write (badness)
logfile.close()
... View more
09-28-2022
07:32 AM
|
0
|
0
|
1063
|
POST
|
Ken Using the changeversion tool as a script does not seem to work in 2.94. I finally broke it down into a small python script for a single feature class. It works within a python window so I assume it work also work in notbook. It does not work as a script a call from the tool. The tool (within toolbox) just runs the external script with no arguments as follows: Summary of error: In the following I have a map named "t104_4_test1" it currently references "Default" . I want to change ALL layers from default to a new version "andersd.t104_4_test1" I just created (The create version works great and my process to create a new map with the version name also works). Also - my layer 'Anno0400Scale' visibility is turned off. Here is the code... ------------------------------ import arcpy, datetime, sys Map = "t104_4_test1" Version = "andersd.t104_4_test1" thisProject = arcpy.mp.ArcGISProject("CURRENT") map = thisProject.listMaps("LocatorMap")[0] LayerToChange = map.listLayers('Anno0400Scale')[0] arcpy.management.ChangeVersion(LayerToChange, 'BRANCH', Version,"","") LayerToChange.visible = True ------------------------------------------ When I run this code in ArcPro in a PYTHON window it works fine. When I run this code in a script the visibility of my layer changes so I know the layer and map are being referenced correctly but the layer version is NOT changed. I am hopeful that this will work in a 3.0 environment but we are still setting that up as a test environment.
... View more
09-23-2022
11:46 AM
|
0
|
0
|
580
|
POST
|
Here are a bunch of examples of how to play with python strings (slice, modify, etc). https://www.w3schools.com/python/python_strings.asp
... View more
09-21-2022
02:24 PM
|
1
|
0
|
345
|
POST
|
Used to drive python scripts from tkinter in ArcMap (for years - was stable). Did a quick test and it still works in Arcpro. Made the following "VERY SIMPLE Hack" of a tikinter form in python to demonstrate. Root (form) calls a function "runit" that counts the number of records for a layer in geodb. This shows a simple way to drive ArcPy stuff from python. Also nice goes pandas runs well outside of ArcGIS as well. Here is code. What it looks like is below (also an attachment as textfile). Again this was quick and dirty but shows how it works. # TestTkInter.py # # Demo to show how to drive ArcPy from tkinter form. # Set Geodatabase in variable # Prompt user to enter layer name with form and use mssagebox to display number records # User can continue to enter layers names etc... until they press Quit butt # # THIS IS A TEST and it does not check if layer exists in database! # # GeoDb = Geodatabase # Layer = Layer you want to count records for # # import os,sys,shutil,tkinter as tk,arcpy,pandas as pd,datetime,traceback from tkinter import * from tkinter import ttk from tkinter import messagebox def runit(): print ("runit") LayerRunIt = Layer.get() print ("GeoDB:" + GeoDb) print ("Layer:" + LayerRunIt) LayeraPath = GeoDb + "\\" + LayerRunIt arcpy.MakeFeatureLayer_management(LayeraPath, "LayerLyr") numRecords = int(arcpy.GetCount_management("LayerLyr").getOutput(0)) print ("Records: " + str(numRecords)) messagebox.showinfo(LayerRunIt,"Records: " + str(numRecords)) arcpy.management.Delete("LayerLyr") # main root = tk.Tk() root.title ("Test") #GeoDb = StringVar() Layer = StringVar() GeoDb = "C:\\ORMAP3.0\\T7-4\\Fabric\\TownEd.gdb" #frm = ttk.Frame(root, padding=10) #frm.grid() tk.Label(root, text="Test").grid(column=0, row=0) tk.Label(root, text="GeoDb").grid(column=0, row=1,sticky=E) tk.Label(root, text="Layer").grid(column=0, row=2,sticky=E) tk.Label(root,text=GeoDb,width=40).grid(row=1,column=1,sticky=W) tk.Entry(root,textvariable=Layer,width=20).grid(row=2,column=1,sticky=W) tk.Button(root,text="Quit", command=root.destroy).grid(column=0, row=4) tk.Button(root,text="RunIt",command=lambda: runit(),font = "Verdana 10 bold").grid(column=1,row=4) root.mainloop() Form looks like this: tkinter messagebox returns this...
... View more
09-14-2022
08:54 AM
|
1
|
0
|
742
|
IDEA
|
You are correct. But it means I have to select each layer to the new version (selecting each one at time). If I mess up and miss one then I end up with to versions in the same session (always confusing). I have tested a work around where I programmatically go through ALL layers in the active map and convert them. However, I am not sure how this impacts other maps and layouts in the project. It would just be so much easier if the tool operated the same way the interactive "change version" did.
... View more
09-14-2022
05:36 AM
|
0
|
0
|
681
|
IDEA
|
The "Change Version" tool currently allows you to change a version for a single layer. Normally when we want to change a version we do so for ALL layers in the active maps versioned datasource. The "change version" method on the Version ribbon lets us do this interactively. I was quite happy to find the "Change Version" tool but when I started to use it, found that it only worked for a single layer or the fabric. Unfortunately, having multiple layers with different versions can cause problems. Also looping through ALL the layers in the active map can also be problematic. I would like this tool to function the same way the ChangeVersion method works on the Versioning ribbon.
... View more
09-09-2022
04:30 PM
|
3
|
4
|
776
|
IDEA
|
Current Situation: We have interactive access to the parcel fabric record and methods and also now have access using the ArcGIS API and SDK. Need: We do not have "programmatic" access to these methods in an ArcPro project environment. At a minimum it would great to have the ability to access the parcel fabric manager and select (or set?) the active record. This could be implemented using a "Tool" which could then be accessible to both the Python and Model Builder environments. As an added bonus having tools to create, delete, and copy the record (again accessible to Python and Model Builder) would also be very helpful. These tools would impact not just the record but all the features linked to that record. Why: The tools to interactively access and manipulate the fabric work nicely. I have spent the last few months exploring how to use tasks to integrate these interactive tools into our workflow and found it to be just too limiting. Tasks are great for small directed work flows. They are just not up to the heavy lift required to support our quite varied work flow because our workflows have too many process exceptions given the transaction, type of document, the location, etc. We have found that a "collection" of scripts and small directed tasks gives us the best productivity. Unfortunately, we really need access to tools to manage the parcel fabric record to work. I have been VERY EXCITED about the ArcGIS API and am using it, but it does NOT seem to be fully integrated into our ArcPro session and ESRI staff have recommended I start meeting my needs using SDK which I am hesitant to do. I would rather have the methods exposed as tools in an ArcPro environment making them both accessible to Python and Model Builder.
... View more
09-09-2022
04:17 PM
|
0
|
4
|
764
|
POST
|
Not sure if these are addressed but having the ability to: 1. Use Python to select and set the active record (rather then relying a task or sdk) 2. Use Python to change a version (without selecting a layer). Would be great! Currently we are planning on having a close relationship between a version and a record. Every record should have a version. (but a version could contain none, one or more then one fabric record - especially if you have to remap an area). So I have a tool that prompts for fabric record and version info (see attached python script). However, I am doing something wrong, in that even though I delete the version if it exists the script bombs when creating the record second time and gives me an error. This is not a big deal as I intend to have the tool stop if the version already exists. But did run into this when testing. See attached python script (shared as a txt file).
... View more
09-08-2022
02:05 PM
|
0
|
3
|
607
|
POST
|
Ken I think I have figured it out. IN our example for Part 2 - Branched Versioning for Parcel Fabric when you reference the Service_urls it appears that you may be missing a "/". The example is as follows: I got it to work by changing the service_urls to be the following: service_urls = {url: base_server_url + "/" + url for url in service_endpoints} I no longer get the permissions error I was getting and will continue to proceed.
... View more
09-07-2022
09:53 AM
|
1
|
0
|
1417
|
POST
|
Ken Its a new day / I started over from your example - First test worked - Both in a python window and from a tool/script. Code and results running the tool/script are: Code ----------- import arcpy, datetime, sys from arcgis import GIS from arcgis.features import _version base_server_url = "https://gisportal.co.polk.or.us/server/rest/services/ParcelTest" gis =GIS("pro") arcpy.AddMessage("username:" + gis.properties.user.username) from arcgis.features._version import VersionManager version_management_server_url = f"{base_server_url}/VersionManagementServer" vms = VersionManager(version_management_server_url, gis) arcpy.AddMessage(vms.properties) ---- Result Messages ---- Start Time: Wednesday, September 7, 2022 6:02:57 AM username:andersd {
"name": "Version Management Server",
"type": "Map Server Extension",
"defaultVersionName": "sde.DEFAULT",
"defaultVersionGuid": "{BD3F4817-9A00-41AC-B0CC-58F78DBAE0A1}",
"capabilities": {
"supportsConflictDetectionByAttribute": true,
"supportsPartialPost": true,
"supportsDifferencesFromMoment": true,
"supportsDifferencesWithLayers": true,
"supportsAsyncReconcile": true,
"supportsAsyncPost": true,
"supportsAsyncDifferences": true
}
} Succeeded at Wednesday, September 7, 2022 6:02:57 AM (Elapsed Time: 0.30 seconds) ---------------------------------------- I will keep testing - thanks again for looking into this.
... View more
09-07-2022
06:05 AM
|
1
|
0
|
1418
|
POST
|
Not a "notebook" user and got similar error. Entered code... import arcpy, datetime, sys from arcgis import GIS from arcgis.features.layer import FeatureLayer from arcgis.features.layer import FeatureLayerCollection base_server_url = "https://gisportal.co.polk.or.us/server/rest/services/ParcelTest" gis = GIS("pro") print("url: " + base_server_url) print("username:" + gis.properties.user.username) service_endpoints = ["FeatureServer", "VersionManagementServer"] service_urls = {url: base_server_url + url for url in service_endpoints} parcel_fabric_flc = FeatureLayerCollection(service_urls["FeatureServer"], gis) ---- "run" url: https://gisportal.co.polk.or.us/server/rest/services/ParcelTest
username:andersd ---------------------------------------------------------------------------
Exception Traceback (most recent call last)
In [1]:
Line 14: parcel_fabric_flc = FeatureLayerCollection(service_urls["FeatureServer"], gis)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\features\layer.py, in __init__:
Line 3732: if self.properties.syncEnabled:
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py, in properties:
Line 14176: self._hydrate()
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py, in _hydrate:
Line 14228: self._refresh()
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\__init__.py, in _refresh:
Line 14162: dictdata = self._con.get(self.url, params)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in get:
Line 506: ignore_error_key=ignore_error_key,
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_response:
Line 625: self._handle_json_error(data["error"], errorcode)
File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\gis\_impl\_con\_connection.py, in _handle_json_error:
Line 648: raise Exception(errormessage)
Exception: User does not have permissions to access this folder.
(Error Code: 403)
... View more
09-06-2022
09:30 AM
|
0
|
1
|
1424
|
POST
|
I get the same error when I when I run the script from a tbx tool. (just shells out to the script). I will look at notebook. Thanks for looking at this
... View more
09-06-2022
09:24 AM
|
0
|
2
|
1424
|
Title | Kudos | Posted |
---|---|---|
1 | 11-14-2022 05:13 AM | |
1 | 02-14-2024 08:17 AM | |
1 | 11-20-2023 05:55 AM | |
1 | 11-20-2023 05:14 AM | |
1 | 04-25-2023 03:15 PM |
Online Status |
Offline
|
Date Last Visited |
a week ago
|