Now this is a tricky one...
After much headscratching and support tickets bounced backwards and forwards with Bentley the conclusion was reached that the VB API is still very immature when it comes to 3D and material information.
Basically if you have an external process (that isn't using Microstations MDL language) then accessing the material assignment information (levels / solid faces etc) is nigh on impossible.
After much investigation, and a lot of time frustrated, I came to the conclusion that the treeview within the materials window is inaccessible with the API

All the infomation on the right of the screen is accessible as they are generally text boxes which the 'getcexpressionvalue' function can poke to return the selected value (record a VBA macro to get the names of the textboxes) but this method is okay only if you want the properties for the selected option in the treeview.
Away around this is to produce the .Mat output file as it should contain all the material assignment information that you can read. Trouble I found is this can be a little tempermental as sometimes doesn't produce any assignment results at all (what I found with my test drawings).
After reworking the problem (with the help of an expert Microstation driver) the decision was made to export the level infomation out through a .CSV file, and use some VB to extract the level name and material assignment, as well as producing a .pal file for material and pattern map selected values.
This approach worked well for the .csv file as it can be read into a dataset, which in turn can be easily manipulated in memory to extract the info we needed...but as you can see the .pal file is in a nasty format.

Quite a bit of string processing was needed as we were after some values within the pattern section (which doesn't always appear) but we did end up managing to extract the info which meant we've managed to get all the info we required about level material assignment and solid pattern mapping.
It would have been so much easier if Bentley had given us external application developers access to the treeview objects as well...

No comments:
Post a Comment