Functions
msmodel.fdf File Reference
#include "msmodel.h"
#include "mselems.h"
#include <DgnPlatform\DgnFileIO\SheetDef.h>
#include <Mstn/MdlApi/filelist.h>
#include <DgnPlatform/DgnFile.h>

Functions

DgnPlatform::ModelId mdlModelRef_getModelID (DgnModelRefP modelRef)
 Gets the DgnPlatform::ModelId of a model. More...
 
StatusInt mdlModelRef_getModelName (DgnModelRefP modelRef, WCharP nameP)
 Gets the name of a model. More...
 
StatusInt mdlModelRef_setModelName (DgnModelRefP modelRef, const WChar *nameP)
 Sets the name of a model. More...
 
StatusInt mdlModelRef_getModelDescription (DgnModelRefP modelRef, WChar *pDescr)
 Gets the description of a model. More...
 
StatusInt mdlModelRef_setModelDescription (DgnModelRefP modelRef, const WChar *pDefaultRefLogical)
 Sets the default reference logical name for a model. More...
 
StatusInt mdlModelRef_setModelDefaultRefLogical (DgnModelRefP modelRef, const WChar *pDescr)
 Sets the description of a model. More...
 
StatusInt mdlModelRef_setModelType (DgnModelRefP modelRef, DgnPlatform::DgnModelType type)
 Sets the type of a model. More...
 
StatusInt mdlModelRef_setModelFlag (DgnModelRefP modelRef, int flagNum, int value)
 Sets various flags of a model. More...
 
double mdlModelRef_getUorPerMaster (DgnModelRefP modelRef)
 Gets the number of uors per master unit for a model. More...
 
double mdlModelRef_getUorPerSub (DgnModelRefP modelRef)
 Gets the number of uors per sub unit for a model. More...
 
double mdlModelRef_getSubPerMaster (DgnModelRefP modelRef)
 Gets the number of sub units per master unit for a model. More...
 
double mdlModelRef_getUorPerStorage (DgnModelRefP modelRef)
 Gets the number of uors per storage unit for a model. More...
 
double mdlModelRef_getUorPerMeter (DgnModelRefP modelRef)
 Gets the number of UORs per meter for a given model ref. More...
 
StatusInt mdlModelRef_getMasterUnit (DgnModelRefP modelRef, DgnPlatform::UnitInfo *pUnitInfo)
 Gets the master unit definition of a model. More...
 
StatusInt mdlModelRef_getSubUnit (DgnModelRefP modelRef, DgnPlatform::UnitInfo *pUnitInfo)
 Gets the sub unit definition of a model. More...
 
StatusInt mdlModelRef_getSubUnitLabel (DgnModelRefP modelRef, WCharP pLabel)
 Gets the sub unit label of a model. More...
 
StatusInt mdlModelRef_getMasterUnitLabel (DgnModelRefP modelRef, WCharP pLabel)
 Gets the master unit label of a model. More...
 
StatusInt mdlModelRef_getStorageUnit (DgnModelRefP modelRef, DgnPlatform::UnitInfo *pUnitInfo)
 Gets the storage unit definition of a model. More...
 
StatusInt mdlModelRef_setWorkingUnits (DgnModelRefP modelRef, const DgnPlatform::UnitInfo *pNewMasterUnit, const DgnPlatform::UnitInfo *pNewSubUnit)
 Sets the working units of a model, including the definition for both the master and the sub unit. More...
 
StatusInt mdlModelRef_setStorageUnits (DgnModelRefP modelRef, const DgnPlatform::UnitInfo *pNewStorageUnit, double *pNewUorPerStorage)
 Sets the storage unit definition of a model. More...
 
StatusInt mdlModelRef_setMasterUnitLabel (DgnModelRefP modelRef, const WChar *pLabel)
 Sets the master unit label of a model. More...
 
StatusInt mdlModelRef_setSubUnitLabel (DgnModelRefP modelRef, WCharCP pLabel)
 Sets the sub unit label of a model. More...
 
StatusInt mdlModelRef_getGlobalOrigin (DgnModelRefP modelRef, DPoint3dP pGlobalOrigin)
 Gets the global origin of a model. More...
 
StatusInt mdlModelRef_setGlobalOrigin (DgnModelRefP modelRef, DPoint3dCP pGlobalOrigin)
 Sets the global origin of a model. More...
 
