ArcFM Desktop Developer Guide
Create CUs

Resource Center Home

This topic applies to Designer versions 10.0.3 and later.

With the implementation of compatible unit (CU) referencing in 10.0.3, the processes for creating CUs has changed from earlier versions. This topic covers:

Create CUs

To programmatically create a new CU in the CU library, create an ICompatibleUnit object. This new object must have at least the following properties. Review the ICompatibleUnit topic for more available properties.

Pass this ICompatibleUnit object to the GetValidatedCu method on the CuEditor class. This method verifies that the new CU was created correctly and passes the following validations:

The GetValidatedCu method returns an IValidCompatibleUnit object that contains information about it's validity. You can then pass this IValidCompatibleUnit object (assuming it's valid) to the Create method on the CuEditor class. The Create method generates an IRow object that resides in the MM_CU_LIBRARY table in the geodatabase. It also adds the ICompatibleUnit object to the CU library.

The Create method will throw an exception when it receives an invalid IValidCompatibleUnit object or when it encounters a conflict with an existing CU in the library.

The Create method may also throw an exception if:

  • You cannot create an edit workspace.
  • You cannot open an edit session.

Batch Create CUs

The following code sample illustrates how to create a large number of CUs in a single batch process. Use the BatchCreateCu method on the CuEditor object.

Copy Code
//Pass into the CreateCUs method the workspace and a list of IValidCompatibleUnit objects you wish to create.
private static void CreateCUs(IWorkspace workspace, List<IValidCompatibleUnit> validCus)
{
IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
if (workspace is IMultiuserWorkspaceEdit)
((IMultiuserWorkspaceEdit)workspace).StartMultiuserEditing(esriMultiuserEditSessionMode.esriMESMNonVersioned);
else
workspaceEdit.StartEditing(false);
workspaceEdit.StartEditOperation();
// If you already have a CuLibrary object, then point to it using the cuLib argument on the CuEditor.
// If you do not have a CuLibrary object, create one.
CuLibrary cuLib = new CuLibrary();
CuEditor cuEditor = new CuEditor(workspace, cuLib);

//Pass the list of IValidCompatibleUnit objects to the BatchCreateCu on the CuEditor.
//The BatchCreateCu method creates the CUs in a batch process.
cuEditor.BatchCreateCu(validCus);
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(saveEdits);
}

Add CU Defining Attributes or Extended Data

If you wish to associate CU defining attributes (CUDAs) or extended data with your new ICompatibleUnit object, you can do this using the ICompatibleUnitAttribute interface.

CU-defining attributes designate the features of a CU that are unchanging (e.g., a pole's height and class). Extended Data allows you to maintain data specific to your work management system (WMS).

Create an ICompatibleUnitAttribute object that contains the CUDA or extended data information. The ICompatibleUnitAttribute interface has three properties:

Once you have created the ICompatibleUnitAttribute object, pass it to the AddExtendedData or AddAttribute (for CUDAs) method on the ICompatibleUnit interface. Next, pass the ICompatibleUnit object to the GetValidatedCu method on the CuEditor class and continue creating the CU as described in the Create CUs section above.

Add a CU to a Treeview

To add a CU to a treeview, follow these steps:

  1. Call the FindCU() method to return an ICompatibleUnit object.
  2. Create a new IMMCompatibleUnit object.
  3. Copy necessary attributes from the ICompatibleUnit returned from the FindCU() method to the IMMCompatibleUnit you created. At a minimum this should include:
    • WMS code
    • CU name
    • available work function
  4. Cast your IMMCompatibleUnit as IMMAttributeDefinition. This step is necessary because Designer now uses CU referencing, so attributes are needed from ICompatibleUnit that are not part of IMMCompatibleUnit.
  5. Copy these attributes from the ICompatibleUnit:
    • CU description
    • table name (necessary for CU referencing)
    • subtype (necessary for CU referencing)
  6. Cast the IMMCompatibleUnit as ID8WorkFunction to copy work function from ICompatibleUnit.
  7. Add CU defining attributes (CUDAs) and extended data:
    • Use ICompatibleUnit.Attributes for CUDAs.
    • Use ICompatibleUnit.ExtendedData for extended data.
  8. Cast your IMMCompatibleUnit as an ID8ListItem.

 

 


Send Comment to ArcFMdocumentation@schneider-electric.com