Removing All Object Data from Selected Cells in VBA


  
 Applies To 
  
 Product(s):MicroStation
 Version(s):V8i
 Environment: Windows 7 32 bit,Windows 7 64 bit
 Area: Programming
 Subarea: VBA
 Original Author:Tristan Anderson, Bentley Technical Support Group
  

Background Information

Property data by specifications contain values that should not be displayed in a drawing, or it should generally make all technical data of certain cells disappear.

Steps

Below is an example in which all property data is hidden in cells which were selected in advance.

The example examines only the previously selected cells or dummy cells on the .GetSelected method from the attribute .IsHidden = True.

The number of attribute data is counted and displayed in the message center at the end. If nothing is selected a message will appear.

Sub TagsSelOff()
Dim Ee As ElementEnumerator
Dim found As Boolean
Dim otags() As TagElement
Dim count As Long
count = 0
Set Ee = ActiveModelReference.GetSelectedElements
Do While Ee.MoveNext
    found = True
    If Ee.Current.IsCellElement Or Ee.Current.IsSharedCellElement Then
        If Ee.Current.HasAnyTags Then
            otags = Ee.Current.GetTags
            For i = LBound(otags) To UBound(otags)
              If otags(i).IsHidden = False Then
                count = count + 1
                otags(i).IsHidden = True
                otags(i).Rewrite
              End If
            Next
        End If
    End If
Loop
If Not found Then
    MessageCenter.AddMessage "No elected Members", , msdMessageCenterPriorityError
Else
    MessageCenter.AddMessage "There were " + str(count) + " pieces of attribute data removed", , msdMessageCenterPriorityInfo
End If
End Sub

See Also

Searching and Evaluating Data in a drawing with VBA Part 10 - Reading Attribute Data