ArcFM Desktop Overview > Designer Overview > Compatible Units > Managing CUs > Create CUs |
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:
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:
|
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); } |
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.
To add a CU to a treeview, follow these steps: