How do you programatically switch versions on the parcel fabric?

1583
5
Jump to solution
02-10-2017 11:34 AM
KennethDinsmore
New Contributor II

I have a .net add-in for ArcGIS Desktop that helps a user set up their map document when they are starting a new project. One of the tasks that this add-in does for the user is create a version for the project (if it doesn't already exist) then switch all of the versioned layers to use that version. This works perfectly for "normal" feature classes, tables, relations etc. But it doesn't work for Parcel Fabric datasets. I haven't found any sample code that addresses this issue, does anyone have a sample that does this?

0 Kudos
1 Solution

Accepted Solutions
KennethDinsmore
New Contributor II

Resolved, this is clean and simple and maybe this will save someone else some time. This will change the version for all of the feature classes that are in the workspace of OldVersion. Thanks to the guy at ESRI who shared this with me.

private void ChangeDBVersionForDocument(IVersion OldVersion, IVersion NewVersion)
{
IActiveView pActiveView = ArcMap.Document.ActiveView;
IMap pMap = pActiveView.FocusMap;
IBasicMap pBasicMap = (IBasicMap)pMap;

if (OldVersion == null || NewVersion == null)
return;

IChangeDatabaseVersion pChDBVer = new ChangeDatabaseVersionClass();
pChDBVer.Execute(OldVersion, NewVersion, pBasicMap);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pChDBVer);

//notify listeners that the event was fired
IMapAdmin2 pMapAdmin = (IMapAdmin2)pMap;
pMapAdmin.FireChangeVersion(OldVersion, NewVersion);
}

View solution in original post

0 Kudos
5 Replies
MichaelVolz
Esteemed Contributor

What is your versioning setup for a "normal" feature class?

My organization has Default that is protected, a child version (call it MP) under this and then another layer of children under MP where the editing is done.  Is your "normal" feature class versioning setup anything like this?

This setup is not possible with the parcel fabric and you can only have child versions under the Default version and no versions below the child versions directly off of default.

0 Kudos
KennethDinsmore
New Contributor II

Under this scenario, the project version sits one level down from Default. If the version does not exist, I can create it. Once I create it, I can switch my feature classes to use the newly created version, except for the fabric classes. I've tried changing the version of the individual feature classes and the dataset.

0 Kudos
MichaelVolz
Esteemed Contributor

Do you get some sort of error message when running your .NET code?

0 Kudos
KennethDinsmore
New Contributor II

No error message, when I debug the code it looks like it opens the default version of the parcels sublayer, and it doesn't switch the version of the parcel fabric dataset.

0 Kudos
KennethDinsmore
New Contributor II

Resolved, this is clean and simple and maybe this will save someone else some time. This will change the version for all of the feature classes that are in the workspace of OldVersion. Thanks to the guy at ESRI who shared this with me.

private void ChangeDBVersionForDocument(IVersion OldVersion, IVersion NewVersion)
{
IActiveView pActiveView = ArcMap.Document.ActiveView;
IMap pMap = pActiveView.FocusMap;
IBasicMap pBasicMap = (IBasicMap)pMap;

if (OldVersion == null || NewVersion == null)
return;

IChangeDatabaseVersion pChDBVer = new ChangeDatabaseVersionClass();
pChDBVer.Execute(OldVersion, NewVersion, pBasicMap);
System.Runtime.InteropServices.Marshal.ReleaseComObject(pChDBVer);

//notify listeners that the event was fired
IMapAdmin2 pMapAdmin = (IMapAdmin2)pMap;
pMapAdmin.FireChangeVersion(OldVersion, NewVersion);
}

0 Kudos