Public Member Functions | List of all members
DgnModelRef Struct Referenceabstract

A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile. More...

#include <DgnModelRef.h>

Inheritance diagram for DgnModelRef:
DgnAttachment DgnModel

Public Member Functions

StatusInt CreateDgnAttachment (DgnAttachmentP &attachment, DgnDocumentMonikerR moniker, WCharCP modelName, bool loadCache=true)
 Attach the specified model in the specified file to this model. More...
 
StatusInt DeleteDgnAttachment (DgnAttachmentP &attachment)
 Remove the specified attachment from this model. More...
 
DgnAttachmentArrayP GetDgnAttachmentsP () const
 Get the attachments contained in this model. More...
 
DgnAttachmentArrayCP GetDgnAttachmentsCP () const
 Get the attachments contained in this model. More...
 
ReachableModelRefCollection GetReachableModelRefs (ReachableModelRefOptionsP=0)
 Get an iterable collection of modelRefs that includes 'this' modelRef, its attachments and all nested attachments. More...
 
ReachableElementCollection GetReachableElements (ReachableElementOptionsP=0)
 Get an iterable collection of elements reachable from this modelRef. More...
 
DgnAttachmentP FindDgnAttachmentByElementId (ElementId attachmentID)
 Gets the Bentley::DgnPlatform::DgnAttachment structure that for a reference given the element ID of its attachment element. More...
 
StatusInt ReadAndLoadDgnAttachments (DgnAttachmentLoadOptions const &)
 Detects attachments in this model, creates a Bentley::DgnPlatform::DgnAttachment for each, and then loads the attached models. More...
 
DgnModelRefP GetParentModelRefP () const
 Query the parent of an attachment, if any. More...
 
DgnModelP GetDgnModelP () const
 Get the model that is the target of this reference. More...
 
DgnFileP GetDgnFileP () const
 Get the file that this references. More...
 
ModelInfoCP GetModelInfoCP () const
 Get information about this model that this references. More...
 
bool IsDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment. This function is equivalent to testing the result of AsDgnAttachmentCP. More...
 
bool IsDirectDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself a direct attachment. More...
 
bool IsNestedDgnAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself an attachment owned by another DgnAttachment. More...
 
bool IsDwgStyleAttachment () const
 Query if this is a Bentley::DgnPlatform::DgnAttachment that is a DWG style attachment. More...
 
bool IsDefault () const
 Query if this references the default model in its file. More...
 
DgnModelRefType GetModelRefType () const
 Query if this model is an attachment and if so what type of attachment. More...
 
DgnModelCP AsDgnModelCP () const
 Cast this to a DgnModel. More...
 
DgnModelP AsDgnModelP ()
 Cast this to a DgnModel. More...
 
DgnAttachmentCP AsDgnAttachmentCP () const
 Cast this to a Bentley::DgnPlatform::DgnAttachment. More...
 
DgnAttachmentP AsDgnAttachmentP ()
 Cast this to a Bentley::DgnPlatform::DgnAttachment. More...
 
LevelCacheR GetLevelCacheR ()
 Get the level cache for this model reference. More...
 
LevelCacheCR GetLevelCache () const
 Get the level cache for this model reference. More...
 
FileLevelCacheP GetFileLevelCacheP ()
 Get the level cache for the file containing this model. More...
 
FileLevelCacheCP GetFileLevelCacheCP () const
 Get the level cache for the file containing this model. More...
 
bool Is3d () const
 Query if this is a 3D model. More...
 
bool TreatAs3d () const
 Query if this model should be treated as a 3D model for user interface purposes. It is true if the model is 3D and not a sheet model. More...
 
DgnFileP GetSymbologySourceDgnFileP () const
 Get the source file for this modelRef. This is the same as GetDgnFile unless the modelRef is a DgnAttachment that is being displayed by proxy (CVE) - in this case the symbology source will be the root. More...
 

Detailed Description

A DgnModelRef provides access to a model in a Bentley::DgnPlatform::DgnFile.

A DgnModelRef may be a direct reference to a model (a DgnModel) or an indirect reference to a model (a Bentley::DgnPlatform::DgnAttachment). This base class defines functions that are common to both models and attachments.

Collections and Iterators

GetDgnAttachmentsP returns an iterable collection of directly attached Bentley::DgnPlatform::DgnAttachment objects. GetReachableModelRefs returns an iterable collection of modelRefs that include 'this' modelRef, its attachments, their attachments, etc.

Remarks
Required library : DgnPlatform<ApiNumber>.lib i.e. DgnPlatform5.lib

Member Function Documentation

DgnAttachmentCP AsDgnAttachmentCP ( ) const

Cast this to a Bentley::DgnPlatform::DgnAttachment.

