Background Information
In the application of complex cells, factual data that is already attached and fit with default values is common. These default values are specified when creating the cells, and they may no longer be the current values. You can now use VBA to clean up property data values by searching for sepcific factual data and adjusting the values. The attribute data itself will not be deleted, only the contents will be cleared.
Here is a simple example that makes a selection of all active model cells which are then checked to see whether or not factual data is available. If so, it reads and checks the name.
If the correct factual data is found, the values are reset, and the values are added to an empty string:
Option Explicit Sub tag_clear() Dim Sc As New ElementScanCriteria Dim Ee As ElementEnumerator Dim otags() As TagElement Dim i As Integer ' Looking for cells: Sc.ExcludeAllTypes Sc.IncludeType msdElementTypeSharedCell 'Pseudo-cells (Type 35) Sc.IncludeType msdElementTypeCellHeader 'Type 2 Cells Set Ee = ActiveModelReference.Scan(Sc) ' Check each cell for factual data ' If factual data was found and the name matches, clean it up: Do While Ee.MoveNext If Ee.Current.HasAnyTags Then otags = Ee.Current.GetTags For i = LBound(otags) To UBound(otags) If otags(i).TagSetName = "tagsetname" Then ' Example names tagset If otags(i).TagDefinitionName = "tagname" Then ' Example names tag otags(i).Value = "" otags(i).Rewrite End If End If Next End If Loop End Sub
In the above example, the name of the attribute data-set and attribute data are fixed. In this way, this VBA routine can be used in batch mode, but would add several different names each time a change in the program is made.
Therefore, to be able to apply the routine a little bit easier for differenet names, here is an extended example which the routine must be given names to be tested as a parameter when running it. The call parameters are found in the Key-in arguments that stop here in the components and are stored in the array sNames. A separator space is assumed.
If 0 or only 1 parameter has been given, it stops the routine with a message in the message center.
Option Explicit Sub tag_clear() Dim Sc As New ElementScanCriteria Dim Ee As ElementEnumerator Dim otags() As TagElement Dim i As Integer Dim sNames() As String sNames = Split(KeyinArguments, " ") If UBound(sNames) <= 0 Then ' there were only 1 or no given parameters MessageCenter.AddMessage "Es fehlen Parameter zum Bereinigen der Sachdaten", , msdMessageCenterPriorityError Exit Sub ' end of the routine End If ' Looking for cells: Sc.ExcludeAllTypes Sc.IncludeType msdElementTypeSharedCell 'Pseudo-cells (Type 35) Sc.IncludeType msdElementTypeCellHeader 'Type 2 Cells Set Ee = ActiveModelReference.Scan(Sc) ' Check each cell on factual data ' If factual information is available and the name matches, clean it up: Do While Ee.MoveNext If Ee.Current.HasAnyTags Then otags = Ee.Current.GetTags For i = LBound(otags) To UBound(otags) If otags(i).TagSetName = Trim(sNames(0)) Then ' Example names tagset If otags(i).TagDefinitionName = Trim(sNames(1)) Then ' Example names tag otags(i).Value = "" otags(i).Rewrite End If End If Next End If Loop End Sub
Calling this routine must be done with at least 2 parameters, the first of which is the name of the attribute data set and the second is assumed to be the name of the property date.
The following call can be used to open the VBA routine in order to achieve the same result as the first example:
vba run tag_clear tagsetname tagname