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:Any suggestions?
At first, read and follow this forum best practices and please edit your post.
Does not seem it weird to you that the most of discussions in this forum use standardized subject format (which should be [version subversion language]), code snippets are properly formatted (so readable easily)?
You cannot expect you will receive valuable answers quickly when you do not provide even basic "developers info" like product + version (build number), API / langueage you use (your code still can be compiled as pseudocode or native code) and you code is not formatted (so honestly, it cannot be read).
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
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
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.
Jan,
I appreciate your guidance about ‘best practices’ and submitting queries to this forum. As I very seldom use this avenue of support, I was unaware of the process.
Jon actually provided the answer I needed (without the condescending lecture).
Have a nice day.