How to get available table styles in a document

How to get available table styles in a document

Anonymous
Not applicable
792 Views
4 Replies
Message 1 of 5

How to get available table styles in a document

Anonymous
Not applicable

Hi,

 

I'm new for developing for AutoCAD.

 

I am building a COM interop using visual basic .NET

I've managed to add a new table, I wish to give the user an option to choose which table style to apply.

 

I just cannot find how to get the document's available table styles.

 

I'm developing for AutoCAD 2012, if it matters.

 

Thanks.

 

 

0 Likes
Accepted solutions (1)
793 Views
4 Replies
Replies (4)
Message 2 of 5

Hallex
Advisor
Advisor
Accepted solution
#Region "Table Styles"

    <CommandMethod("demo", CommandFlags.Modal Or CommandFlags.Session)> _ 
    Public Sub ShowTableStyles()
        'get the acad application object
        Dim acApp As AcadApplication = Application.AcadApplication ''New AcadApplication
        Try
            acApp.Visible = True
            ' get activedocument object
            Dim acDoc As Autodesk.AutoCAD.Interop.AcadDocument = acApp.ActiveDocument
            'get utilituy object
            Dim acUtil As AcadUtility = acDoc.Utility
            ' get a table style dictionary object
            Dim tblDict As AcadDictionary = acDoc.Dictionaries.Item("ACAD_TABLESTYLE")
            Dim tblStl As AcadTableStyle
            Dim msg As String = String.Empty
            'loop through dictionary
            'dispaly style in the command line
            For Each tblStl In tblDict
                acUtil.Prompt(vbLf & tblStl.Name & vbLf)
            Next
        Catch ex As Exception
            MsgBox(ex.Message & vbLf & ex.StackTrace)
            acApp.Quit()
            acApp = Nothing
        End Try

    End Sub
#End Region

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 5

Anonymous
Not applicable

Great, thank you for your quick response.

 

And another question, how do I apply the acadTableStyle to the acadTable I have just created

 

Dim acTableStyle As AcadTableStyle = GetTableStyle(acDoc)
Dim acTable As AcadTable = acDoc.ModelSpace.AddTable(acPoint, DocumentsInfo.Count + 1, 7, acTableStyle.GetTextHeight(AcRowType.acDataRow) * 1.05, 20)

 unlike TextStyle the acadDocument don't have a ActiveTableStlye property.

 

0 Likes
Message 4 of 5

Anonymous
Not applicable

Never mind, I've Found it.

Thank's anyway

0 Likes
Message 5 of 5

Hallex
Advisor
Advisor

You have to use the system variable "CTABLESTYLE"

See help file

Something like:

 

acDoc.SetVariable("CTABLESTYLE", "MyTableStyle")

 

Dim acTable AsAcadTable = acDoc.ModelSpace.AddTable(acPoint, 10, 7, _

_

 acTableStyle.GetTextHeight(AcRowType.acDataRow) * 1.05, 20)

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
0 Likes