POST
|
We use a lot of tools/scripts to calculate values within the ArcPro/Parcel Fabric Branched Version Environment (when it makes sense not to use tasks or calc attribute rules). I am testing Version 3.0+ and have run into the following problem and am hoping that I may doing something wrong. After a lot of testing I have created the following simple script that that illustrates the problem. (This all works fine in 2.94 and in a standard GeoDatabase). We do not use SDE for editing. Start State: Within Branched Version (GISADMIN.T67_9c_Test200Anno4) map session, Anno0200Scale feature class with Field (MapNumber) with value set to '6.3.8C'). Process: APRX is open, Tool in Tool Box runs script, Select OBJECTID = 7695 and Calc the value for MapNumber to be "XXXX" . I have tested this using arcpy.da.Editor using UpdateCursor with the Source being: https://giscarts.co.polk.or.us/server/rest/services/PF/Parcel_Fabric_3/FeatureServer;VERSION=GISADMI... which I calculate from the datasource of the Anno0200Scale feature class (after I removed the feature class name from the datasource text string). I have tested this without using the arcpy.da.Editor with da.UpdateCursor. I have also tested this with a simple CalculateField both using the arcpy.da.editor and not using it. Problem: I always get the same result. NOTHING HAPPENS unless I close the ArcPro session and reopen it. Then I can see the change. Using refresh screen / Change Version tool etc... None of it works. Its like the edit did not happen until I close the session and then go back in. My hope is that I am doing something wrong and somebody can help me out. Below is the script (again this is not production just a test). - it is also attached as a txt file. Finally, within a simple edit session I can interactively select features and calculate attributes, see the results with no problem. import arcpy, os # 1. Get parameter values AnnoLayer = 'Anno0200Scale' #2. Set Map Layers and default paths thisProject = arcpy.mp.ArcGISProject("CURRENT") Map = thisProject.activeMap AnnoLyr = Map.listLayers(AnnoLayer)[0] FolderPath = thisProject.homeFolder arcpy.AddMessage ("Map: " + Map.name) arcpy.AddMessage (AnnoLyr.dataSource) datasource = AnnoLyr.dataSource lastslash = datasource.rfind("/") workspace = datasource[:lastslash] arcpy.AddMessage(workspace) MapNumber = 'XXXX' # do edit session (Comment it out if you do not want to use it edit = arcpy.da.Editor(workspace) edit.startEditing(with_undo=False, multiuser_mode=True) edit.startOperation() with arcpy.da.UpdateCursor(AnnoLyr, ["MapNumber"],"OBJECTID = 7695") as cursor: for row in cursor: row[0] = MapNumber cursor.updateRow(row) edit.stopOperation() edit.stopEditing(save_changes=True)
... View more
11-14-2022
05:13 AM
|
1
|
1
|
378
|
POST
|
We use a lot of tools/scripts to calculate values within the ArcPro/Parcel Fabric Branched Version Environment (when it makes sense not to use tasks or calc attribute rules). I am testing Version 3.0+ and have run into the following problem and am hoping that I may doing something wrong. After a lot of testing I have created the following simple script that that illustrates the problem. (This all works fine in 2.94 and in a standard GeoDatabase). We do not use SDE for editing. Start State: Within Branched Version (GISADMIN.T67_9c_Test200Anno4) , Anno0200Scale feature class with Field (MapNumber) with value set to '6.3.8C'). Proposed Process: Select OBJECTID = 7695 and Calc the value for MapNumber to be "XXXX" . I have tested this using arcpy.da.Editor using UpdateCursor with the Source being: https://giscarts.co.polk.or.us/server/rest/services/PF/Parcel_Fabric_3/FeatureServer;VERSION=GISADMIN.T67_9c_Test200Anno4;VERSIONGUID={6284F53F-3A4B-4FFF-994E-7606A6AA3783} which I calculate from the datasource of the Anno0200Scale feature class (after I removed the feature class name from the datasource text string). I have tested this without using the arcpy.da.Editor with da.UpdateCursor. I have also tested this with a simple CalculateField both using the arcpy.da.editor and not using it. Problem: I always get the same result. NOTHING HAPPENS unless I close the ArcPro session and reopen it. Then I can see the change. Using refresh screen / Change Version tool etc... None of it works. Its like the edit did not happen until I close the session and then go back in. My hope is that I am doing something wrong and somebody can help me out. Below is the script (again this is not production just a test). - it is also attached as a txt file. Finally, within a simple edit session I can interactively select features and calculate attributes, see the results with no problem. import arcpy, os # 1. Get parameter values AnnoLayer = 'Anno0200Scale' #2. Set Map Layers and default paths thisProject = arcpy.mp.ArcGISProject("CURRENT") Map = thisProject.activeMap AnnoLyr = Map.listLayers(AnnoLayer)[0] FolderPath = thisProject.homeFolder arcpy.AddMessage ("Map: " + Map.name) arcpy.AddMessage (AnnoLyr.dataSource) datasource = AnnoLyr.dataSource lastslash = datasource.rfind("/") workspace = datasource[:lastslash] arcpy.AddMessage(workspace) MapNumber = 'XXXX' # do edit session (Comment it out if you do not want to use it edit = arcpy.da.Editor(workspace) edit.startEditing(with_undo=False, multiuser_mode=True) edit.startOperation() with arcpy.da.UpdateCursor(AnnoLyr, ["MapNumber"],"OBJECTID = 7695") as cursor: for row in cursor: row[0] = MapNumber cursor.updateRow(row) edit.stopOperation() edit.stopEditing(save_changes=True)
... View more
11-13-2022
12:47 PM
|
0
|
2
|
830
|
POST
|
We have recently begun using different "maps" to help organize edit workflows for parcel fabric. We have also been using Tasks. Unfortunately, it appears that Task "map views" can ONLY be set at design time using the task design environment and there is no setting for "use current or activemap". In the example below (very simplified) "Map1" is the active map for the task. If I want to use "Map" I have to open the designer and select it as the active map or press the "CurrentView" button at the bottom of the screen and if "Map" is the active view it will set it. But, again this only works at design time. If so, tasks are tied to a specific view or map and whenever someone changes the map name all tasks associated with the map must also be changed. I feel like I am missing something so any clarification would be greatly appreciated. If this is how it works I will need to re-think some things.
... View more
10-05-2022
12:48 PM
|
0
|
2
|
468
|
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
|
1294
|
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
|
1311
|
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
|
721
|
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
|
454
|
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
|
1048
|
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
|
938
|
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
|
1033
|
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
|
927
|
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
|
748
|
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
|
1758
|
Title | Kudos | Posted |
---|---|---|
1 | 06-10-2024 10:15 AM | |
1 | 06-10-2024 05:19 AM | |
1 | 06-05-2024 11:55 AM | |
1 | 11-14-2022 05:13 AM | |
1 | 02-14-2024 08:17 AM |
Online Status |
Offline
|
Date Last Visited |
06-19-2024
03:50 PM
|