Luís Augusto Posted January 21, 2014 Posted January 21, 2014 I wonder if there is documentation for handling autoCADtables. There are several threads showing how to create a table using the method AddTable and other teaching how to create a TableStyle but found nothing saying which properties can change, and so on. Documentation that would tell me which methods and properties supported by tables and how to configure them. Could analyze with Dump tool, created by Lee Mac, there are many things to be configured in a autoCADtable. Anyone know? Could show me the way? I swear, I swept the internet and not found. Thank you very much. Best regards, Luis Augusto. Quote
BIGAL Posted January 21, 2014 Posted January 21, 2014 I found this pretty easy you can also change a cell, stuff like text height colour etc. ; example of creating a table style (vl-load-com) (defun c:CreateTableStyle() ;; Get the AutoCAD application and current document (setq acad (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acad)) ;; Get the Dictionaries collection and the TableStyle dictionary (setq dicts (vla-get-Dictionaries doc)) (setq dictObj (vla-Item dicts "acad_tablestyle")) ;; Create a custom table style (setq key "MyTableStyle" class "AcDbTableStyle") (setq custObj (vla-AddObject dictObj key class)) ;; Set the name and description for the style (vla-put-Name custObj "MyTableStyle") (vla-put-Description custObj "This is my custom table style") ;; Sets the bit flag value for the style (vla-put-BitFlags custObj 1) ;; Sets the direction of the table, top to bottom or bottom to top (vla-put-FlowDirection custObj acTableTopToBottom) ;; Sets the supression of the table header (vla-put-HeaderSuppressed custObj :vlax-false) ;; Sets the horizontal margin for the table cells (vla-put-HorzCellMargin custObj 0.22) ;; Sets the supression of the table title (vla-put-TitleSuppressed custObj :vlax-false) ;; Sets the vertical margin for the table cells (vla-put-VertCellMargin custObj 0.22) ;; Set the alignment for the Data, Header, and Title rows (vla-SetAlignment custObj (+ acDataRow acTitleRow) acMiddleLeft) (vla-SetAlignment custObj acHeaderRow acMiddleCenter) ;; Set the background color for the Header and Title rows (setq colObj (vlax-create-object "AutoCAD.AcCmColor.19")) (vla-SetRGB colObj 98 136 213) (vla-SetBackgroundColor custObj (+ acHeaderRow acTitleRow) colObj) ;; Clear the background color for the Data rows (vla-SetBackgroundColorNone custObj acDataRow :vlax-true) ;; Set the bottom grid color for the Title row (vla-SetRGB colObj 0 0 255) (vla-SetGridColor custObj acHorzBottom acTitleRow colObj) ;; Set the bottom grid lineweight for the Title row (vla-SetGridLineWeight tableStyle acHorzBottom acTitleRow acLnWt025) ;; Set the inside grid lines visible for the data and header rows (vla-SetGridVisibility custObj acHorzInside (+ acDataRow acHeaderRow) :vlax-true) ;; Set the text height for the Title, Header and Data rows (vla-SetTextHeight custObj acTitleRow 1.5) (vla-SetTextHeight custObj (+ acDataRow acHeaderRow) 1.0) ;; Set the text height and style for the Title row (vla-SetTextStyle custObj (+ acDataRow acHeaderRow acTitleRow) "Standard") ;; Release the color object (vlax-release-object colObj) (princ) ) Quote
Luís Augusto Posted January 21, 2014 Author Posted January 21, 2014 Dear Bigal, thank you for responding. You found this code here? Code I felt the need to learn about it, just trying to change this program. I am creating a treatment for error and that means if the table style does not exist in the drawing. I may be wrong but did not see where to modify the number of columns and their widths. The same for the cells. If this is clear, please have patience with me because I am just a beginner. The style of the table i have to create is very simple, if I had posted, surely someone would have helped me. What puzzles me, is that it seems such documentation does not exist! I am grateful for trying to help me. If you know how to put the number of columns and size for each of them I will be very grateful. Thank you for sharing your knowledge. Regards, Luis Augusto. Quote
Spaj Posted January 21, 2014 Posted January 21, 2014 Hi There are some AU notes on the subject which may help. Try here http://forums.augi.com/showthread.php?148682-CP34-3-LISP-Table-Magic Quote
BIGAL Posted January 21, 2014 Posted January 21, 2014 Not at work now doing the table size is easy will post tomorrow, I had no problems finding how to create a table example this took a couple of seconds VLA create table AutoCAD numerous examples Quote
Luís Augusto Posted January 21, 2014 Author Posted January 21, 2014 Hi There are some AU notes on the subject which may help. Try here http://forums.augi.com/showthread.php?148682-CP34-3-LISP-Table-Magic Great material Spaj. Commented codes are always welcome. Actually quite enlightening, but I feel it's missing some properties to be manipulated, or am I mistaken? Many thanks for sharing. Not at work now doing the table size is easy will post tomorrow, I had no problems finding how to create a table example this took a couple of seconds VLA create table AutoCAD numerous examples I look forward to your post. Thanks BIGAL. Quote
BIGAL Posted January 22, 2014 Posted January 22, 2014 This example is cut from a larger bit of code. but has the necessary bits (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq curspace (vla-get-paperspace doc)) ; must be in paper space which layout to put table in change to modelspace if required. (setq pt1 (vlax-3d-point (getpoint "\nPick point for top left hand of table: "))) ; now do table (setq numrows (+ 2 (sslength ss1))) ; ss1 is a list of data for table (setq numcolumns 2) (setq rowheight 0.2) (setq colwidth 150) (setq objtable (vla-addtable curspace pt1 numrows numcolumns rowheight colwidth)) (vla-settext objtable 0 0 "DRAWING REGISTER") (vla-settext objtable 1 0 "DRAWING NUMBER") (vla-settext objtable 1 1 "DRAWING TITLE") (SETQ X 0) (SETQ Y 2) (REPEAT (sslength ss1) (vla-settext objtable Y 0 (NTH X LIST1)) (vla-settext objtable Y 1 (NTH X LIST2)) (vla-setrowheight objtable y 10) (SETQ X (+ X 1)) (SETQ Y (+ Y 1)) ) Quote
Luís Augusto Posted January 23, 2014 Author Posted January 23, 2014 This example is cut from a larger bit of code. but has the necessary bits Bigal, thanks for your contribution. I hope this post can help others as well as helped me. Thank you all. Quote
asos2000 Posted January 28, 2014 Posted January 28, 2014 Find attached LISPTableMagicUpload2.zip au06_Table_Magic.zip Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.