Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
MicroStation
  • Product Communities
MicroStation
MicroStation Wiki Searching and Evaluating Data in a drawing with VBA: Part 10 - Reading Attribute Data
    • Sign In

    • -MicroStation Wiki
      • +Learning Tips
      • -MicroStation
        • +3D Printing - MicroStation
        • +Animation - MicroStation
        • +Archive / Backup - MicroStation
        • +Base Geometry - MicroStation
        • +Batch Processing - MicroStation
        • +CONNECT Advisor - MicroStation
        • CONNECT Integration - MicroStation
        • +CONNECTION Client
        • +Cells - MicroStation
        • +Change Tracking - MicroStation
        • +Configuration - MicroStation
        • +Coordinate Systems - MicroStation
        • +Curves - MicroStation
        • +Custom Linestyles - MicroStation
        • +DGN - MicroStation
        • +DWG - MicroStation
        • +Database - MicroStation
        • +Detailing Symbols - MicroStation
        • +Dimensions - MicroStation
        • +Documentation & Help - MicroStation
        • +Drawing Aids - MicroStation
        • +Exception - MicroStation
        • +FAQ - MicroStation
        • +Feature Based Solids Modeling - MicroStation
        • +File Access - MicroStation
        • +GUI - MicroStation
        • +General - MicroStation
        • +Graphics Display - MicroStation
        • +Groups - MicroStation
        • +Hardware / Input Devices - MicroStation
        • +Import/Export - MicroStation
        • +Installation - MicroStation
        • +Interchange - MicroStation
        • +Interference - MicroStation
        • +Internationalization - MicroStation
        • +Levels - MicroStation
        • +Licensing - MicroStation
        • +Manipulation - MicroStation
        • +Markup / Redline - MicroStation
        • +Measure - MicroStation
        • +Mesh - MicroStation
        • +Models - MicroStation
        • +Multi-Lines - MicroStation
        • +OLE - MicroStation
        • +Other - MicroStation
        • +Parametrics - MicroStation
        • +Patterning - MicroStation
        • +Point Cloud - MicroStation
        • +Printing - MicroStation
        • -Programming - MicroStation
          • +General - Programming - MicroStation
          • +Macro Recorder - Programming - MicroStation
          • +MDL - Programming - MicroStation
          • -VBA - Programming - MicroStation
            • Automatic execution when opening or closing drawings
            • Automatic Subroutine Loading
            • Automatically generate plots with VBA
            • Avoiding Inaccuracies in VBA Methods - .FacetSolidAsShapes for SmartSolids
            • Bring All Text to a New Level with VBA
            • Browsing References for Specific Items
            • Calculating the range of Rotated Cells
            • Changing Colors of Levels in VBA
            • Changing display priority for references
            • Changing Element Colors from RGB to Indexed Color
            • Changing Layer Colors from RGB to an Indexed Color
            • Changing the Alignment of All Texts with VBA
            • Changing the display order of elements
            • Changing the presentation order of Layers
            • Changing the Transparency Settings of Levels with VBA
            • Cleaning Property Data with VBA
            • COM Server error
            • Create Engineering (HTML) Links in VBA
            • Creating Coordinates as Latitude and Longitude using VBA Lines
            • Creating VBA Levels - 'Level name is duplicate'
            • Deleting Lines of Length 0 Using VBA
            • Errors Attempting to Load VBA Projects
            • Errors while attempting to load VBA
            • Exporting the RGB Values of the Color Table to a Text File in VBA
            • Forms in an .mvba do not open some pc's
            • How to read the RGB values of the Attached Color Table
            • Keyin to load the VBA Project Manager in MicroStation Connect
            • Leaving a VBA Tools Dialog Box Open
            • Linking to VBA Elements with User Attributes
            • New Text Font Cannot be Assigned
            • Placing annotation cells with VBA
            • Print Organizer Control with VBA
            • Printing all Sheet Models to PDF Using VBA
            • Reading the Length of All Arcs
            • Removing All Object Data from Selected Cells in VBA
            • Replacing Points with Circles Using VBA
            • Replacing Text with VBA - Part 1: Introduction
            • Replacing Text with VBA - Part 2: Complex Structures
            • Running a VBA Routine by Keyin
            • -Searching and Evaluating Data in a drawing with VBA
              • Searching and Evaluating Data in a drawing with VBA: Part 1 - Preparation.
              • Searching and Evaluating Data in a drawing with VBA: Part 10 - Reading Attribute Data
              • Searching and Evaluating Data in a drawing with VBA: Part 2 - Reading properties of Elements
              • Searching and Evaluating Data in a drawing with VBA: Part 3 - Reading Properties of Elements and Exporting to a Text File
              • Searching and Evaluating Data in a drawing with VBA: Part 4 - Saving data to a formatted CSV file
              • Searching and Evaluating Data in a drawing with VBA: Part 5 - Reading More General Properties of Elements
              • Searching and Evaluating Data in a drawing with VBA: Part 6 - Evaluating Simple Complex Elements
              • Searching and Evaluating Data in a drawing with VBA: Part 7 - Evaluating General Complex Elements
              • Searching and Evaluating Data in a drawing with VBA: Part 8 - Evaluating Nested Complex Elements
              • Searching and Evaluating Data in a drawing with VBA: Part 9 - PropertyHandler for Element Analysis
            • Searching and Selecting Text Fields with VBA
            • Updating sequence control with VBA
            • Using a VBA Macro
            • Using the VBA object PropertyHandler to change the Element Information
            • VBA - Interface Error: 0x80040502
            • VBA Error in Execution: Project or Library Not Found
            • What are these "Default.mvba" files?
        • +Project Navigation - MicroStation
        • +Properties - MicroStation
        • +RSS Feeds - MicroStation
        • +Reference - MicroStation
        • +Security - MicroStation
        • +Selection - MicroStation
        • +Settings - MicroStation
        • +Sheet Composition - MicroStation
        • +Solids - MicroStation
        • +Standards - MicroStation
        • +Surfaces - MicroStation
        • +Tables - MicroStation
        • +Text - MicroStation
        • +UI Customization - MicroStation
        • +Units - MicroStation
        • +View - MicroStation
        • +Visualization - MicroStation
        • Welcome Page - MicroStation
        • +Accreditation - MicroStation
        • +i.Models - MicroStation
        • +ProjectWise Integration
        • +Raster - MicroStation
    • +Administration Wiki
    • +Annotations Wiki
    • +Bentley View Wiki
    • +MicroStation PowerDraft
    • +Printing and Plotting
    • +Programming Wiki
    • +Visualization Wiki

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

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

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

    In the factual data set under that graphical elements of some drawings, elements of type 37 appear visually identical to text elements. However, they are defined by a drawing and summarized in property records in groups. In a drawing, any number of such properties can give factual data definitions. When property data is then placed, they can be associatively placed. This means that they will be linked together with another member.
    Non-associatively placed attribute data is often found in cell libraries. If a cell is placed with free factual data from a cell library, the property data is then subsequently linked to the cell. The technical data corresponds to the attributes of an AutoCAD block. Being linked due to the limitations in the DWG format, this DWG only can with blocks (shared cells).
    In this example, we will look at areas to define tangible data that we want to use in a title block to create a new model and define records with factual data.
    It will look something like this:

    The title block is indicated only by a few lines. The property data is represented with names in the drawing and were not placed associatively, because otherwise they would display the value.

    Next, we will create a drawing and place the cell within the drawing. The attribute data is currently empty and must be filled with the values of this drawing with the command "edit attribute data" shown circled below:

    To search the attribute data in a drawing, can can apply several different strategies. We have defined the first parts selection sets, where certain pre-selected items or certain types of items were filled.
    When looking for factual data, we can also go this way, but we should consider in advance how we will need the technical data that is found.

    First of all, I would like to search for a very specific kind of date, which may only be present in the drawing when the cell is placed with the title block with the example property data called "project". In my example, I have entered the following data, so I can search to obtain the result value "BE Community".

    This example search would look something like this:

    Sub elementinfo()
    Dim ele As TagElement
    Dim ee As ElementEnumerator
    Dim header, line As String
    Dim file As String
    Dim Sc As New ElementScanCriteria
    Sc.ExcludeAllTypes
    Sc.IncludeType msdElementTypeTag
    If ActiveWorkspace.IsConfigurationVariableDefined("MyOutputFile") Then
    file = ActiveWorkspace.ConfigurationVariableValue("MyOutputFile")
    Else
    MsgBox "The Variable MyOutputFile is undefined. Stopped processing.", vbCritical
    Exit Sub
    End If
    Open file For Append As #1
    Set ee = ActiveModelReference.GraphicalElementCache.Scan(Sc)
    Do While ee.MoveNext
    Set ele = ee.Current.AsTagElement
    If ele.TagDefinitionName = "Project" Then
    Print #1, "Project" & ";" & ele.Value
    End If
    Loop
    Close #1
    End Sub

    As a result, I find the last line of the .csv:

    Project BE Community

    The search was successful, so we have only one property date with the value "BE Community" found.

    This type of search is not only for reading out certain factual data, but also can serve as a check on the correctness of drawings. This test could also be made to test the presence of the drawing header, to check that the drawing is complete.

    A material date is characterized by the following 3 characteristics: the value .Value, the name of the property date .TagDefinitionName, and the attribute data set .TagSetName.

    The previous method to search for attribute data does not include the identity of the data, but often attribute data goes together, such as the technical data of a drawing header. It may be easier to look for the attribute data according to the elements rather than the factual data.

    Here is an example on how to read out the attribute data of the title block by searching the cell and then reading attribute data:

    Sub elementinfo()
    Dim ele As CellElement
    Dim ee As ElementEnumerator
    Dim header, line As String
    Dim file As String
    Dim oTags() As TagElement
    Dim Sc As New ElementScanCriteria
    Sc.ExcludeAllTypes
    Sc.IncludeOnlyCell ("Default")
    Sc.IncludeType msdElementTypeCellHeader
    If ActiveWorkspace.IsConfigurationVariableDefined("MyOutputFile") Then
    file = ActiveWorkspace.ConfigurationVariableValue("MyOutputFile")
    Else
    MsgBox "The Variable MyOutputFile is undefined. Stopped processing.", vbCritical
    Exit Sub
    End If
    Open file For Append As #1
    Set ee = ActiveModelReference.Scan(Sc)
    Do While ee.MoveNext
    Set ele = ee.Current.AsCellElement
    If ele.HasAnyTags Then
    Print #1, "Cell: " & ";" & ele.Name
    oTags = ele.GetTags
    For i = LBound(oTags) To UBound(oTags)
    line = oTags(i).TagSetName & ";" & oTags(i).TagDefinitionName
    line = line & ";" & oTags(i).Value
    Print #1, line
    Next
    End If
    Loop
    Close #1
    End Sub

    This routine output the following from my example:

    Cell: Default
    Title Block Drafter Administrator
    Title Block checked 01.01.1970
    Title Block Format From A1
    Title Block Scale 0,180555556
    Title Block Project BE Community

    The issue of the name of property date may seem initially unnecessary, but in the general case, a larger number may be attached to property records and only the combination of a record name and definition name is unique, because this combination can only attach once to an item in a cell.

    << RETURN TO PART 9 <<

    • Windows 7 32 bit
    • MicroStation
    • VBA
    • Windows 7 64 bit
    • Programming
    • en
    • 08.11.09.578
    • SELECTsupport
    • Share
    • History
    • More
    • Cancel
    • Tristan Anderson Created by Bentley Colleague Tristan Anderson
    • When: Thu, Jun 25 2015 9:42 AM
    • Tristan Anderson Last revision by Bentley Colleague Tristan Anderson
    • When: Thu, Jun 25 2015 12:58 PM
    • Revisions: 3
    • 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