Returns
NULL if this is not a Bentley::DgnPlatform::DgnAttachment.
DgnAttachmentP AsDgnAttachmentP ( )

Cast this to a Bentley::DgnPlatform::DgnAttachment.

This function differs from AsDgnAttachmentCP in that it returns a non-const pointer.

Returns
NULL if this is not a Bentley::DgnPlatform::DgnAttachment.
DgnModelCP AsDgnModelCP ( ) const

Cast this to a DgnModel.

Remarks
This function differs from GetDgnModelP in that this function will return NULL if this model ref is a Bentley::DgnPlatform::DgnAttachment.
Returns
NULL if this is not a DgnModel.
See also
GetDgnModelP, AsDgnAttachmentCP
DgnModelP AsDgnModelP ( )

Cast this to a DgnModel.

This function differs from AsDgnModelCP in that it returns a non-const pointer.

Returns
NULL if this is not a DgnModel.
StatusInt CreateDgnAttachment ( DgnAttachmentP attachment,
DgnDocumentMonikerR  moniker,
WCharCP  modelName,
bool  loadCache = true 
)

Attach the specified model in the specified file to this model.

This creates a new Bentley::DgnPlatform::DgnAttachment.

Parameters
[out]attachmentnewly created attachment
[in]monikerIdentifies the document to be referenced
[in]modelNameThe model within the target file to be referenced
[in]loadCacheTrue to load the dgnModel.
Returns
non-zero status if the reference could not be created. Typically, the error will be one of:
  • DGNOPEN_STATUS_FileNotFound The file identified by document could not be found.
  • DGNMODEL_STATUS_NotFound The model identified by modelName could not be found in the file. Other DGNOPEN errors could also be returned.
Remarks
The parameters of the new Bentley::DgnPlatform::DgnAttachment are set up as follows:
  • scale mode = true scale
  • display, display raster = on if primary attachment, off if nested attachment
  • lstyle scale = on for DWG, otherwise off
  • origin and rotation = coincident
  • reference number = next available
  • logical name = computed unique logical name
This function does not add the new attachment as an element to the model. Call Bentley::DgnPlatform::DgnAttachment::Write
If fileName does not provide a full file specification, the master file path and the environment variables MS_RFDIR and MS_DEF are searched sequentially for the file.
See also
Bentley::DgnPlatform::DgnAttachment::Write
StatusInt DeleteDgnAttachment ( DgnAttachmentP attachment)

Remove the specified attachment from this model.

This deletes the Bentley::DgnPlatform::DgnAttachment.

Parameters
[in,out]attachmentThe attachment to be removed. Freed and set to NULL.
Returns
non-zero error status if attachment cannot be deleted.
Remarks
This method also removes the attachment element from the model.
DgnAttachmentP FindDgnAttachmentByElementId ( ElementId  attachmentID)

Gets the Bentley::DgnPlatform::DgnAttachment structure that for a reference given the element ID of its attachment element.

Remarks
This function looks only for attachments owned by this model, i.e., direct attachments. It does not recurse and look for nested attachments.
Parameters
[in]attachmentIDThe element id of the attachment element
See also
Bentley::DgnPlatform::DgnAttachment::GetElementId
DgnAttachmentArrayCP GetDgnAttachmentsCP ( ) const

Get the attachments contained in this model.

Returns
NULL if this model has no attachments.
See also
Bentley::DgnPlatform::DgnAttachment

Example:

DgnModelRefCR model = ... ;
if (NULL != model.GetDgnAttachmentsCP())
{
for each (DgnAttachmentCP attachment in *model.GetDgnAttachmentsCP())
{
printf ("Referencing file %S, model %S\n", attachment->GetAttachFileName().c_str(), attachment->GetAttachModelName());
}
}
DgnAttachmentArrayP GetDgnAttachmentsP ( ) const

Get the attachments contained in this model.

Returns
NULL if this model has no attachments.
See also
Bentley::DgnPlatform::DgnAttachment

Example:

DgnModelRefR model = ... ;
if (NULL != model.GetDgnAttachmentsP())
{
for each (DgnAttachmentP attachment in *model.GetDgnAttachmentsP())
{
printf ("Referencing file %S, model %S\n", attachment->GetAttachFileName().c_str(), attachment->GetAttachModelName());
}
}
DgnFileP GetDgnFileP ( ) const

Get the file that this references.

Returns
A DgnFile. If this is a DgnModel, then the returned file is the file that contains this model. If this is a Bentley::DgnPlatform::DgnAttachment, then the return value will be the attached file, if available, or NULL if not.

Referenced by DgnFontManager::GetDgnFontMapP(), DgnFontManager::GetFontByNumber(), and DgnFontManager::ResolveFontNum().

DgnModelP GetDgnModelP ( ) const

