Motivation #
This post dives into a specific discrepancy where property values visible in the UI aren’t consistently accessible through the API, focusing on the PressurePartContextType.DiameterNominal for appurtenances. It is asked and answered here by yours truly.
The Problem: UI Shows It, Code Doesn’t #
Two Civil 3D drawings, both featuring pressure pipe networks with appurtenances (specifically, Bulk Meters). When inspecting these appurtenances through the Civil 3D user interface, the nominal diameter information appears to be consistently defined.
Here’s what the “good drawing” shows for a Bulk Meter DN80 in the Pressure Network Parts List:

And similarly for the “bad drawing,” the UI also displays the diameter correctly:

So when we query the PressurePartContextType.DiameterNominal property through the Civil 3D .NET API, we should get consistent results, right?
Well, no. Not always. See the following C# code snippet designed to iterate through appurtenances and retrieve their nominal diameter:
[CommandMethod(nameof(PressurePartGetAddPartSize))]
public void PressurePartGetAddPartSize()
{
using var tr = ActiveACADDocument.Database.TransactionManager.StartTransaction();
foreach (ObjectId pressurePipeNetworkId in ActiveCivil3DDocument.GetPressurePipeNetworkIds())
{
var ppNetwork = tr.GetObject<PressurePipeNetwork>(pressurePipeNetworkId);
var ppList = tr.GetObject<PressurePartList>(ppNetwork.PartsListId);
var ppName = ppNetwork.PartsListName;
// Note: This part retrieves Pipe properties, not Appurtenance
// var partCategories = ppList.GetPartCategories(PressurePartDomainType.Pipe, PressurePartContextType.PipeDiamterInside);
var partSizes = ppList.GetParts(PressurePartDomainType.Appurtenance);
foreach (var partSize in partSizes)
{
var partFamilyID= partSize.GetProperty(PressurePartContextType.PartFamilyId);
var partFamilyName = partSize.GetProperty(PressurePartContextType.PartFamilyName);
// This is the problematic line for "bad drawing"
var nominalDiameter = partSize.GetProperty(PressurePartContextType.DiameterNominal);
var description = partSize.Description;
}
}
}
When run against the “good drawing,” this code successfully retrieving the nominalDiameter for appurtenances as a string. However, for the “bad drawing,” the line var nominalDiameter = partSize.GetProperty(PressurePartContextType.DiameterNominal); throws an Autodesk.AutoCAD.Runtime.Exception, indicating that PressurePartContextType.DiameterNominal cannot be found.
The Root Cause: UI vs. Catalog Data #
The discrepancy stems from how Civil 3D’s UI and API retrieve data for pressure parts. The key lies in understanding the structure of the part catalog.
Upon opening the part catalog in Content Catalog Editor (CCE), the reason for the API’s failure becomes clear:

Explanation #
- UI Retrieval: When you view the appurtenance properties in the Civil 3D drawing UI, it is actually pulling the nominal diameter from the “Nominal Diameter (mm)” column under the “Connection Points” data within the part catalog. This data is consistently populated for both drawings, which is why the UI always shows the correct diameter.
- API Retrieval (
PressurePartContextType.DiameterNominal): ThepartSize.GetProperty(PressurePartContextType.DiameterNominal)API call, however, attempts to retrieve a string value from the “Nominal Diameter Description” field located under the “General” properties of the appurtenance within the catalog.
For the “bad drawing,” this “Nominal Diameter Description” field was left empty by the catalog designer. Since the API specifically looks for a value in this particular field for PressurePartContextType.DiameterNominal, and it’s empty, it throws an exception.
The Takeaway #
While one could argue that this is a “fault of the catalog designer” for not populating the Nominal Diameter Description field properly, Civil 3D has to at least partly shoulder the blame. The Nominal Diameter Description in Appurtenance and Nominal Diameter in Connection should be related, so C3D shouldn’t allow one to set both separately, there is no data integrity check here.
Recommendations #
- Inspect Catalogs with CCE: If you encounter unexpected API behavior with pressure parts, always start by inspecting the part’s definition in the Content Catalog Editor. This will reveal what data is truly available at the catalog level.
- Alternative Data Sources: Always always try to ensure that the related data across different entities are consistent. You can do this by manual inspection, or use a script to interpolate. Under the hood of pressure part catalog is just sqlite file and some DWG files, so it is doable.
