VBA Batch process Turning reference levels off

VBA Batch process

Wrote this vba script and using it on 1 file works with just the vba,

however when I ran it using several sheets using the batch process it will go from sheet to sheet and I guess it applies the command however it will not save the settings, and if I try just 1 sheet on the batch process it will turn off the levels but will not allow me to save the settings.  Even if I manually save settings when I log back into the drawings the levels are on...  if I just manually turn a referenced level off and save the settings it will keep it even after exiting and going back into the drawing.  this is the script,,, any suggestions on what could be wrong?
thanks

Public Sub LevelOff()

Dim att As Attachment, filename As String

filename = "D468620-Topo_05.dgn"

For Each att In ActiveModelReference.Attachments

  If StrComp(att.AttachName, filename, vbTextCompare) = 0 Then

   att.Levels("DEC_Topo_Riser").IsDisplayed = False

   att.Levels("Aerial Survey_Control Points").IsDisplayed = False

   att.Levels("Topo_Vegetation").IsDisplayed = False

   att.Levels("Topo_Roadway Notes").IsDisplayed = False

   att.Levels("Topo_NonHighway Improvements").IsDisplayed = False

   att.Levels("Design_EX_Roadway Notes").IsDisplayed = False

   att.Rewrite

  End If

Next att

End Sub

 

 

Parents
  • Use this command:

    CadInputQueue.SendCommand "Save Settings"

  • Hi,

    If you're going through Microstation, the command would be:

    CadInputQueue.SendCommand "FileDesign"

    If you are using vba, you might as well use the vba command which is

    SaveSettings

    That's hard!

    --Robert

  • Robert,

    Using this example and solution of SaveSettings will not hold the save settings in the file after the vba is run, even a manual save settings does not work.  I've tried running it both in MicroStation batch process and running just the vba.

    Any clues?

  • Hi,

    This is one of my older routines...  I see a AttachedFile.Levels.Rewrite command.  I wonder if this is the issue.  Also, I though of ActiveDesignFile.Save as another possibility.

    --Robert

    Sub AllReferenceLevelsOn()
        Dim Level As Level
        Dim Attachment As Attachment
        Dim I As Integer

        'Each Attachment
        For Each Attachment In ActiveModelReference.Attachments
           DisplayLevels Attachment
        Next
        
        RedrawAllViews
    End Sub

    Private Sub DisplayLevels(AttachedFile As Attachment)
        Dim Level As Level
        Dim Attachment As Attachment
        Dim I As Integer
        
        'Turn on all levels in this attachment
        If Not (AttachedFile.IsMissingFile) Then
            For Each Level In AttachedFile.Levels
                If Not (Level.IsDisplayed) Then Level.IsDisplayed = True
                If Level.IsFrozen Then Level.IsFrozen = False
            Next
            For I = 1 To 8
                If ActiveDesignFile.Views(I).IsOpen Then
                    For Each Level In AttachedFile.Levels
                        If Not (Level.IsDisplayedInView(ActiveDesignFile.Views(I))) Then Level.IsDisplayedInView(ActiveDesignFile.Views(I)) = True
                    Next
                End If
            Next
            AttachedFile.Levels.Rewrite
        End If
        
        'Do it again for each nested reference in this attachment
        For Each Attachment In AttachedFile.Attachments
            DisplayLevels Attachment
        Next
    End Sub


Reply
  • Hi,

    This is one of my older routines...  I see a AttachedFile.Levels.Rewrite command.  I wonder if this is the issue.  Also, I though of ActiveDesignFile.Save as another possibility.

    --Robert

    Sub AllReferenceLevelsOn()
        Dim Level As Level
        Dim Attachment As Attachment
        Dim I As Integer

        'Each Attachment
        For Each Attachment In ActiveModelReference.Attachments
           DisplayLevels Attachment
        Next
        
        RedrawAllViews
    End Sub

    Private Sub DisplayLevels(AttachedFile As Attachment)
        Dim Level As Level
        Dim Attachment As Attachment
        Dim I As Integer
        
        'Turn on all levels in this attachment
        If Not (AttachedFile.IsMissingFile) Then
            For Each Level In AttachedFile.Levels
                If Not (Level.IsDisplayed) Then Level.IsDisplayed = True
                If Level.IsFrozen Then Level.IsFrozen = False
            Next
            For I = 1 To 8
                If ActiveDesignFile.Views(I).IsOpen Then
                    For Each Level In AttachedFile.Levels
                        If Not (Level.IsDisplayedInView(ActiveDesignFile.Views(I))) Then Level.IsDisplayedInView(ActiveDesignFile.Views(I)) = True
                    Next
                End If
            Next
            AttachedFile.Levels.Rewrite
        End If
        
        'Do it again for each nested reference in this attachment
        For Each Attachment In AttachedFile.Attachments
            DisplayLevels Attachment
        Next
    End Sub


Children
No Data