Get the model that is the target of this reference.

Returns
A DgnModel. If this is a DgnModel, then the returned model is this model. If this is a Bentley::DgnPlatform::DgnAttachment, then the returned model will be from the attached file, if available, or NULL if not.
See also
AsDgnModel
FileLevelCacheCP GetFileLevelCacheCP ( ) const

Get the level cache for the file containing this model.

Returns
a FileLevelCache. If this model is a Bentley::DgnPlatform::DgnAttachment, then the returned level cache will be from the attached file. If the attachment is unresolved, then NULL is returned.
FileLevelCacheP GetFileLevelCacheP ( )

Get the level cache for the file containing this model.

Returns
a FileLevelCache. If this model is a Bentley::DgnPlatform::DgnAttachment, then the returned level cache will be from the attached file. If the attachment is unresolved, then NULL is returned.
LevelCacheCR GetLevelCache ( ) const

Get the level cache for this model reference.

Returns
a LevelCache. If this model is a Bentley::DgnPlatform::DgnAttachment, then the returned level cache will be a Bentley::DgnPlatform::DgnAttachmentLevelCache.
LevelCacheR GetLevelCacheR ( )

Get the level cache for this model reference.

Returns
a LevelCache. If this model is a Bentley::DgnPlatform::DgnAttachment, then the returned level cache will be a Bentley::DgnPlatform::DgnAttachmentLevelCache.
ModelInfoCP GetModelInfoCP ( ) const

Get information about this model that this references.

Returns
A ModelInfo. If this is a DgnModel, then the returned info pertains to this model. If this is a Bentley::DgnPlatform::DgnAttachment, then the returned information will pertain to the attached DgnModel, if available. If the attached DgnModel is not available, then NULL is returned.
DgnModelRefType GetModelRefType ( ) const

Query if this model is an attachment and if so what type of attachment.

DgnModelRefP GetParentModelRefP ( ) const

Query the parent of an attachment, if any.

Returns
If this is DgnAttachment, return the model or attachment that owns this attachment. Otherwise, return NULL.

Get an iterable collection of elements reachable from this modelRef.

The reachable set includes all elements in this model as well as all elements in models attached to this model, including nested attachments.

Returns
A collection of Elements.

Example:

DgnModelRefR model = ... ;
for each (ElementHandle elem in model.GetReachableElements())
{
WString typeString;
elem.GetHandler().GetTypeName(typeString, 5000);
printf ("Reached element of type: %S\n", typeString.c_str());
}

Get an iterable collection of modelRefs that includes 'this' modelRef, its attachments and all nested attachments.

The returned modelRefs can refer to missing attachments, so a NULL check is required to determine if each modelRef refers to an actual model.

Returns
A collection of modelRefs.

Example:

DgnModelRefR model = ... ;
for each (DgnModelRefP modelRef in model.GetReachableModelRefs())
{
DgnFileP file = modelRef->GetDgnFileP();
DgnModelP model = modelRef->GetDgnModelP();
if (file && model)
printf ("Reached file %S, model %S\n", file->GetName(), model->GetModelName());
}
DgnFileP GetSymbologySourceDgnFileP ( ) const

Get the source file for this modelRef. This is the same as GetDgnFile unless the modelRef is a DgnAttachment that is being displayed by proxy (CVE) - in this case the symbology source will be the root.

bool Is3d ( ) const

Query if this is a 3D model.

bool IsDefault ( ) const

Query if this references the default model in its file.

bool IsDgnAttachment ( ) const

Query if this is a Bentley::DgnPlatform::DgnAttachment. This function is equivalent to testing the result of AsDgnAttachmentCP.

bool IsDirectDgnAttachment ( ) const

Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself a direct attachment.

See also
GetModelRefType
bool IsDwgStyleAttachment ( ) const

Query if this is a Bentley::DgnPlatform::DgnAttachment that is a DWG style attachment.

See also
GetModelRefType
bool IsNestedDgnAttachment ( ) const

Query if this is a Bentley::DgnPlatform::DgnAttachment that is itself an attachment owned by another DgnAttachment.

See also
GetModelRefType
StatusInt ReadAndLoadDgnAttachments ( DgnAttachmentLoadOptions const &  )

Detects attachments in this model, creates a Bentley::DgnPlatform::DgnAttachment for each, and then loads the attached models.

This operation is then applied recursively to attachments of the attached models. This function returns immediately if the attachments of this model have already been loaded. Loads Dgn attachments

bool TreatAs3d ( ) const

Query if this model should be treated as a 3D model for user interface purposes. It is true if the model is 3D and not a sheet model.


The documentation for this struct was generated from the following file:

Copyright © 2017 Bentley Systems, Incorporated. All rights reserved.