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

[V8i VBA] Creating Annotation Text in specific units regardless of design file units

$
0
0

Firstly, I am able to create text elements by providing text width and height values (via text boxes on a form) using the active units of a design file (values are in Metres) however I have been asked to instead for the values to always represent Millimeters AND for the text to be annotation text. In a previous thread I had difficulty with annotation scale not working for newly created cells and Jan Slegr advised that I try using ActiveModelReference.GetLastValidGraphicalElement to apply a property handler after the cell was added to the design file. Without know if creating text receptive to annotation scale changes is a similar in process to creating annotation cells, I have amended my text creation code like so:

Header = Point3dAdd(Point, Point3dFromXYZ(-0.5, -1.25, 0))
            Point = Header

            If CStr(CurrArray(R, C)) = vbNullString Then
                Set oText = CreateTextElement1(Nothing, "0", Point, Matrix3dIdentity)
            Else
                Set oText = CreateTextElement1(Nothing, CStr(CurrArray(R, C)), Point, Matrix3dIdentity)
            End If
            Set WriteChainage = oText
            Set oFont = ActiveDesignFile.Fonts.Find(msdFontTypeWindowsTrueType, sFontName)
            oText.TextStyle.Font = oFont
            oText.TextStyle.Height = dFontHeight
            oText.TextStyle.Width = dFontWidth
            oText.TextStyle.Color = ActiveModelReference.InternalColorFromRGBColor(RGB(sRGBVals(0), sRGBVals(1), sRGBVals(2)))
            oText.TextStyle.Justification = msdTextJustificationRightCenter
            oText.Redraw msdDrawingModeNormal
            ActiveModelReference.AddElement oText

            Set oText = ActiveModelReference.GetLastValidGraphicalElement
            Set oProp = CreatePropertyHandler(oText)
            oProp.SelectByAccessString "AnnotationPurpose"
            If oProp.GetValue = True Then
                oProp.SelectByAccessString "IsAnnotation"
                Debug.Print "the Text Annotation value is " & oProp.GetValue
                oProp.SetValue (True)
            End If

The result can be seen below:

I have checked the VBA help and it doesn't mention AnnotationPurpose anywhere. I discovered the term from this page but I am unsure if it is only specific to annotation cells and not annotation text. Can anyone advise how what I need to change to create annotation text?

Secondly, I am looking for some advice how I can ensure the dFontHeight and dFontWidth variable values always represent Millimeters regardless of if the active designfile units are either Meters or Millimetres. My initial thoughts are to use a simple IF Else statement to check the value of ActiveModelReference.MasterUnit.Label and if the value is m (meters), divide the textbox values by 1000 otherwise just use the textbox value. Does this sound feasible or am I missing something?


Viewing all articles
Browse latest Browse all 7260

Trending Articles



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