.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get available table styles in a document

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
Anonymous
623 Views, 4 Replies

How to get available table styles in a document

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.

 

 

4 REPLIES 4
Message 2 of 5
Hallex
in reply to: Anonymous

#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
in reply to: Hallex

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.

 

Message 4 of 5
Anonymous
in reply to: Anonymous

Never mind, I've Found it.

Thank's anyway

Message 5 of 5
Hallex
in reply to: Anonymous

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

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost