Saved view is not restored in 64 bit Connect Edition

Hi all,

I am quite new to Microstation. We have some Macros running well on 32 bit Microstation version 08.11.09.089. When we change to use 64 bit MicroStation Connect version 10.12.00.40, there are some issues, some of which have been fixed by adding PtrSafe and changing Long type to LongPrt in declare statements. But I am not able figure out how to fix the following issue.

Before running the Macro, the view is like attached image 1 (before process). After running the Macro, it shrinks and zoom way out as shown in image 2 (after process). Please note the view is supposed to be the same before and after process as it works that way in 32 bit MicroStation. The view change happens when calling the following sub. Specifically, it happens after executing this line: vw.ApplySavedViewElement SV, msdCopyViewPortApplySize. When I debug this Macro on both 32 bit and 64 bit MicroStation, I notice some values for SV properties are different between this two version. Other variables have same values. I am not sure if it's related to the issue and have no idea how to fix. Any help is greatly appreciated.

Sub RestoreView(strName As String, viewNumber As Long)
Dim vw As view
Dim SV As SavedViewElement

Set SV = ActiveDesignFile.FindSavedView(strName) ' Not using optional arguments

If Not SV Is Nothing Then
Set vw = ActiveDesignFile.Views(viewNumber)
vw.ApplySavedViewElement SV, msdCopyViewPortApplySize
End If
End Sub

  • I created a SaveView named MySV in my DGN file and add vw.Redraw in your original code.  Then the code works well in my MSCE U11.

    Sub RestoreView(strName As String, viewNumber As Long)
        Dim vw As View
        Dim SV As SavedViewElement
        
        Set SV = ActiveDesignFile.FindSavedView(strName) ' Not using optional arguments
        
        If Not SV Is Nothing Then
            Set vw = ActiveDesignFile.Views(viewNumber)
            vw.ApplySavedViewElement SV, msdCopyViewPortApplySize
            vw.Redraw
        End If
    End Sub
    
    Sub Main()
       RestoreView "MySV", 1
    End Sub
    



  • Thanks for the reply. Were you able to see the same issue I have before adding vw.Redraw?  I added vw.Redraw to my code, but still has same issue. When I debug, I notice vw.Redraw doesn't get executed. After execution of vw.ApplySavedViewElement SV, msdCopyViewPortApplySize, it exits the sub, didn't go to the line vw.Redraw. I am wondering if this is related to SaveView function, but it's just my guess. Can you see any issue with the following code? 

    Function SaveView()
    Dim SV As SavedViewElement
    
        Set SV = ActiveDesignFile.FindSavedView("E3Temp")
        If Not SV Is Nothing Then
          SV.IsLocked = False
          ActiveModelReference.RemoveElement SV
        End If
    
        Set SV = CreateSavedViewElement(1, "E3Temp", "Temp view")
        ActiveModelReference.AddElement SV
    End Function

  • I can run your code smoothly in my MSCE-U13 without any issue. The result is as below:



  • Thanks. So back to original issue, what could be the possible cause to make the window shrink after running macro? since I have very little knowledge on MS and vba and no idea what cause that issue. Please note that the same code runs well without this issue in 32 bit MS. This only happens in 64 bit MS.

  • After changing this line

    vw.ApplySavedViewElement SV, msdCopyViewPortApplySize

    to vw.ApplySavedViewElement SV, msdCopyViewPortKeepCurrent

    It seems the issue is fixed. The window is not shrinking anymore. Still not sure why.

  • Although the window is not shrinking, my colleague found some other issue after this code change. Here is the description of issue after running the macro:

    " It looks like it is inverting the on/off layers but the level display dialog is not updating.  The display is off for the rooms I grouped but other elements seem to display on that layer.  Layers all seem to turn on and screen does not refresh.".

  • After putting together the example images I realized it looks like the saved view is not saving the correct levels displayed and when restored is not refreshing the level display dialog properly. The temporary saved view is also not being deleted after the command executes which could cause issue if run more than once. Microstation will error if trying to save a view with the same name as an existing name. After I apply the E3temp view manually the layers all display correctly but the layers are not the ones that should have been saved, they are the layers that the design file was last saved with.  


    It appears the layers displayed in the saved view are the layers that were on and off when the Design file was saved.  These are the layers that are on/off when you initially open the design file and not the ones that were on/off at the time of the program execution.  The save view option in the application must be saving the view layers with a wrong option picking the design layers rather than the actual layers on/off at the time the program is executed.  That doesn't explain why the Level display dialog does not display the layers correctly.  It shows the layers that should be on/off at program execution.  If you restore the E3temp view that still exists in the file after program executes the level display is correct but not the ones that should have been saved (A-AREA-ROOM and A-AREA-IDEN only.


    Layers displayed at the time of execution.

    Layers actually displayed and indicated layer display after program executes.  Original file - save - settings layers displayed but level display indicates only the two layers are on as were at program execution.

    Layers actually displayed at the end of the program execution. (after restoring the E3temp saved view manually) This is how the design file layers were last originally saved ( file - save settings - initial file open layers).

    I hope this helps in the troubleshooting.

    Thank You, 
    _________________________________

    Mark T. Itil, Computer-Aided Design Supervisor

    Facilities & Operations Information Services (FOIS)

    Mark Itil

    University of Michigan

    CAD Manager and UofM Site administrator

  • Hi,

    I can confirm this is a regression issue from V8i. 
    In CONNECT Edition (tested with Upd 13)  the level display settings will be incorrect, if the level settings from the saved view are different to the level settings from the active design file.
    This means after applying the VBA method ApplySavedViewElement the elements are displayed with the settings from the active DGN file and the level display dialog are showing the level settings from the applied saved view.

    We have filed the Defect # 1063344 to address this issue.

    Best regards,

    Artur