(SpaceOffsetRulesManager.AecSpaceRule Base Class)
A space rule is applied to the whole space, as opposed to all other rule types which are more specific. Space rules are the only type of offset rules that can only be registered once for each standard (once for each of the offset types net, usable, and gross.)
To implement a space rule, you must add a new class that is derived from the SpaceOffsetRulesManager.AecSpaceRule base class. The new class must implement the Apply interface of the base class. It need not call the AecSpaceOffsetRuleBase.RegisterType() method of the base class since it always applies to space objects. The Apply method that each rule needs to implement has the following syntax for the AecSpaceRule class:
public abstract bool Apply(Autodesk.AutoCAD.DatabaseServices.ObjectId idSpace);)
The boolean return value determines if the space has a valid offset boundary. If so, it can be used to deactivate all boundaries of a certain offset type. The following example shows the framework for a new space rule class:
namespace AecSpaceOffsetStandardSample {public class SpaceRule: AecSpaceRule {}public SpaceRule() { } public override bool Apply(ObjectId idSpace) { // return false to switch boundary off }}
A common use case is that an area calculation standard includes only net and gross offsets, but no usable offset. You can accomplish that by implementing a space rule derived from AecSpaceRule that always returns false in the implementation of the Apply method. Register one instance of that rule with the usable offset in the standards implementation of AecSpaceOffsetStandard.InitRules().
A more complex space rule might define that all spaces with an area smaller than a certain predefined value do not contribute to a certain offset type. The following example shows the space rule that is part of the sample project and that will invalid all spaces. It is used within the sample standard to switch off the usable boundary:
namespace AecSpaceOffsetStandardSample {public class NullSpace: AecSpaceRule {}public SpaceRuleNet() { } public override bool Apply(ObjectId idSpace) { return false; }}