Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
OpenBuildings | AECOsim | Speedikon
  • Product Communities
  • Building
  • OpenBuildings | AECOsim | Speedikon
  • More
  • Cancel
OpenBuildings | AECOsim | Speedikon
OpenBuildings | AECOsim | Speedikon Wiki DataGroup Annotation Cells - Custom DataGroup Information Labels Using VBA
    • Sign in
    • Building Design - Wiki
    • -OpenBuildings Designer
      • +What's New
      • FAQ - OpenBuildings Designer CONNECT Edition
      • Released Versions - OpenBuildings Designer
      • IFC4 Self-certification
      • +Installation - OpenBuildings Designer
      • +Migration - Upgrading from earlier versions
      • +Configuration - OpenBuildings Designer
      • +General - OpenBuildings Designer
      • +User Interface - OpenBuildings Designer
      • +Architectural Design - OpenBuildings Designer
      • +Structural Design - OpenBuildings Designer
      • +ProStructures Interoperability - OpenBuildings Designer
      • +Electrical Annotation and Design - OpenBuildings Designer
      • +Datasets and Content - OpenBuildings Designer
      • -DataGroup System - OpenBuildings Designer
        • "Cannot find template" message when trying to create a DataGroup report.
        • Adding a Type to a DataGroup Catalog Filter
        • Custom Curtain Walls do not display in the list during placement
        • DataGroup Annotation Cells - Custom DataGroup Information Labels Using VBA
        • DataGroup Annotation Cells - Where should their library be located?
        • DataGroup Keyins
        • DataGroup Properties cannot be edited
        • DataGroup Validator "Duplicate Catalog Type" error
        • Editing Catalog Item value lists
        • Error message when attempting to create a new Schedule
        • For existing member OBD does not allow to add value to those properties which have been added recently.
        • How to create custom Catalog Properties and add them to Catalog Items
        • Match Catalog Item Element Properties
        • Remove All Building Data - TFREMOVE
        • Remove Instance Data
        • Use Live Hyperlinks in Catalog Properties
        • Whenever I place custom DataGroup wall items, why does the width and height of wall default to "0" ?
      • +Floor Management - OpenBuildings Designer
      • +Grid Systems - OpenBuildings Designer
      • +Drawing Views - OpenBuildings Designer
      • +Annotation - OpenBuildings Designer
      • +Import/Export- OpenBuildings Designer
      • +ProjectWise Integration - OpenBuildings Designer
      • +Customization - OpenBuildings
      • +Platform Tools - OpenBuildings Designer
      • +Plumbing Design
      • Electrical Designer
      • +Learning Tips
      • +HVAC Design - OpenBuildings Designer
      • +OpenBuildings Designer Accreditation Program
    • +OpenBuildings Energy Simulator
    • +GenerativeComponents
    • OpenBuildings Station Designer
    • +OpenBuildings Speedikon + Bentley Speedikon V8i
    • +Bentley Facilities Space Planner CONNECT Edition
    • +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. 

    DataGroup Annotation Cells - Custom DataGroup Information Labels Using VBA

      Product(s): OpenBuildings Designer (and AECOsim Building Designer)
      Version(s): CONNECT Edition and V8i
      Environment:  N/A
      Area:  Annotation
      Subarea:  DataGroup Annotation

    In the Manage DataGroup Annotation Cells dialog > DataGroup Information section you select and format the DataGroup Information that you would like to see in your DataGroup Annotation Cells.

    So what if the format you want is not available or, if using an available format with values of variable length with following dumb text, results in uneven spacing or overlapping between the variable DataGroup Information and the dumb text?

    Take a look at the Custom option:

    What goes in these blank fields is fairly obvious once you get to grips with the basics of the VBA Editor:

    In this example, and it makes more sense backwards:

    • Function Name = the sub-routine that actually does the work, Door_FireRating
    • Module Name = the name of the module containing the Function: DoorLabels
    • Project Name = the name of the mvba file containing the module: MT_DGinfo (without the file extension)

    Click OK and use the Place Text button to add the text to your DataGroup Annotation Cell. Ensure that the Length is sufficient to contain the DataGroup value and any surrounding text.

    So what is in the Function?

    In this example I want to place a Label that has a prefix, 'FR |', the Fire rating of a door from the DataGroup, followed by a suffix.

    The VBA code is:

    Public Sub Door_FireRating()
        Dim DoorFR As String
        Dim DoorFRLabel As String
       
        DoorFR = KeyinArguments
        DoorFRLabel = "FR | " + DoorFR + " suffix"
        KeyinArguments = DoorFRLabel
    End Sub

    Line 1

    Starts Public Sub and names Door_FireRating() the function.

    Lines 2 and 3

    Declares Dim the variables DoorFR to be used and their type As String.

    Line 6

    Set variable DoorFR equal to KeyinArguments. KeyinArguements gathers the value from the DataGroup.

    Line 7

    Sets DoorFRLabel equal to the concatenation of the plain text contained within the quotation marks "FR | " and the value set for DoorFR into a string to be used in Line 8.

    Note that the quotation marks need to contain any spaces you want between words in the text string that is finally output. Here there are spaces either side of the pipe character and a space before suffix.

    The + character is the concatenation operator that joins them all together.

    Line 8

    Sets KeyinArgument equal to the string concatenated by Line 7.

    Line 9

    Closes End Sub the function.

    The .MVBA file containg this code needs to be located in your daatset VBA folder to be found by the Auto Annotation process.

    Other examples can be found in DG_Annotation.mvba located in the delivered dataset VBA folder.

    One warning: because the VBA does have to run for each piece of annotation that uses it, you could see a performance hit in Dynamic Views that contain a large number of annotations that reference a vba.

    The Result:

    '2 Hr. Fire rating' and '3 Hr. Fire rating' are values gathered from the NM Dataset. These values will vary between datasets.

    • OpenBuildings Designer
    • VBA
    • Drawing Views
    • DataGroup Annotation Cells
    • AECOsim Building Designer
    • Share
    • History
    • More
    • Cancel
    • Marc Thomas Created by Bentley Colleague Marc Thomas
    • When: Thu, Nov 28 2013 2:17 PM
    • Marc Thomas Last revision by Bentley Colleague Marc Thomas
    • When: Thu, Sep 9 2021 5:51 AM
    • Revisions: 7
    • 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

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