About Using Classifications in the Rule Implementation

After adding classifications to the current database, you want to use them within area calculation standard plug-ins. You are in principle able to determine the classification from a space that is passed to a rule with the existing AutoCAD Architecture 2024 toolset .NET API. This however could be complex, especially as you always need to use the global name of classifications within your rules, in order to work with all localizations of the classifications display name. Therefore, the class AecSpaceOffsetClassification provides functionality to simplify this.

Reading the Global Classification Name from a Space Object

The AecSpaceOffsetClassification class has a method to get the global classification name from a space object so that it can be compared to the names defined by the resource string table to decide how to offset boundaries. The method is the public string GetClassificationName(Object Id objId). The following example shows a bounding adjacency rule that uses the classifications described in the example table above. Because the rule needs to be able to access the AecSpaceOffsetClassification object of the standard, the standard is passed through the constructor and assigned to a member of the rule. This means you will need to create the rule in the standard’s InitRules() implementation with a “this” reference to the current standard.

public class BoundingAdjacencyRuleGross : AecBoundingAdjacencyRule
{
private AecSpaceOffsetStandardISA standard;
public BoundingAdjacencyRuleGross(AecSpaceOffsetStandardISA standardISA)
{
standard = standardISA;
} public override AecSpaceOffsetInfo Apply(ObjectId idSpace, ObjectId idObject, ObjectId idAdjSpace) {
String classificationNameThis = "";
String classificationNameAdjacent = "";
if (!idSpace.IsNull)
{
classificationNameThis = standard.Classification.GetClassificationName(idSpace);
} if (!idAdjSpace.IsNull) {
classificationNameAdjacent = standard.Classification.GetClassificationName(idAdjSpace);
} if (idAdjSpace.IsNull || classificationNameAdjacent =="Exterior") {
return new AecSpaceOffsetInfo(AecSpaceOffsetType.Opposite);
} if (!idAdjSpace.IsNull && classificationNameThis == "Exterior") {
return new AecSpaceOffsetInfo(AecSpaceOffsetType.Adjacent);
} if (classificationNameThis == "Office") {
return new AecSpaceOffsetInfo(AecSpaceOffsetType.Adjacent);
} // for the rest return new AecSpaceOffsetInfo(AecSpaceOffsetType.Center);
}
}