Classes | Typedefs | Functions
DgnFile C Api

Find an element in one of the loaded DgnModels of a DgnPlatform::DgnFile by ID. More...

Classes

struct  v8ToV7Hooks
 

Typedefs

typedef struct v8ToV7Hooks V8ToV7Hooks
 
typedef int(* ModelRefTraverseFunctionP )(int *pMayContinue, DgnModelRefP modelRef, bool isDefault, CallbackArgP pUserData)
 UserFunction called from mdlDgnFileObj_traverseRootModelRefs. More...
 

Functions

StatusInt mdlFile_checkDesignFile (bool *isThreeD, WCharCP fileName)
 Determine whether a file is a valid DGN file, and if it is a DGN file, it's dimensionality. More...
 
ElementRefP dgnFileObj_findElemByID (DgnFileP dgnFile, DgnPlatform::ElementId elementID, bool dictionaryOnly)
 
DgnFileP mdlDgnFileObj_getMasterFile ()
 Get the DgnFileObj for the current master file. More...
 
bool mdlDgnFileObj_hasPendingChanges (DgnFileP dgnFileObj)
 Determines if a design file has pending chages. More...
 
StatusInt mdlDgnFileObj_createModel (DgnModelRefP *pNewModelRef, DgnFileP dgnFileObj, DgnModelRefP seedModelRef, WCharCP pName, WCharCP pDescr, DgnPlatform::DgnModelType *pType, bool *pIs3d)
 Create a new model and add it to the specified file. More...
 
V8ToV7HooksmdlDgnFileObj_setV8ToV7Hooks (V8ToV7Hooks *pHooks)
 
Register a group of user callback functions that are called by MicroStation when saving a MicroStation V8

file to the IGDS 8 file format (the file format used by versions of MicroStation prior to version 8.0). More...

 
StatusInt mdlDgnFileObj_traverseRootModelRefs (ModelRefTraverseFunctionP callbackFunc, CallbackArgP callbackArg, DgnFileP dgnFileObj)
 Traverse the models of the given file. More...
 
StatusInt mdlDgnFileObj_traverseModelIndex (ModelIndexTraverseFunctionP pCallbackFunc, CallbackArgP pCallbackArg, DgnFileP dgnFileObj)
 Traverse the models of the given file. More...
 
StatusInt mdlDgnFileObj_findModelIDByName (DgnFileP dgnFileObj, DgnPlatform::ModelId *pModelID, WCharCP name)
 Retrieve the persistent ID for a model from the model's name. More...
 

Detailed Description

Find an element in one of the loaded DgnModels of a DgnPlatform::DgnFile by ID.

First looks in the dictionary model. If ID is not found in the dictionary model, and the "dictionaryOnly" flag is true, it then returns NULL. Otherwise it searches all loaded caches looking for the id.

Parameters
[in]dgnFilefile to search
[in]elementIDID to find
[in]dictionaryOnlyif true, only search dictionary model.
Returns
ElementRefP of element with elementID. If id is not found, return NULL.

Typedef Documentation

typedef int(* ModelRefTraverseFunctionP)(int *pMayContinue, DgnModelRefP modelRef, bool isDefault, CallbackArgP pUserData)

UserFunction called from mdlDgnFileObj_traverseRootModelRefs.

Parameters
[out]pMayContinuetrue means keep going, false means stop now
[in]modelRefmodelRef
[in]isDefaulttrue if this is the default model
[in]pUserDatauserdata or NULL
Returns
non-zero return will stop traversal
typedef struct v8ToV7Hooks V8ToV7Hooks

Function Documentation

ElementRefP dgnFileObj_findElemByID ( DgnFileP  dgnFile,
DgnPlatform::ElementId  elementID,
bool  dictionaryOnly 
)
StatusInt mdlDgnFileObj_createModel ( DgnModelRefP *  pNewModelRef,
DgnFileP  dgnFileObj,
DgnModelRefP  seedModelRef,
WCharCP  pName,
WCharCP  pDescr,
DgnPlatform::DgnModelType *  pType,
bool *  pIs3d 
)

Create a new model and add it to the specified file.

This function returns a working modelRef which must be freed with <a ="mdlModelRefList_free.htm">mdlModelRef_freeWorking.

Parameters
[out]pNewModelRefis a DgnPlatform::DgnModelRef to the newly created model. This can be used in any of the mdl functions that accept a DgnModelRefP. It should be freed by calling mdlModelRef_freeWorking.
[in]dgnFileObjindicates the design file to create the new model in.
[in]seedModelRefindicates a seed model from which settings are copied into the new model. This argument should not be NULL.
[in]pNameindicates the name string to assign to the model. If this is NULL, a name is automatically assigned by MicroStation.
[in]pDescrindicates the description string to assign to the model. If this is NULL, no description is assigned.
[in]pTypeindicates the value that sets the type of the model. Possible values for the type are: DgnModelType::Sheet and DgnModelType::Normal. Setting pType to NULL will create model that has the same type as the seedModelRef.
[in]pIs3dis3d (NULL to use seed)
Returns
MDLERR_BADARG if the file reference is invalid; MDLERR_MODELNAMEEXISTS may be returned if the name specified in pName is not unique within the specified file; otherwise, if the model is created successfully, SUCCESS is returned.
Remarks
Required Library: mdlbltin.lib
See also
mdlModelRef_freeWorking
StatusInt mdlDgnFileObj_findModelIDByName ( DgnFileP  dgnFileObj,
DgnPlatform::ModelId *  pModelID,
WCharCP  name 
)

Retrieve the persistent ID for a model from the model's name.

Parameters
[in]dgnFileObjthe DgnFileObj of interest.
[out]pModelIDmodelID of model
[in]namename to seach for
Returns
SUCCESS if the model was found.
Remarks
Required Library: mdlbltin.lib
See also
mdlDgnFileObj_getModelItemByID
DgnFileP mdlDgnFileObj_getMasterFile ( )

Get the DgnFileObj for the current master file.

DgnFileObj Functions

MicroStation can work with files in several formats (e.g. DGN V7, DGN V8, DWG, etc.). To deal with these varied formats, MicroStation defines an object called a DgnFileObj that internally handles the differences between the capabilities of each format. The DgnFileObj API provides functions to operate on external files in a consistent manner, regardless of external format.

MicroStation creates a DgnFileObj for all files it opens, (e.g. the Master File, Reference files, or work files.)

DgnCaches are loaded from DgnFileObjs.

Returns
The DgnFileP for the current master file.
Remarks
Required Library: mdlbltin.lib
bool mdlDgnFileObj_hasPendingChanges ( DgnFileP  dgnFileObj)

Determines if a design file has pending chages.

Parameters
[in]dgnFileObjis a reference to the design file of interest
Returns
true if the design file has changes that have not been saved; false otherwise.
Remarks
Required Library: mdlbltin.lib
V8ToV7Hooks* mdlDgnFileObj_setV8ToV7Hooks ( V8ToV7Hooks pHooks)

Register a group of user callback functions that are called by MicroStation when saving a MicroStation V8

file to the IGDS 8 file format (the file format used by versions of MicroStation prior to version 8.0).

Parameters
[in]pHooksis a pointer to a structure of the form shown below.
<p>typedef struct v8ToV7Hooks
{
void (*pNewHooks)(struct v8ToV7Hooks *pNewHooks);
void (*pBeforeSave) ();
int (*pMapV8LevelNameToNumber) (const char *pLevelName);
void (*pMapV8CellNameToV7) (char *pV7Name, int maxSize,
const char *pV8Name);
int (*pMapV8FontNameToNumber) (const char *pFontName);
void (*pAfterSave) ();
Returns
A pointer to the structure containing the hook information in place before the function was called.
Remarks
Required Library: mdlbltin.lib
StatusInt mdlDgnFileObj_traverseModelIndex ( ModelIndexTraverseFunctionP  pCallbackFunc,
CallbackArgP  pCallbackArg,
DgnFileP  dgnFileObj 
)

Traverse the models of the given file.

The callback will be called once for each model.

Parameters
[in]pCallbackFuncfunc to call for each model
[in]pCallbackArgargument to pass into func
[in]dgnFileObjthe DgnFileObj of interest.
Returns
This function either returns an error, or it returns the last status returned by the callback.
Remarks
Required Library: mdlbltin.lib
StatusInt mdlDgnFileObj_traverseRootModelRefs ( ModelRefTraverseFunctionP  callbackFunc,
CallbackArgP  callbackArg,
DgnFileP  dgnFileObj 
)

Traverse the models of the given file.

The callback will be called once for each loaded model. To access all models, use the modelIndex functions - either mdlDgnFileObj_traverseModelIndex or use mdModelIterator_create and other mdlModelIterator_* functions.

Parameters
[in]callbackFuncfunc to call for each model
[in]callbackArgargument to pass into func
[in]dgnFileObjthe file object to traverse
Returns
This function either returns an error, or it returns the last status returned by the callback.
Remarks
Required Library: mdlbltin.lib
StatusInt mdlFile_checkDesignFile ( bool *  isThreeD,
WCharCP  fileName 
)

Determine whether a file is a valid DGN file, and if it is a DGN file, it's dimensionality.

Parameters
[out]isThreeDpoints to a boolean that is set to true if fileName is a three dimensional DGN file.
[in]fileNamethe name of the file to be checked.
Returns
SUCCESS if the file is a DGN file and ERROR otherwise.

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