[CONNECT vba] bold text element

I must be missing something. all i want to be able to do is take all selected text elements and bold them. But i appears this is only possible if a text style has not been used

there is apparently no way to do this in bulk using any microstation tools. the modify text attributes does not have bold as an option. the best you can do is update a text style and save that, then switch all the text to that text style. but this causes problems because we have special symbols in a different font but then regular text uses aerial. so applying a text style switches all text to the font specified in the text style which then makes the special symbols display as a box (as aerial font doesnt have that symbol). So i thought why not just loop through selected elements and bold it. but my code below will only bold the text if the text style is set to none.

I can open the text editor for a given text element and hit the bold bottom to bold the text no matter what textstyle is set and that text style itself is not modified. (that would be bad if it did because then all elements using that text style would get updated automatically.) so its possible to achieve what i want via text editor but i need to do that in bulk.

So something as basic as bulk bolding text doesnt seem possible

here is my code. 

    Dim oEE As ElementEnumerator
    Dim intNumSel As Integer
    intNumSel = 0
    Set oEE = ActiveModelReference.GetSelectedElements
    Do While oEE.MoveNext
        If oEE.Current.IsTextElement Or oEE.Current.IsTextNodeElement Then
            'count the elements
            intNumSel = intNumSel + 1
            If oEE.Current.IsTextElement Then
                oEE.Current.AsTextElement.TextStyle.IsBold = True
                oEE.Current.Rewrite
            ElseIf oEE.Current.IsTextNodeElement Then
                Dim eeText As ElementEnumerator
                Set eeText = oEE.Current.AsTextNodeElement.GetSubElements
                Do While eeText.MoveNext
                    eeText.Current.AsTextElement.TextStyle.IsBold = True
                    eeText.Current.Rewrite
                Loop
                oEE.Current.Rewrite
            Else
            End If
        Else
        End If
    Loop

any ideas

Parents
  • I remember there are some bugs for directly changing textstyle for TextElement in CE. A workaround is using ActiveSettings.TextStyle. Below is a sample for this:

    Sub SetTextBold()
        Dim normTextElem As TextElement, boldTextElem As TextElement
        Set normTextElem = ActiveModelReference.GetElementByID(DLongFromLong(2906))
        
        ActiveSettings.TextStyle = normTextElem.TextStyle
        ActiveSettings.TextStyle.IsBold = True
        Set boldTextElem = CreateTextElement1(Nothing, normTextElem.Text, normTextElem.Origin, normTextElem.Rotation)
        ActiveModelReference.ReplaceElement normTextElem, boldTextElem
    End Sub
    



Reply
  • I remember there are some bugs for directly changing textstyle for TextElement in CE. A workaround is using ActiveSettings.TextStyle. Below is a sample for this:

    Sub SetTextBold()
        Dim normTextElem As TextElement, boldTextElem As TextElement
        Set normTextElem = ActiveModelReference.GetElementByID(DLongFromLong(2906))
        
        ActiveSettings.TextStyle = normTextElem.TextStyle
        ActiveSettings.TextStyle.IsBold = True
        Set boldTextElem = CreateTextElement1(Nothing, normTextElem.Text, normTextElem.Origin, normTextElem.Rotation)
        ActiveModelReference.ReplaceElement normTextElem, boldTextElem
    End Sub
    



Children
No Data