必须定义一个派生自 AecSpaceOffsetStandard 的新类。该类将作为一个框架来管理 AutoCAD Architecture 2024 toolset 在加载和应用标准时调用的各个规则和入口点。
using System; using System.Collections.Generic; using System.Text; namespace AecSpaceOffsetStandardSample {public class Class1 { }}
添加一个派生自抽象基本类 Autodesk.Aec.SpaceOffsetRulesManager.AecSpaceOffsetStandard 的标准类。
using Autodesk.Aec.SpaceOffsetRulesManager;
using System; using System.Collections.Generic; using System.Text; using Autodesk.Aec.SpaceOffsetRulesManager; namespace AecSpaceOffsetStandardSample {public class AecSpaceOffsetStandardSample : AecSpaceOffsetStandard {}public AecSpaceOffsetStandardSample() { }}
AecSpaceOffsetStandard.SetName() 方法是在基本类中实现的,不能被覆盖。需要在类的构造函数中调用该方法以便为标准注册一个名称。该名称将显示在 AutoCAD Architecture 2024 toolset 中的可用面积计算标准列表中。
下例演示了对样例项目 AecSpaceOffsetStandardSample 的调用,该项目在软件中注册为基准面积计算标准。
public class AecSpaceOffsetStandardSample : AecSpaceOffsetStandard {public AecSpaceOffsetStandardSample () {}SetName("Basic");}
public class AecSpaceOffsetStandardSample : AecSpaceOffsetStandard {public AecSpaceOffsetStandardSample () {}SetName("Basic");} protected override void InitRules() {// register rules}
这些调用将返回对 Autodesk.Aec.SpaceOffsetRulesManager.AecSpaceOffsetRuleCollection 类的一个对象的引用,该类可公开函数以注册不同的规则类型。这些对象由 AutoCAD Architecture 2024 toolset 维护和使用。下例演示了如何使用三种不同的偏移类型来注册规则:
public class AecSpaceOffsetStandardSample : AecSpaceOffsetStandard {public AecSpaceOffsetStandardSample () {}SetName("Basic");} protected override void InitRules() {// Register the rules with this standard, so the // offset calculation algorithm can call them // for the according boundary type NetRules().AppendBoundingOpeningRule(new BoundingOpeningRuleNet()); // no usable boundary UsableRules().SetSpaceRule(new NullSpace()); GrossRules().AppendBoundingObjectRule(new BoundingObjectRuleGross()); GrossRules().AppendBoundingAdjacencyRule(new BoundingAdjacencyRuleGross());}
public class AecSpaceOffsetStandardSample : AecSpaceOffsetStandard {public AecSpaceOffsetStandardSample () {}// set the name of the standard SetName("Basic");} // must be overriden protected override void InitRules() { } // can be overriden protected override void InitDatabase(Database* database) {// ...init database with classification definitions or zone styles, etc...}