Branched Version Parcel Fabric Workflow

2182
15
Jump to solution
09-02-2022 06:28 AM
Labels (1)
DeanAnderson2
Occasional Contributor II

I am looking for some advice.  I am currently using ArcPro 2.9+ with a branched versioning and am setting up a new workflow.  As a first step in our workflow process I need to create a version with a record.  I prefer to do this all in one step so that I can programmatically control/manage both version and record info with one user interface.  Once a version is created I have found that I can programmatically create a record using the following code which creates a record in the Parcel Fabric records feature class (with no spatial component). Obviously, I will be adding more attributes but am using this as a basic test. 

-------------

thisProject = arcpy.mp.ArcGISProject("CURRENT")
Map = thisProject.activeMap
TargetFabric = Map.listLayers("TaxlotsPF")[0]
TargetRecord = Map.listLayers("Records")[0]

cursor = arcpy.da.InsertCursor(TargetRecord, ["Name"])

cursor.insertRow(["DeanTest111"])

----------------

I also found I can create a version using the "CreateVersion" tool.  Again, using the tool from a script is important as we want to manage both the version name and the record name following a set of rules and also ensure that improper characters are not used to name a version or a record.  I just took the following example from the user documentation but have used the tool successfully in a test environment. 

arcpy.CreateVersion_management(inWorkspace, parentVersion, versionName, "PUBLIC")

-----

The "Change Version" tool only seems to apply to specific layers.   It does seem to work that I can assign my new record change to a specific version (yay). Can this tool apply to "ALL" layers in my current project?  (I will be trying this next - It should be pretty simple to loop through all layers in my current active map )

My question is:  Is this a good way to do this or are there better ways?  I have been testing a variety of tools, scripts, tasks etc. in a branched version environment for awhile. 

Again Our Goal - One user interface that helps the user create both  a new version with a new record  and changes the version and makes the new record active. 

0 Kudos
15 Replies
KenGalliher1
Esri Contributor

I'm glad it's working!

And yes, you will have to watch out for that extra slash when building up URLs. I'm not sure if there's a more efficient way to get them.

Although it's hard to see in the Python API sample, the trailing slash is in the base_server_url variable.

KenGalliher1_0-1662573499906.png

Ken

0 Kudos
AmirBar-Maor
Esri Regular Contributor

@DeanAnderson2 

Future plans:

Ability to create a version in Tasks without having to select the version in the data source tab in the Contents pane. This would help to create a new version and switch to it using tasks.

We will also explore how you can enter a string once and use it to:

  1. Create a new version and switch to it
  2. Create a new record.

You are welcome to enter it as an idea

Amir

DeanAnderson2
Occasional Contributor II

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.  

DeanAnderson2_0-1662670729476.png

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).  

 

 

0 Kudos
AmirBar-Maor
Esri Regular Contributor

@DeanAnderson2 

You have plenty of great ideas.

It would be great if you can enter them: one idea in the parcel fabric community for setting the Active Record using python for a given map. Another idea in ArcGIS Pro Geodatabase for being able to change the version of a map.

0 Kudos
DeanAnderson2
Occasional Contributor II

will do 

DeanAnderson2
Occasional Contributor II

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. 
 
 
 
0 Kudos