Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

RE: [VBA - V8i] How to access the text portion of a dimension?

$
0
0

Mary,

From your description I think you need to be modifying the TextStyle defined in the DimensionStyle to change the text background. 

The function below demonstrates how to update the text of a dimension element. You have to iterate through all of the PrimaryText and SecondaryText properties for each segment of the dimension. These are just string values that get their style settings from the TextStyle settings in the DimensionStyle.

Function UpdateDimensionText(strPrefix As String, strSuffix As String) As Long
    Dim iCount As Long' index for dimension element array
   Dim lElem As Long
   Dim lElemStart As Long
   Dim lElemEnd As Long' index for segments in dimension element
   Dim lSeg As Long
   Dim lSegStart As Long
   Dim lSegEnd As Long

   Dim ee As ElementEnumerator
   Dim escan As ElementScanCriteria
   Dim eArray() As Element
   Dim oDim As DimensionElement

   Set escan = New ElementScanCriteria
   escan.ExcludeAllTypes
   escan.IncludeType msdElementTypeDimension

   Set ee = ActiveModelReference.Scan(escan)
   eArray = ee.BuildArrayFromContents

   lElemStart = LBound(eArray)
   lElemEnd = UBound(eArray)
   lSegStart = 1
   iCount = 0
   For lElem = lElemStart To lElemEnd
       Set oDim = eArray(lElem).AsDimensionElement
       iCount = iCount + 1

       lSegEnd = oDim.SegmentsCount

       For lSeg = lSegStart To lSegEnd
           oDim.PrimaryText(lSeg) = strPrefix & "*" & strSuffix
           oDim.SecondaryText(lSeg) = "*"
           oDim.Rewrite
       Next

       Set oDim = Nothing
   Next

    Set ee = Nothing
    Set escan = Nothing

    UpdateDimensionText = iCount
End Function

Viewing all articles
Browse latest Browse all 7260

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>