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.
Solved! Go to Solution.
Solved by Hallex. Go to 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
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.
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)