StatusInt mdlModelRef_getAzimuth (DgnModelRefP modelRef, double *pAzimuth)
 Gets the azimuthal angle (the angle between the Y axis and true north) of the model in degrees. More...
 
StatusInt mdlModelRef_setAzimuth (DgnModelRefP modelRef, double azimuth)
 Sets the azimuthal angle (the angle between the Y axis and true north) of the model in degrees. More...
 
StatusInt mdlModelRef_getAuxCoordinateSystem (DgnModelRefP modelRef, Dpoint3d *pOrigin, RotMatrixP pRotMatrix, DgnPlatform::ACSType *pType, DgnPlatform::ElementId *pElementId)
 Gets the definition of the active auxiliary coordinate system of a model. More...
 
StatusInt mdlModelRef_getAuxCoordinateSystem2 (DgnModelRefP modelRef, Dpoint3d *pOrigin, RotMatrixP pRotMatrix, double *pScale, DgnPlatform::ACSType *pType, DgnPlatform::ElementId *pElementId)
 Get the active ACS for a model. More...
 
StatusInt mdlModelRef_setAuxCoordinateSystem (DgnModelRefP modelRef, const Dpoint3d *pOrigin, RotMatrixCP pRotMatrix, const DgnPlatform::ACSType *pType, const DgnPlatform::ElementId *pElementId)
 Sets the definition of the active auxiliary coordinate system of a model. More...
 
StatusInt mdlModelRef_setAuxCoordinateSystem2 (DgnModelRefP modelRef, const Dpoint3d *pOrigin, RotMatrixCP pRotMatrix, const double *pScale, const DgnPlatform::ACSType *pType, const DgnPlatform::ElementId *pElementId)
 Set the active ACS for a model. More...
 
StatusInt mdlModelRef_setGridParams (DgnModelRefP modelRef, const double *pUorPerGrid, const UInt32 *pGridPerRefernce, const double *pGridRatio, const DPoint2d *pGridBase, const double *pGridAngle)
 Sets the grid parameters of a model. More...
 
StatusInt mdlModelRef_setRoundoffUnit (DgnModelRefP modelRef, const double *pRoundoffUnit, const double *pRoundOffRatio)
 Sets the roundoff unit of a model. More...
 
bool mdlModel_nameCharIsValid (const WChar modelNameChar)
 Tests if the supplied character is valid for a model name. More...
 
bool mdlModel_nameIsValid (const WChar *modelName)
 Tests if the supplied string is a valid model name. More...
 
StatusInt mdlModelRef_setCellType (DgnModelRefP modelRef, DgnPlatform::CellLibraryType cellType)
 Set the cell type of a model. More...
 
StatusInt mdlModelRef_setSheetDef (DgnModelRefP modelRefIn, SheetDefCP sheetDefIn)
 For a modelref, set its sheet definition. More...
 
int mdlModelRef_getModelFlag (DgnModelRefCP modelRef, int flagNum)
 Gets various flags of a model. More...
 
DgnPlatform::DgnFileFormatType mdlModelRef_getOriginalFormat (DgnModelRefP modelRef)
 Gets the original format of a file. More...
 
StatusInt mdlModelRef_getSheetDef (DgnModelRefP modelRefIn, SheetDefP sheetDefOut)
 For a modelref, get its sheet definition. More...
 
StatusInt mdlModelRef_getRoundoffUnit (DgnModelRefP modelRef, double *pRoundoffUnit, double *pRoundOffRatio)
 Gets the roundoff unit of a model. More...
 
StatusInt mdlModelRef_getGridParams (DgnModelRefP modelRef, double *pUorPerGrid, UInt32 *pGridPerRefernce, double *pGridRatio, DPoint2dP pGridBase, double *pGridAngle)
 Gets the grid parameters of a model. More...
 
StatusInt mdlModelRef_getCellType (DgnModelRefCP modelRef, DgnPlatform::CellLibraryType *cellType)
 Get the cell type of a model. More...
 
double mdlModelRef_getEffectiveAnnotationScale (DgnModelRefP modelRefIn)
 For a modelref, get its effective annotation scale. More...
 
StatusInt mdlModelRef_getModelDefaultRefLogical (DgnModelRefP modelRef, WCharP pDefaultRefLogical)
 Gets the default reference logical name for a model. More...
 
StatusInt mdlModelRef_getLinkageHolderElement (DgnModelRefP modelRef, MSElementP el)
 Get an element containing all linkages associated with the model header. More...
 
