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

How to create a new acadtablestyle

4 REPLIES 4
Reply
Message 1 of 5
wang890
423 Views, 4 Replies

How to create a new acadtablestyle

how to create a new table style and have access to it's properties from vb.net? non managed wrapper preferred. i am trying to so something quick and stable.

thank you
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: wang890


I use this proceedure, but changes the case name to protect my source code. I had to work this out the 'hard way' by testing and probing every option one by one. Be nice if it was properly documented in a help file somewhere.



Public Function DefineTableStyle(ByVal strStyleName As String) As TableStyle



Dim ts As TableStyle = Nothing



Using trans As Transaction = db.TransactionManager.StartTransaction



Dim tsd As DBDictionary = trans.GetObject(db.TableStyleDictionaryId, OpenMode.ForWrite, True, True)



If tsd.Contains(strStyleName) Then



ts = tsd.GetAt(strStyleName).GetObject(OpenMode.ForWrite)



Else



ts = New TableStyle



tsd.SetAt(strStyleName, ts)



trans.AddNewlyCreatedDBObject(ts, True)



End If



Select Case strStyleName



Case "Ariel"



ts.HorizontalCellMargin = 1



ts.VerticalCellMargin = 5



Dim txtstyle As ObjectId = GetTextStyle("Ariel")



ts.SetTextStyle(txtstyle, RowType.TitleRow)



ts.SetTextStyle(txtstyle, RowType.HeaderRow)



ts.SetTextStyle(txtstyle, RowType.DataRow)



ts.SetTextHeight(8, RowType.TitleRow)



ts.SetTextHeight(6, RowType.HeaderRow)



ts.SetTextHeight(6, RowType.DataRow)



ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)



Case "Simplex"



ts.HorizontalCellMargin = 1



ts.VerticalCellMargin = 5



Dim txtstyle As ObjectId = GetTextStyle("Simplex")



ts.SetTextStyle(txtstyle, RowType.TitleRow)



ts.SetTextStyle(txtstyle, RowType.HeaderRow)



ts.SetTextStyle(txtstyle, RowType.DataRow)



ts.SetTextHeight(8, RowType.TitleRow)



ts.SetTextHeight(6, RowType.HeaderRow)



ts.SetTextHeight(6, RowType.DataRow)



ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)



Case "RomanC"



ts.HorizontalCellMargin = 6



ts.VerticalCellMargin = 6



Dim txtstyle As ObjectId = GetTextStyle("RomanC")



ts.SetTextStyle(txtstyle, RowType.TitleRow)



ts.SetTextStyle(txtstyle, RowType.HeaderRow)



ts.SetTextStyle(txtstyle, RowType.DataRow)



ts.SetTextHeight(6, RowType.TitleRow)



ts.SetTextHeight(6, RowType.HeaderRow)



ts.SetTextHeight(6, RowType.DataRow)



ts.SetAlignment(CellAlignment.MiddleLeft, RowType.TitleRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.HeaderRow)



ts.SetAlignment(CellAlignment.MiddleCenter, RowType.DataRow)



ts.IsHeaderSuppressed = True



ts.IsTitleSuppressed = True



Case "Standard"



'do nothing to it.



Case Else



End Select



trans.Commit()



End Using



Return ts



End Function



jvj

Message 3 of 5
wang890
in reply to: wang890

excellent, it should work.

but do you know how to take the linefeed off the code once i copy and paste to vs or word or whatever? i know this site is weird. the code you paste doesn't show nicely.

thanks.
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19
Message 4 of 5
Anonymous
in reply to: wang890

The special characters can be found and replaced using the word find replace tool The keys for them are "^p" for the paragraph return (replace any double with a single) and the manual line break "^l" for the other item (replace with nothing). Sounds like time to make a code cleanup utility, altho it probably has already been done.



jvj
Message 5 of 5
wang890
in reply to: wang890

excellent. man, thanks. worked great. even the ladies in my office who uses word all the time doesn't even know this.
Stantec
Dell Precision 5530, Prism M320PU, C3D 14/17/19

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