Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
OpenBuildings | AECOsim | Speedikon
  • Product Communities
  • Building
  • OpenBuildings | AECOsim | Speedikon
  • Cancel
OpenBuildings | AECOsim | Speedikon
OpenBuildings | AECOsim | Speedikon Wiki Replacing multiple attributes in Tag Sets of multiple files
    • Building Design - Wiki
    • +OpenBuildings Designer
    • +OpenBuildings Energy Simulator
    • +GenerativeComponents
    • OpenBuildings Station Designer
    • +OpenBuildings Speedikon
    • +OpenBuildings Speedikon + Bentley Speedikon V8i
    • +Bentley Facilities Space Planner CONNECT Edition
    • -AECOsim Building Designer
      • -Annotation - AECOsim Building Designer
        • Certain annotation does not update after changing DataGroup properties
        • Change the character limit of Annotations
        • Changing units of Space Labels
        • Custom Section Sizes are Showing, but are much Larger when Placed
        • Custom Structural Section Sizes not Displaying in Program
        • DataGroup Annotation - Information Positioning Annotation
        • DataGroup Annotation for component coordinate values?
        • Error labeling Grilles and Diffusers using DataGroup Annotation
        • Escalator Annotation Cell
        • Find/Replace Text is Generating a .NET Framework Error
        • How to make complex chain with text
        • How to prevent Windows and Doors ID labels from displaying
        • How to turn on Annotation Scale
        • Replacing multiple attributes in Tag Sets of multiple files
        • Room Names/Numbers are placed very small
      • +Architectural Design - AECOsim Building Designer
      • +ASM (Analytical Space Model)
      • +Configuration - AECOsim Building Designer
      • +DataGroup System - AECOsim Building Designer
      • +Dataset and Content - AECOsim Building Designer
      • +Drawing Extraction - AECOsim Building Designer
      • +Drawing Views - AECOsim Building Designer
      • +Electrical Annotation and Design - AECOsim Building Designer
      • +Floors - AECOsim Building Designer
      • +Form Modeling - AECOsim Building Designer
      • +General - AECOsim Building Designer
      • +Grid Systems - AECOsim Building Designer
      • +HVAC Design - AECOsim Building Designer
      • +i-model - AECOsim Building Designer
      • +Import/Export - AECOsim Building Designer
      • +Installation - AECOsim Building Designer
      • +Modify - AECOsim Building Designer
      • +Platform Tools - AECOsim Building Designer
      • +Plumbing Design - AECOsim Building Designer
      • +Print/Plot - AECOsim Building Designer
      • +ProjectWise Integration - AECOsim Building Designer
      • +Settings/Attributes - AECOsim Building Designer
      • +Space Planner - AECOsim Building Designer
      • +Structural Design - AECOsim Building Designer
      • +Utilities - AECOsim Building Designer
      • +Workspace - AECOsim Building Designer
    • +iModel Plugin for Revit
    • +Social Distance Assessments
    • Working from home with OpenBuildings products
    • Working from home with Speedikon
    • +Special Interest Group (SIG) FAQs
    • +Structural Modeler_PS
    • +Configuration Explorer
    • +Legacy Products

     
     Questions about this article, topic, or product? Click here. 

    Replacing multiple attributes in Tag Sets of multiple files

      Product(s): AECOsim Building Designer
      Version(s): V8i (08.11.09.866)
      Environment: N/A
      Area: Annotation
      Subarea: Tags

    Problem

    There are many files in which some specific attributes are to be deleted and some specific attributes are to be added in some specific Tag sets. This would take a lot of time to do if it is done file by file.

    Solution

    The fasted way to do it would be to automate this process for the required files. To do this, please run AECOsim Building Designer in Administrator mode and press Alt+F11 to open the Visual Basic Editor. In there, copy one MVBA module and rename it as per your convenience (say, ReplaceTagAtt). Remove all the modules and class modules within this and save it.

    In a new module within ReplaceTagAtt.mvba, add the following code:

    'Add a new Tag
    Dim newtagsets As TagSets
    Set newtagsets = MicroStationDGN.ActiveDesignFile.TagSets
    Dim newtagset As TagSet
    'The following statement is to add a new tag set within which a new tag definition will be created
    'To create new tag definition in an existing tag set
    'change the <tagset name> with the actual tag set name and uncomment 
    'the following line and comment the next line
    'Set newtagset = newtagsets.item("<tagset name>")
    Set newtagset = newtagsets.Add("NewTagSet1")
    Dim NewTagDefs As TagDefinitions
    Set NewTagDefs = newtagset.TagDefinitions
    Dim newTagDef As TagDefinition
    Set newTagDef = NewTagDefs.Add("NewTagDef1", msdTagTypeCharacter)
    newTagDef.Prompt = "This is a new Tag"
    
    'Remove existing Tag with name NewTagDef1
    Dim TagSets As TagSets
    Dim TagSet As TagSet
    Dim TagDefs As TagDefinitions
    Dim TagDef As TagDefinition
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    
    i = 1
    k = 1
    Set TagSets = MicroStationDGN.ActiveDesignFile.TagSets
    'if a tagset name is not known use the following
    For Each Item In TagSets
        Set TagSet = TagSets.Item(i)
        Set TagDefs = TagSet.TagDefinitions
        j = TagDefs.count
        For k = 1 To j
            Set TagDef = TagDefs.Item(k)
            If TagDef.Name = "NewTagDef1" Then
                TagDefs.Remove (k)
            End If
            k = k + 1
        Next
        i = i + 1
    Next
    'if a tagset and Tag set name is known 
    'uncomment the following and put the name of the tag set in place of <TagSet Name> and 
    'comment the from Dim TagDef as... to ...i= i+1 Next
    'Set TagSet = TagSets.Item("<TagSet Name>")
    'Set TagDefs = TagSet.TagDefinitions
    'TagDefs.Remove("<TagDef Name>")

    Things to note before the code is run:

    • Two types of codes are mixed in there. Different modules can be used for each of them. Alternatively, one can be used while the other one is commented using a single apostrophe (‘) in the beginning of each line you want to change to a comment. The codes can also be used as two different sub procedures.
    • The names of the Tags Sets and Tag Definitions are hardcoded. Please use the appropriate names in place of the provided names before running.
    • A few bits of codes are commented. These can be uncommented at particular scenarios. These scenarios are also written as a comment preceding those pieces of codes. Please go through the comments before running.

    After the code is added and is running successfully, save the MVBA file. To import this code in other files, open the file, go to the Visual Basic Editor (press Alt+F11), go to Tools > References >  Browse > Browse for the MVBA file ("Files of type" should show "All Reference Files") > Select the appropriate MVBA > Click Open. That would import the MVBA file. You can then run the Macro as per your requirement.

    • Architectural Design
    • 08.11.09.866
    • Annotation
    • Tags
    • Automation
    • AECOsim Building Designer
    • Problem Solving
    • SELECTseries6
    • Share
    • History
    • More
    • Cancel
    • Satadal Dhar Created by Bentley Colleague Satadal Dhar
    • When: Fri, Aug 25 2017 12:48 AM
    • Revisions: 1
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2023 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies