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; }
Hi Brenden,
Brenden OReilly said:and have been tasked with upgrading MicrostationsJ(v 7.0) mdl code to work in v8i select series 4
Depending on size, complexity and also quality of V7 code, it can be (and typically is) enormous task. Everything related to levels have to rewritten, also often scanning, especially when levels are involved, have to be migrated from old mdlScan_ to mdlScanCriteria_ API. And there are plenty of other small and big issues that have to be evaluated.
I agree with Bob, when V7 > V8i migration is discussed now, whether it makes sense, when migration to CE will require another substantial amount of time.
Brenden OReilly said: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.
A question is whether do it in an opposite order would not be better.
Brenden OReilly said:What am I doing wrong?
I have no time to do any serious analysis (including try to remember how exactly this old scanning worked). but if I understand it right, the code searches for cell headers. Is it correct? The headers are elements, placed (historically in V7 files) in level 0.
I do not see any recursion in your code, that would dig inside the cell and to analyze the cell content.
Regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Answer Verified By: Brenden OReilly
Thank you, everyone for your responses. Unfortunately, I must use v8i for now. Upgrading to Connect will come later.
Jan, yes you are correct, the element that I am attempting to get the level for is a cell header, so that makes sense that I am getting a 0. I need to dig into the cell to get the actual levels.
There is a lot to Microstations that I need to learn
Brenden OReilly said:Upgrading to Connect will come later.
Be prepared to learn something completely new when moved to CE and (optionally) forget these "old C" things from J and V8.
Brenden OReilly said:There is a lot to Microstations that I need to learn
This old style, when element data structures are accessed directly, requires really good understanding of elements features and how they are stored.
Do you not know MicroStation?Have you been hired to convert programs for a software you are unfamiliar with? Have you written code for MicroStation in the past, or are you writing it currently?
While I don't know a lot about coding, I see here so very often where people are trying to rework old code and getting lost in all of the details that have changed. Sometimes, it might be easier to write newer applications by trying to understand WHAT the old code did and write new code to do "that thing", instead of trying to replicate HOW the old code did things.
MaryB
Power GeoPak 08.11.09.918Power InRoads 08.11.09.918OpenRoads Designer 2021 R2