Results 1 to 5 of 5

Thread: Text Style

  1. #1
    Active Member
    Join Date
    2011-10
    Location
    Norfolk England
    Posts
    55
    Login to Give a bone
    0

    Default Text Style

    Hi

    I've not posted too much, always seem to find an answer using these forums, however I'm stumped.

    I have made a routine (see below) to create a text style, which in itself works fine.
    However, when the 'Text Style' dialog box is opened every time the new text style is highlighted it asks if it needs to be saved.
    Click 'Yes' but the 'Apply' button remains live when rehighlighted.

    Function IsomTextStyle()

    Dim IsoStyle As AcadTextStyle
    Dim name As String
    Dim Entry As AcadTextStyle
    Dim Found As Boolean

    Found = False

    For Each Entry In ThisDrawing.TextStyles

    If Entry.name = "Isom1" Then
    Found = True
    Exit For
    End If

    Next

    If Not (Found) Then

    Set IsoStyle = ThisDrawing.TextStyles.Add("Isom1")

    IsoStyle.fontFile = "romans.shx"
    IsoStyle.height = 0
    IsoStyle.Width = 1
    IsoStyle.ObliqueAngle = 5.76 '330 in radians, 30 = 0.524 rads

    Else

    End If

    ThisDrawing.ActiveTextStyle = IsoStyle

    End Function

    Is there a way to 'Apply' this change with VBA.
    If any one can help it will be appreciated

    Thx Once more in Advance

    It seems the problem is any backward slanting text eg -30!!!
    Even when changed in the Text Style Dialog box!
    Attached Images Attached Images
    Last edited by Calteq; 2021-06-20 at 08:08 AM.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,388
    Login to Give a bone
    0

    Default Re: Text Style

    I was able to replicate your problem. It seems you found a bug. However, the problem is in AutoCAD not VBA. I can use the STYLE command to create a new style and set the oblique angle to any negative number and the error occurs when clicking on another style. Tested in 2018 and 2021.
    C:> ED WORKING....

  3. #3
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,388
    Login to Give a bone
    0

    Default Re: Text Style

    I also made some changes to your code. I improved setting the oblique factor and added a logic test for setting the active style. Note that if you click on the Go Advanced button, you can put your code in a code window to preserve formatting. Also, since your code doesn't return any object, it can be a sub rather than a function.
    Code:
    Sub textsty()
    
        Dim IsoStyle As AcadTextStyle
        Dim name As String
        Dim Entry As AcadTextStyle
        Dim Found As Boolean
    
        Found = False
    
        For Each Entry In ThisDrawing.TextStyles
    
        If Entry.name = "Isom1" Then
        Found = True
        Exit For
        End If
    
        Next
    
        If Not (Found) Then
    
        Set IsoStyle = ThisDrawing.TextStyles.add("Isom1")
    
        IsoStyle.fontFile = "romans.shx"
        IsoStyle.Height = 0
        IsoStyle.Width = 1
        IsoStyle.ObliqueAngle = DegToRad(-30)
    
        Else
    
        End If
    
    
        If Not ThisDrawing.ActiveTextStyle.name = "Isom1" Then ThisDrawing.ActiveTextStyle = IsoStyle
    End Sub
    
    Public Function DegToRad(Angle As Double)
        'convert degrees to radians
        DegToRad = ((Angle / 180) * PI)
    End Function
    
    Public Function PI() As Double
      PI = Atn(1) * 4
    End Function
    C:> ED WORKING....

  4. #4
    Active Member
    Join Date
    2011-10
    Location
    Norfolk England
    Posts
    55
    Login to Give a bone
    0

    Default Re: Text Style

    Thx Ed

    Much Appreciated
    Never sure if it's me or 'Autocad'

    I have seen a lot of post relating to Isometric Text and Dimensions and thought it would be nice to have an automated IsomDimns and will post the humble routine I've created warts and all.

    Geoff

  5. #5
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,388
    Login to Give a bone
    0

    Default Re: Text Style

    BTW, I logged a bug with Autodesk. Now they are aware of it.
    C:> ED WORKING....

Similar Threads

  1. Replies: 1
    Last Post: 2018-01-31, 02:45 PM
  2. 2014: Text Style not showing correct style??? architxt.shx
    By hcadang in forum AutoCAD General
    Replies: 4
    Last Post: 2016-12-15, 09:40 PM
  3. Replies: 1
    Last Post: 2016-09-19, 02:59 PM
  4. Isolate Selected Text Style or Dim Style
    By Wish List System in forum AutoCAD Wish List
    Replies: 4
    Last Post: 2013-01-20, 05:10 AM
  5. Lock Text Height in Dimension Style when Text Style Height is Not 0
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2013-01-16, 04:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •