I am attempting to cycle through all the cells in a library by stepping through the models. The following code would
seem to be a logical way to achiever this. However, it retrieves only the current (active) model, and then the process
exits (no further processing). What am I doing incorrectly?
mdlModelRefIterator_create (&iterator, MASTERFILE, MRITERATE_Root | MRITERATE_PrimaryChildRefs , -1); while (modelRefP = mdlModelRefIterator_getNext (iterator)) { mdlModelRef_getModelName (modelRefP, WmodelName); mdlCnv_convertUnicodeToMultibyte (WmodelName, -1, modelName, sizeof(modelName)); printf ("Model Name-> %s\n", modelName);}
On a side note, when I attempt to cycle through all the cells with the following code (using an index iterator), it performs as
expected and steps through each cell (model).
fileObj = mdlModelRef_getDgnFile(MASTERFILE); ndxIterator = mdlModelIterator_create (fileObj); mdlModelIterator_setAcceptCellsOnly (ndxIterator, TRUE); while (NULL != (IndexItem = mdlModelIterator_getNext (ndxIterator))) { mdlModelItem_getName (IndexItem, WmodelName, MAXFILELENGTH); mdlCnv_convertUnicodeToMultibyte (WmodelName, -1, modelName, sizeof(modelName)); mdlModelItem_getDescription (IndexItem, WmodelDesc, MAXFILELENGTH); mdlCnv_convertUnicodeToMultibyte (WmodelDesc, -1, modelDesc, sizeof(modelDesc)); printf ("Model Name-> %s Description-> %s\n", modelName, modelDesc);
}
Any suggestions?
Larry Durke
Larry Durke said:I am attempting to cycle through all the cells in a library by stepping through the models
Larry Durke said:when I attempt to cycle through all the cells with the following code (using an index iterator), it performs as expected
when I attempt to cycle through all the cells with the following code (using an index iterator), it performs as expected
Larry Durke said:Any suggestions?
You've written some code that does what you want. What kind of suggestions are you expecting (notwithstanding Jan's to follow the forum best practices)?
If you're asking why the second code fragment works where the first doesn't, then you must consider the difference between reference attachment models (first fragment) and model references (cells) in a DGN file (second fragment).
This article provides some clarification.
Regards, Jon Summers LA Solutions
While I understand the issue of 'best practices', I appreciate your response. This was enough to answer my question, without the lecture.
Thanks Jon.