Public Const Tag_Set_Name = "testTagSetName" Public Function GetTagSet(ByVal TagName As String) As TagSet Dim strName As String Dim oTagSets As TagSets strName = Tag_Set_Name Set oTagSets = ActiveDesignFile.TagSets On Error Resume Next Set GetTagSet = oTagSets(strName) If GetTagSet Is Nothing Then Dim td As TagDefinition Set GetTagSet = oTagSets.Add(strName) Set td = GetTagSet.TagDefinitions.Add(TagName, msdTagTypeCharacter) td.IsConstant = True End If End Function Public Sub TagMyElement(oElement As Element, ByVal TagName As String, ByVal TagValue As String) 'TAG THE ELEMENT'GET TAG SET, ADD TO TAG SET IF NOT THERE Dim ts As TagSet Set ts = GetTagSet(TagName)'GET THE TAG DEFS IN THE TAG SET Dim tagDefs As TagDefinitions Set tagDefs = ts.TagDefinitions'LOOK FOR OUR TAG NAME Dim tagDef As TagDefinition Set tagDef = tagDefs.Find(TagName)'CREATE IT IF IT DOES NOT EXIST If tagDef Is Nothing Then Set tagDef = tagDefs.Add(TagName, msdTagTypeCharacter) tagDef.IsConstant = True End If'CREATE A TAG ELEMENT Dim eleTag As TagElement Set eleTag = oElement.AddTag(tagDef)'SET ITS VALUE eleTag.Value = TagValue'MAKES SURE IT'S HIDDEN eleTag.IsHidden = True'MAKE SURE IT GOT WRITTEN eleTag.Rewrite End Sub
[View:/cfs-file/__key/communityserver-discussions-components-files/343173/Default.mvba:940:0]
[View:/cfs-file/__key/communityserver-discussions-components-files/343173/tagtest.dgn:940:0]