StatusInt mdlModelRef_setLinkageHolderElement (DgnModelRefP modelRef, MSElementP el)
 Set linkages on the model header element. More...
 
bool dgnModel_isReadOnly (DgnModelP model)
 " " More...
 
ElementRefP dgnModel_findElemByFilePos (DgnModelP model, UInt32 filePos, int skipDeleted)
 Return the ElementRefP for an element, given a DgnModel and a filePos. More...
 
ElementRefP dgnModel_findElemByID (DgnModelP model, DgnPlatform::ElementId elementID)
 Find the element in a DgnModel with a specified ID. More...
 
DgnFileP dgnModel_getDgnFile (DgnModelP model)
 Get the DgnFileP for this model. More...
 
StatusInt dgnModel_getModelName (DgnModelP model, WChar *modelName)
 Get the model name for this model. More...
 
UInt32 dgnModel_getLevelUsage (DgnModelP model, int level)
 Get the number of elements on a particular level within a DgnModel. More...
 
UInt32 dgnModel_getLevelChangeCount (DgnModelP model)
 Get the number of times the number of elements on any level in this model has changed (this is useful to see whether the level information dialogs are current or not). More...
 
UInt32 dgnModel_getEOF (DgnModelP model, DgnPlatform::DgnModelSections section)
 Get the current End-Of-File filepos for a particular section of this model. More...
 
UInt32 dgnModel_getElementCount (DgnModelP model, DgnPlatform::DgnModelSections sections)
 Get the element counts for the categories in the mask. More...
 
UInt32 dgnModel_getControlElmStart (DgnModelP model)
 Get the filepos of the first Control Element for this model. More...
 
UInt32 dgnModel_getGraphicElmStart (DgnModelP model)
 Get the filepos of the first Graphic Element for this model. More...
 
int dgnModel_getRangeStamp (DgnModelP model)
 Get the "range stamp" for this model. More...
 
StatusInt dgnModel_getRange (DgnModelP model, DRange3dP pRange)
 Get the union of the ranges of all of the graphic elements held in this model. More...
 
bool dgnModel_is3D (DgnModelP model)
 Determine whether a model can hold 3D elements. More...
 

Function Documentation

ElementRefP dgnModel_findElemByFilePos ( DgnModelP  model,
UInt32  filePos,
int  skipDeleted 
)

Return the ElementRefP for an element, given a DgnModel and a filePos.

Note
This routine CAN return an ElementRefP for a deleted element.
Parameters
[in]modelThe DgnModel to search.
[in]filePosFind the element at this filePos.
[in]skipDeletedIf true, start at filePos and return the ElementRefP of the first non-deleted element in model.
Returns
the ElementRefP for the element at filePos. If the filepos is beyond the last element in the model, return NULL. " "
See also
dgnModel_findElemByID
ElementRefP dgnModel_findElemByID ( DgnModelP  model,
DgnPlatform::ElementId  elementID 
)

Find the element in a DgnModel with a specified ID.

Returns
the ElementRefP for an element, given a model and an ElementId.
Note
This routine CAN return an ElementRefP for a deleted element.
Parameters
[in]modelThe DgnModel to search.
[in]elementIDThe ID of the element to find.
Returns
the ElementRefP for the element with ID elementID. If no element exists in the model with that ID, return NULL. " "
UInt32 dgnModel_getControlElmStart ( DgnModelP  model)

Get the filepos of the first Control Element for this model.

Parameters
[in]modelThe DgnModel of interest
Returns
filepos of the first Control Element for this model. " "
See also
dgnModel_getGraphicElmStart
DgnFileP dgnModel_getDgnFile ( DgnModelP  model)

Get the DgnFileP for this model.

Parameters
[in]modelThe DgnModel of interest.
Returns
DgnFileP for this model. " "
Parameters
[in]modelThe DgnModel.
UInt32 dgnModel_getElementCount ( DgnModelP  model,
DgnPlatform::DgnModelSections  sections 
)

Get the element counts for the categories in the mask.

Parameters
[in]modelThe DgnModel of interest.
[in]sectionsAny combination of the values of ~t?DgnModelSections.
Returns
number of elements in the given sections " "
UInt32 dgnModel_getEOF ( DgnModelP  model,
DgnPlatform::DgnModelSections  section 
)

Get the current End-Of-File filepos for a particular section of this model.

Parameters
[in]modelThe DgnModel of interest.
[in]sectionSection of interest.
Returns
current End-Of-File filepos for this model. " "
UInt32 dgnModel_getGraphicElmStart ( DgnModelP  model)

Get the filepos of the first Graphic Element for this model.

Parameters
[in]modelThe DgnModel of interest
Returns
filepos of the first Graphic Element for this model. " "
See also
dgnModel_getControlElmStart
UInt32 dgnModel_getLevelChangeCount ( DgnModelP  model)

Get the number of times the number of elements on any level in this model has changed (this is useful to see whether the level information dialogs are current or not).

Parameters
[in]modelThe DgnModel of interest.
Returns
the number of level changes that have happened in this model. " "
UInt32 dgnModel_getLevelUsage ( DgnModelP  model,
int  level 
)

Get the number of elements on a particular level within a DgnModel.

Returns
the number of elements on a particular level.
Parameters
[in]modelThe DgnModel of interest
[in]levelThe level of interest. " "
StatusInt dgnModel_getModelName ( DgnModelP  model,
WChar *  modelName 
)

Get the model name for this model.

Parameters
[in]modelThe DgnModel of interest.
[out]modelNameThe name of the model.
Returns
SUCCESS if the modelName was filled in. " "
StatusInt dgnModel_getRange ( DgnModelP  model,
DRange3dP  pRange 
)

Get the union of the ranges of all of the graphic elements held in this model.

Parameters
[in]modelIN The DgnModel of interest
[out]pRangeOUT filled with the union of all of the ranges of the elements in model.
Returns
SUCCESS if range is known, ERROR otherwise " "
int dgnModel_getRangeStamp ( DgnModelP  model)

Get the "range stamp" for this model.

Each model holds a union of the range of all of the elements in the model. The range stamp is an ever-increasing value that can be used to indicate whether the overall range of a model has expanded (note that the range of a model never decreases, since deleted elements are never removed from the model) since the last call to this function.

Parameters
[in]modelIN The DgnModel of interest
Returns
the range stamp for this model. The value is not significant other than for comparisons between calls to this function. " "
bool dgnModel_is3D ( DgnModelP  model)

Determine whether a model can hold 3D elements.

Parameters
[in]modelIN The DgnModel of interest
Returns
true if the model can hold 3D elements. " "
bool dgnModel_isReadOnly ( DgnModelP  model)

" "

DgnModel Functions

A DgnFile reads Models from external files (e.g. V8 DGN files, V7 dgn files, DWG files, etc.) into memory to work with them. The object created by a DgnFile to hold a Model in memory is called a DgnModel. The contents of a loaded Model is held in a DgnModel and each DgnModel holds one and only one Model. For this reason, the terms "Model" and "DgnModel" are often used interchangeably. Note that some Models of a DgnFile may not be loaded into memory. A DgnFile will have no DgnModel for an unloaded Model.

DgnModels are owned by a DgnFile. When a DgnFile is closed, all DgnModels associated with that file are deleted as well. If a DgnFile is readonly, all DgnModels loaded from that DgnFile are readonly as well.

A DgnModel is a DgnModelRef. If a Model is attached as a reference more than once, there will be multiple DgnAttachments, but only one DgnModel.

Also see the ElementRefP Functions section for further information about the organization of elements within a DgnModel. Check the read only status of a DgnModel. "DgnModel Functions"

Parameters
[in]modelThe DgnModel to test.
Returns
true if the DgnModel is readonly, false if it is writeable.
StatusInt mdlModelRef_getCellType ( DgnModelRefCP  modelRef,
DgnPlatform::CellLibraryType *  cellType 
)

Get the cell type of a model.

This is only used when the model is placed as a cell.

Parameters
[in]modelRefModel to get data from.
[out]cellTypeThe cell type of the model. Possible values are CellLibraryTypes::Graphic, CellLibraryTypes::Point, and CellLibraryTypes::Menu which are defined in mscell.fdf.
Returns
SUCCESS if the cell type was returned successfully, otherwise ERROR.
See also
usmthmdlModelRef_setCellTypeC " "
double mdlModelRef_getEffectiveAnnotationScale ( DgnModelRefP  modelRefIn)

For a modelref, get its effective annotation scale.

Considers if the annotation scale lock is ON for the model. If the annotation scale lock is OFF, then effective annotation scale is 1.

