(SpaceOffsetRulesManager.AecBoundingObjectRule Base Class)
Bounding object rules allow objects that are bounding the base profile of the space, such as structural members, to be marked as non-bounding, so that they will not be processed when creating the offset profile. Each standard can define and apply multiple bounding object rules for each boundary offset type.
To implement a custom bounding object rule, you need to add a new class that is derived from the SpaceOffsetRulesManager.AecBoundingObjectRule base class. The new class needs to implement the Apply interface of the base class and register itself for the object types it should be called for in the constructor by calling the AecSpaceOffsetRuleBase.RegisterType() base method. The Apply method of this rule type has the following syntax:
public abstract bool Apply(Autodesk.AutoCAD.DatabaseServices.ObjectId idSpace, Autodesk.AutoCAD.DatabaseServices.ObjectId idObject);
The first argument is the current space for which the offset boundary profile is to be calculated. The second argument idObject is the Object ID of the object that bounds the space. Within the Apply method, the space object as well as the bounding object can now be opened and queried for certain properties to decide if this object should contribute to the generated profile. If the method returns false, the boundaries of the object are removed from the offset profile. This implies that the object will not be considered anymore when the offset rules are applied. The following example shows the framework for a new space rule called BoundingObjectRuleGross:
namespace AecSpaceOffsetStandardSample {public class BoundingObjectRuleBasic: AecBoundingObjectRule {}public BoundingObjectRuleGross() {}RegisterType(typeof(kAllTypes));} public override bool Apply(ObjectId idSpace, ObjectId idObject) {//return false to mark object as non-contributing}
The following example shows the bounding object rule implementation used for the gross profile of the sample project. This rule removes all segments from the profile that are bound by a structural member. This is a common case for defining the gross area of a space, where structural members are not considered, even if they are bounding the base profile of the space.
public class BoundingObjectRuleGross : AecBoundingObjectRule {public BoundingObjectRuleGross() {}RegisterType(typeof(kAllTypes));} public override bool Apply(ObjectId idSpace, ObjectId idObject) {bool result=true; Autodesk.AutoCAD.DatabaseServices.Database db =idObject.Database; using (Autodesk.AutoCAD.DatabaseServices.Transaction transaction =db.TransactionManager.StartTransaction()) {}Member member = transaction.GetObject(idObject, OpenMode.ForRead) as Member; if ( member == null ) {transaction.Commit(); } return result;MemberType memType = member.MemberType; if ( memType == MemberType.Column ) { result = false; }}
The figure below shows an example of applying this rule, where the net boundary (green) includes the columns, while the gross boundary (blue) ignores them