AutoCAD Mechanical Forum
Welcome to Autodesk’s AutoCAD Mechanical Forums. Share your knowledge, ask questions, and explore popular AutoCAD Mechanical topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Setting the Default TextStyle

1 REPLY 1
Reply
Message 1 of 2
Anonymous
619 Views, 1 Reply

Setting the Default TextStyle

I am using VBA to create text, and also to create a new TextStyle. 

I can create the TextStyle no problem. I would like this new TextStyle to become the Default TextStyle  for this drawing hereafter. Example. If I were to add new text, it would automatically be set to this new TextStyle. 


I have managed to do exactly this for a Leader, but unable to do this for other text objects. 

This is the code I currently have:

    Dim newTextStyle As AcadTextStyle
    Dim currTextStyle As AcadTextStyle
    
   
    Set newTextStyle = ThisDrawing.TextStyles.Add("TextDefault")
    newTextStyle.SetFont "Arial", False, False, 1, 0
    With newTextStyle
        .Height = 10 * myScale
    End With
    
    ThisDrawing.AcadTextStyle.Name = "TextDefault"                             'Sets the default for the modelspace
    ThisDrawing.MTextStyle.Name = "TextDefault"
    ACAD.Regen
    
    
    
    'Creates a LeaderStyle: LeaderDefault
    Set oDict = ThisDrawing.Dictionaries.Item("ACAD_MLEADERSTYLE")
    Dim oNewMLS As AcadMLeaderStyle
    Set oNewMLS = oDict.AddObject("LeaderDefault", "AcDbMLeaderStyle")
    ' Add the textstyle to the textstyles collection
    With oNewMLS
                .TextStyle = "TextDefault"
                .ArrowSize = 10 * myScale
                .ArrowSymbol = acArrowOpen30
                '.ArrowheadSize = 10 * myScale                              'Modify the Arrow Size
                '.ArrowheadType = acArrowOpen30                             'Modify Arrow Type
                '.TextBackgroundFill = True                                 'Fill in the back of the text
                .TextHeight = 10 * myScale                                  'Specify Text Height
                .LandingGap = .TextHeight / 2                               'Refers the spacing around the text
                '.TextLineSpacingStyle = acLineSpacingStyleAtLeast
    End With
     ThisDrawing.AcadMLeaderStyle.Name = "LeaderDefault"                    'Sets the default for the modelspace

 

Any help of how to get "TextDefault" as the default style for the drawing after it is created would be heplful.

As I mentioned the  code:

ThisDrawing.AcadMLeaderStyle.Name = "LeaderDefault" 

DOES set the LeaderStyle to "LeaderDefault." I want this, but for other text objects. 

This code:

ThisDrawing.AcadTextStyle.Name = "TextDefault"                             'Sets the default for the modelspace
    ThisDrawing.MTextStyle.Name = "TextDefault"

Does NOT do that. 

Thanks in advance. 

Tags (3)
1 REPLY 1
Message 2 of 2
Anonymous
in reply to: Anonymous

So I just asnwered my own question so I thought I might as well post the answer. 

 

To set the TextStyle I needed this line:

 ThisDrawing.ActiveTextStyle = newTextStyle

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost