Hi there,
I am currently trying to edit the display style of an element through a program (VBA).
This is needed to change the display style of all cells within a cell library by program.
Is there a way to get the display style changed in VBA?
Unfortunately I was not able to find something useful in the documentation ...
Hi,
VBA is very poor tool to play with these tiny details, because VBA API exposes only a part (a fraction in my opinion :-) of MicroStation capabilities. Fortunately MDL would help you, there is VBA wrapper for mdlElement_setDisplayStyle function available, which from its description does what you need.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Hi Jan,
thanks for this!
This is crazy! I have searched through the MDL Function Reference document but there is no entry for "mdlElement_setDisplayStyle" ... maybe my MDL Function Reference is out of date ...
Unknown said: I have searched through the MDL Function Reference document but there is no entry for "mdlElement_setDisplayStyle" ... maybe my MDL Function Reference is out of date
That function was introduced with MicroStation version 08.11.09
Regards, Jon Summers LA Solutions
The problem is not in outdated MDL documentation but that your SDK is probably not the same version as your MicroStation. From your screen it's visible you use MicroStation V8i (SELECTseries 3). I checked MicroStation SDK 08.11.09.292, which I think was the version released for the first V8i SS3 MicroStation, and mdlElement_setDisplayStyle is there.
So check what version of SDK do you use and if required, download the newer versions.
Unknown said:There is VBA wrapper for mdlElement_setDisplayStyle function available, which from its description does what you need
mdlElement_setDisplayStyle takes as its second argument Int32 styleIndex. However, I can't find anywhere what values styleIndex can take. How does one discover what display styles are defined for the active model?
I have checked this now - you are right! My SDK is very out of date ...
I will download the latest SDK & Microstation to be up-to-date and have a try then ...
Unknown said:mdlElement_setDisplayStyle takes as its second argument Int32 styleIndex. However, I can't find anywhere what values styleIndex can take. How does one discover what display styles are defined for the active model?
Hmm, good question ... and I have no idea :-(
It looks like there is no way in MDL or VBA to receive a list of available display styles. Or did I miss anything?
The MicroStationAPI provides the DisplayStyle Struct. It includes this method...
As usual with the MicroStationAPI documentation, there is no hint how we can use the DisplayStyle class. As it's C++, it doesn't help quasi_modo because VBA can't talk to C++.
I have done some tests yesterday after installing the latest versions of MS and SDK.
I used "mdlElement_getDisplayStyle" to analyse the display style of all elements within the cell library. The result was always "-1" which means that no display style is set.
Then I manually entered the display style "wireframe" for some elements and ran the code again. The result still was "-1" ...
Here is the code I used:
Do While oScanEnumerator.MoveNext Set oElement = oScanEnumerator.Current If oElement.IsGraphical = True Then ret = mdlElement_getDisplayStyle(oElement.MdlElementDescrP) Debug.Print ret End If Loop
Is there something wrong with my code or does "mdlElement_getDisplayStyle" not do the trick?
Unknown said: If oElement.IsGraphical = True Then ret = mdlElement_getDisplayStyle(oElement.MdlElementDescrP) Debug.Print ret End If
That MDL function wants an MSElement pointer, not an MSElementDescr pointer. You need to get an MDL MSElement from that descriptor to pass to the MDL function. Try something like this …
Declare Function ElmdscrAccessor_getMSElement _ Lib "stdmdlaccessor.dll" ( _ ByVal ElementDescr As Long) As Long
If oElement.IsGraphical Then Dim address As Long address = ElmdscrAccessor_getMSElement ( _ oElement.MdlElementDescrP) ret = mdlElement_getDisplayStyle (address) Debug.Print ret End If