Hello,I'm sort of new to Microstations and have been tasked with upgrading MicrostationsJ(v 7.0) mdl code to work in v8i select series 4. I've hit an issue with a function that simply gets the level for an element. I've read that levels in Microstations 7 to 8 changed quite a bit, so I know I would have to rewrite the code for this funciton.
The existing function in v7 used the old method of obtaining the level by traversing an array of short integers and the level could be 1 to 63.
So here is my plan to rewrite the funcction to get the level in v8i
1. Use the mdlElement_getProperties function to get the level id of an element. Note that I realize that this is an internal id and does not equate to the level id in v7.
2. Use funcciton mdlLevel_getName to get the level name from the internal level id. The level name is significant to us, since it seems to equate to the old v7 level, example Level 71, Level 42 ect..
My problem is that in step 1, I always get back a 0 for the internal level id. So when the code below runs I always see the following for each element: this is for thousands of elements always 0. I never see the line good level if the levelid is not 0.
element is graphic level id: 0
I've commented out the call to mdlLevel_getName, since it seems pointless to call it for now if the levelid is always 0, and don't mind that I am returning 1 form the funciton, this is just for testing for now.
couple of more things:I will post full code for my program in a reply to this post. this is a test program that I run from the command windows. The program does a file scan of each hard-coded cell then reads each element in the cell. I know these elements are good because I had code in this program (that I removed for readability) that successfully got other information off the element after the call to getItemLevel.
The dgn that I am using is from v7, so when I opened it in v8i the first time, it converted the file. There is only 1 default model. And if I go into the dgn in v8i, I can see the levels exist that I am tring to get the level name for.
I kow that the way that I am scanning the file is outdated and I will be looking to changing that after I get past my current issue with the levelid.
So here is my question?What am I doing wrong? Am I on the right track for retreiving the level name for an element or is there another way to do this? If I am on the right track then why am I always gettting a 0 in the levelid?
Help for my issue would be greatly appreciated. I've searched these forms and the reference material without success.
Public int getItemLevel(MSElement *elP) { MSWChar levelName [50]; UInt32 levelid; //elements are graphic if(elP->ehdr.isGraphics) { fprintf(fres,"\n element is graphic"); mdlElement_getProperties ( &levelid , NULL , NULL , NULL, NULL , NULL, NULL, NULL, elP ); fprintf(fres,"\n level id: %d", levelid); if (levelid != 0) { fprintf(fres,"\n good level"); } /* if (SUCCESS == mdlLevel_getName( levelName, 50, MASTERFILE, levelid )) { fprintf(fres,"\nlevel name = %s",levelName); } */ } return 1; }
Brenden OReilly said:I've read that levels in Microstations 7 to 8 changed quite a bit
An element has one of 63 levels. Each MSElement has that level bit stored in a 64-bit value (4x16-bit short integers). That is, the entire level domain is specified by that bit.
MSElement
Customers didn't like having only 63 levels and campaigned for more, which resulted in the V8 file spec. revealed in 2001.
Level names were not stored on each element, but in a table stored in the DGN file (if I recall correctly).
Each MSElement has a UInt32 LevelId...
UInt32
LevelId
..\DgnPlatform\DgnPlatformBaseType.r.h(85): typedef UInt32 LevelId;
That LevelId points to a level table stored in the DGN file. The table stores only those levels that have been defined. That is, the level table doesn't have 2 billion rows. Each row in that table stored the LevelId, the user-defined level name and optionally a user-defined level number. A user doesn't normally see the LevelId, but it's what we programmers work with.
With the V8 API, scanning is easier. You don't have to set up an ExtScanList. It could well be that the scanlist setup for V8 is wrong.
ExtScanList
Prefer to use the mdlScanCriteria_api. The SDK supplies examples, and here's another.
mdlScanCriteria_api
Cell names are not restricted to six packed upper-case characters. You don't need the conversion function (mdlCnv_fromAsciiToR50) to exchange packed names with a C string.
mdlCnv_fromAsciiToR50
Regards, Jon Summers LA Solutions