Parameters
[in]modelRefInSheet model.
Returns
effective annotation scale " "
StatusInt mdlModelRef_getGridParams ( DgnModelRefP  modelRef,
double *  pUorPerGrid,
UInt32 pGridPerRefernce,
double *  pGridRatio,
DPoint2dP  pGridBase,
double *  pGridAngle 
)

Gets the grid parameters of a model.

Parameters
[in]modelRefGet the property of the model referenced by this.
[out]pUorPerGridThe number of uors per grid, NULL if not needed.
[out]pGridPerRefernceThe number of grids per ref grid, NULL if not needed.
[out]pGridRatioThe ratio of grid spacing y / x, NULL if not needed.
[out]pGridBaseThe grid base offset, NULL if not needed.
[out]pGridAngleThe grid rotation angle, NULL if not needed.
Returns
SUCCESS if the requested params were returned successfully, otherwise ERROR " "
StatusInt mdlModelRef_getLinkageHolderElement ( DgnModelRefP  modelRef,
MSElementP  el 
)

Get an element containing all linkages associated with the model header.

Note that the element itself has no data in it and should only be used to append linkages. The element will have all linkages from the model header so callers should be careful not to delete other linkages. Use ~mmdlModelRef_setLinkageHolderElement to add or update a linkage.

Parameters
[in]modelRefModel to get linkages from.
[in]elA pointer to a full-sized MSElement to copy the element and all linkages into.
Returns
SUCCESS if the element was filled successfully, otherwise ERROR.
See also
usmthmdlModelRef_setLinkageHolderElementC " "
StatusInt mdlModelRef_getModelDefaultRefLogical ( DgnModelRefP  modelRef,
WCharP  pDefaultRefLogical 
)

Gets the default reference logical name for a model.

Parameters
[in]modelRefGet the property of the model referenced by this.
[out]pDefaultRefLogicalThe default reference logical name when this model is referenced.
Returns
SUCCESS if the default reference logical string could be retrieved, otherwise ERROR
See also
usmthmdlModelRef_setModelDefaultRefLogical " "
int mdlModelRef_getModelFlag ( DgnModelRefCP  modelRef,
int  flagNum 
)

Gets various flags of a model.

Parameters
[in]modelRefGet the property of the model referenced by this.
[in]flagNumIs the property flag to query. See ~mmdlModelRef_setModelFlag for a list of values.
Returns
the flag value, or < 0 in case of an error " "
DgnPlatform::DgnFileFormatType mdlModelRef_getOriginalFormat ( DgnModelRefP  modelRef)

Gets the original format of a file.

For example, if the file originally existed as a DWG file that was "Save As"ed to V8 then this function will return DgnFileFormatType::DWG.

Valid File Formats
DgnFileFormatType::V7
DgnFileFormatType::V8
DgnFileFormatType::DWG
DgnFileFormatType::DXF

Parameters
[in]modelRefGet the property of the model referenced by this.
Returns
original format of the model, or -1 if the modelRef is invalid. " "
StatusInt mdlModelRef_getRoundoffUnit ( DgnModelRefP  modelRef,
double *  pRoundoffUnit,
double *  pRoundOffRatio 
)

Gets the roundoff unit of a model.

Parameters
[in]modelRefGet the property of the model referenced by this.
[out]pRoundoffUnitThe value of the roundoff unit.
[out]pRoundOffRatioThe ratio of roundoff units y / x. (if 0 use grid ratio)
Returns
SUCCESS if the requested params were returned successfully, otherwise ERROR " "
StatusInt mdlModelRef_getSheetDef ( DgnModelRefP  modelRefIn,
SheetDefP  sheetDefOut 
)

For a modelref, get its sheet definition.

Parameters
[in]modelRefInSheet model.
[out]sheetDefOutSheet definition.
Returns
SUCCESS if the sheet definition is successfully returned. " "
StatusInt mdlModelRef_setLinkageHolderElement ( DgnModelRefP  modelRef,
MSElementP  el 
)

Set linkages on the model header element.

Callers of this function should use ~mmdlModelRef_getLinkageHolderElement to get the element, add or modify linkages as necessary, and then call this function to update the model header. Since there may be other linkages on the model header, care should be taken not to modify any linkages that do not belong to the caller.

Parameters
[in]modelRefModel to set linkages on.
[in]elA pointer to an element from which the linkages will be extracted.
Returns
SUCCESS if the linkage was updated successfully, otherwise ERROR.
See also
usmthmdlModelRef_getLinkageHolderElementC " "

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