Updating overrides with VBA - changes not persisting when saved.

I have developed a macro to report the override and display settings on levels in an active drawing and it's attachments(including one level of subreferences). Outside of microstation (i.e. in excel) I check the settings and highlight any required changes. A second macro is then used to implement any necessary changes back into the drawing. This part is working successfully and the changes are made, and amended setttings are evident in the active view and in the level manager etc. However the changes are not saved when the drawing is closed, despite liberal use of 'levels.rewrite' and 'RewriteLevels' in the updating macro. All the required changes can be implemented manually, and persist when the drawing is saved. Although I have found similar problems discussed, for what would seem to be a common task, and tried various suggestions, the problem persists. I would welcome any suggestions as what I might  have missed. Thanks.

Parents
  • This is interesting, I am having the same problem with changes being made by VBA but these not being saved.
    Microstation 10.15.02.11

    If i use
    oLevel.OverrideColor = 4
    oLevel.OverrideLineStyle = ActiveDesignFile.LineStyles(4)
    oLevel.OverrideLineWeight = iWeight

    then
    ActiveDesignFile.Levels.Rewrite
    ActiveDesignFile.RewriteLevels
    MicroStationDGN.RedrawAllViews
    MicroStationDGN.SaveSettings

    to try desperately to save them, close the file and reopen they all return to where they were
    I have had to revert to using CadInputQueue.SendKeyin .....
    because that actually works

  • Hi Ben,

    I have tested to modify the OverrideColor using VBA and did not notice a problem (used code example below ).
    But any V8 DGN file has a setting refleveloverrides to allow or permit permanent changes to the reference level overrides.

    You may want to check a dgn using the keyin "set refleveloverrides", this returns the value On or Off.
    If this is set to Off, changes are lost with reopening file.
    To enable this, the keyin "set refleveloverrides on" can be used (save settings  is also required) 

    If this does not help, please provide a full code example - thanks.

    Here the simple code example I have used for testing with sample dgn file:

    Sub reflevelsoverridetest()
    Dim oLvs As levels
    Dim oLv As level
    Dim oAtt As Attachment
    Dim i As Long
    
    For Each oAtt In ActiveModelReference.Attachments
        Set oLvs = oAtt.levels
        i = 0
        For Each oLv In oLvs
            oLv.OverrideColor = i Mod 255
            i = i + 1
        Next
        oLvs.Rewrite
    Next
    End Sub
    

    Best regards,

    Artur

Reply
  • Hi Ben,

    I have tested to modify the OverrideColor using VBA and did not notice a problem (used code example below ).
    But any V8 DGN file has a setting refleveloverrides to allow or permit permanent changes to the reference level overrides.

    You may want to check a dgn using the keyin "set refleveloverrides", this returns the value On or Off.
    If this is set to Off, changes are lost with reopening file.
    To enable this, the keyin "set refleveloverrides on" can be used (save settings  is also required) 

    If this does not help, please provide a full code example - thanks.

    Here the simple code example I have used for testing with sample dgn file:

    Sub reflevelsoverridetest()
    Dim oLvs As levels
    Dim oLv As level
    Dim oAtt As Attachment
    Dim i As Long
    
    For Each oAtt In ActiveModelReference.Attachments
        Set oLvs = oAtt.levels
        i = 0
        For Each oLv In oLvs
            oLv.OverrideColor = i Mod 255
            i = i + 1
        Next
        oLvs.Rewrite
    Next
    End Sub
    

    Best regards,

    Artur

Children
No Data