Check For Existence of View Group using VBA

Hello MicroStation Programming Community,

How would one check for the existence of a View Group within the active Design File using VBA code? I can't seem to find examples of this. Looking to delete the View Group if it exists.

Thanks!

Parents
  • Hi Matt,

    please respect the best practices and always specify the used product and its exact version. Even though VBA is stable API, not too much different in different products and versions, they are mandatory information that should be shared always.

    How would one check for the existence of a View Group within the active Design File using VBA code?

    See ViewGroups object, which is a collection containing ViewGroup objects.

    Regards,

      Jan

  • Hello Jan,

    Thanks for your reply. I am attempting to develop a VBA app for OpenRoads Designer CE 2021 Release 2 (Version 10.10.21.40). I checked the VBA Help. However, I cannot find any examples of ViewGroups collection. Therefore, I don't know how to structure the code to cycle through View Groups.

    I've tried this with no luck:

    ' Declare variables.
    Dim oViewGroup As MicroStationDGN.ViewGroup
    
    ' Loop through each View Group.
    For Each oViewGroup In ActiveDesignFile.ViewGroups
        ' View Group Name is "Multi-Model Views".
        If (oViewGroup.Name = "Multi-Model Views") Then
            ' Run command to delete "Multi-Model Views" View Group.
            CadInputQueue.SendKeyin "viewgroup delete " & Chr(34) & "Multi-Model Views" & Chr(34)
        End If
    Next

    ProjectWise Explorer CONNECT Edition, Version 10.00.03.453

    ProjectWise Drive, Version 2022.1.328

    OpenRoads Designer CONNECT Edition, Version 10.09.00.91

    OpenRoads Designer CE 202 Release 2, Version 10.10.21.4

    Power GEOPAK V8i (SELECTseries 10), Version 08.11.09.918

Reply
  • Hello Jan,

    Thanks for your reply. I am attempting to develop a VBA app for OpenRoads Designer CE 2021 Release 2 (Version 10.10.21.40). I checked the VBA Help. However, I cannot find any examples of ViewGroups collection. Therefore, I don't know how to structure the code to cycle through View Groups.

    I've tried this with no luck:

    ' Declare variables.
    Dim oViewGroup As MicroStationDGN.ViewGroup
    
    ' Loop through each View Group.
    For Each oViewGroup In ActiveDesignFile.ViewGroups
        ' View Group Name is "Multi-Model Views".
        If (oViewGroup.Name = "Multi-Model Views") Then
            ' Run command to delete "Multi-Model Views" View Group.
            CadInputQueue.SendKeyin "viewgroup delete " & Chr(34) & "Multi-Model Views" & Chr(34)
        End If
    Next

    ProjectWise Explorer CONNECT Edition, Version 10.00.03.453

    ProjectWise Drive, Version 2022.1.328

    OpenRoads Designer CONNECT Edition, Version 10.09.00.91

    OpenRoads Designer CE 202 Release 2, Version 10.10.21.4

    Power GEOPAK V8i (SELECTseries 10), Version 08.11.09.918

Children