The .NET API
provides access to relationship objects called anchors. These special objects
specify relationships between other objects in the system. ACA base objects
such as walls, windows, and doors know nothing about other objects in the
system. For example, a window and a wall know nothing about each other. If
they were designed to know details about each other, a single window object
would have to know in advance how to behave in any wall, anywhere in the
world. Then consider a different type of placement of a window - what if you
wanted to place the window in a roof? There would be no way to predict all
the possible rules of interaction with other objects. Therefore, the rules
are factored into another object called an anchor. |
|
Anchor objects know
specifically how two objects interact with each other. In the case of the
window and wall, the anchor knows to move the window only within a wall, and
to erase the window if the wall is erased. But a window can also be anchored
to something else, such as a roof. It could also be anchored to something
like a grid to allow it to behave well within a window assembly. This
abstraction of relationships means that objects are potentially interactive
with all other objects in the system without necessarily knowing in advance
what those other objects are. |
|
Anchors are used
typically to establish geometric relationships between objects. They are
database resident objects, so they are persistent and have data associated
with them. For example, a door is typically anchored to a wall at a specific
location. If the wall is moved, the door stays in its position relative to
the wall. When working with objects in the context of anchoring it is a good
idea to determine if the objects are already anchored. The Geo derived
objects provide a property for determining the existing anchor called
AnchorId. |
|
Base class is
Aec.DatabaseServices.Anchor and the real base class is AnchorToReference.
Every anchor derives off this. And there are more specific ones like
AnchorEntityToWall and something more specific AnchorOpeningBaseToWall. Thus
Anchors have knowledge about what they work with specifically based on their
type. |
|
Two ways to work
with anchors – 1) is to work with existing anchor relationships. You can
check any Geo derived entity for any anchorId. So if Id is null, there is no
anchor and if there is one, that Id returned in not null. |
|
2) We can also
create new Anchors and relationships. Get the wall’s objectId, then create or
get the door. The door will be anchored to the wall and so we need to have
the door as open for write. Create the anchor which in this case will be
AnchorOpeningBaseToWall and initialize it. It is a DB object type and so we
will be using subsetDatabaseDefaults. We will use the anchor to set the
geometric positioning data. We shall then assign the new anchor to the door
using the Door SetAnchor API. Set the ID on the wall. |
|