Hi,
I am looking for a lisp code to make a table with full flexibility about cells.
So, I need full dxf code for TABLE entity, actually I couldn't fine an comprehensive list in the online help:
http://docs.autodesk.com/ACD/2014/ENU/files/GUID-D8CCD2F0-18A3-42BB-A64D-539114A07DA0.htm
So, I try with (vlax-dump-object obj T) by applying on a 1x1 table (single cell table), and this is result of it:
( (-1 . <Entity name: 7ffff705ba0>) (0 . "ACAD_TABLE") (330 . <Entity name: 7ffff7039f0>) (5 . "232") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "0") (100 . "AcDbBlockReference") (2 . "*T1") (10 268.342 202.099 0.0) (41 . 1.0) (42 . 1.0) (43 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (44 . 0.0) (45 . 0.0) (210 0.0 0.0 1.0) (100 . "AcDbTable") (280 . 0) (342 . <Entity name: 7ffff703c70>) (343 . <Entity name: 7ffff705bc0>) (11 1.0 0.0 0.0) (90 . 22) (91 . 1) (92 . 1) (93 . 3) (94 . 0) (95 . 0) (96 . 0) (280 . 1) (281 . 1) (141 . 10.0) (142 . 20.0) (171 . 1) (172 . 0) (173 . 0) (174 . 0) (175 . 1) (176 . 1) (91 . 262193) (178 . 0) (145 . 0.785398) (170 . 5) (7 . "ROMANS") (140 . 2.5) (92 . 0) (301 . "CELL_VALUE") (93 . 4) (90 . 4) (1 . "1x1") (94 . 0) (300 . "%tc1") (302 . "1X1") (304 . "ACVALUE_END") )
But the problem is:
I could not found any dxf code about cells properties such as text style,font,width, oblique,....
Please see this sample code:
(defun MakeTable (XYZ lst) (entmakex (append (list '(0 . "ACAD_TABLE") '(100 . "AcDbEntity") '(100 . "AcDbBlockReference") (cons 10 XYZ) '(100 . "AcDbTable") (cons 91 (length lst)) (cons 92 (apply 'max (mapcar '(lambda (x) (length x)) lst))) ) (apply 'append (mapcar (function (lambda (a) (apply 'append (mapcar (function (lambda (b) (list '(171 . 1) '(173 . 0) '(175 . 0) '(176 . 0) '(145 . 0.0) '(301 . "CELL_VALUE") '(90 . 4) (cons 1 b) (cons 302 b) '(304 . "ACVALUE_END") ) ) ) a ) ) ) ) lst ) ) ) ) ) (defun c:test () (MakeTable (getpoint "Where is the insertion point?") '(("A1\\Prow1" "A2\\Prow1") ("B1\\Prow2" "B2\\Prow2") ("C1\\Prow3" "C2\\Prow3") ) ) )
As I know there are more commands for Tables in the VLA-:
List of Methods for Table:
ArrayPolar ArrayRectangular ClearSubSelection ClearTableStyleOverrides Copy CreateContent Delete DeleteCellContent DeleteColumns DeleteContent DeleteRows EnableMergeAll FormatValue GenerateLayout GetAlignment GetAttachmentPoint GetAutoScale GetAutoScale2 GetBackgroundColor GetBackgroundColorNone GetBlockAttributeValue GetBlockAttributeValue2 GetBlockAttributeValue232 GetBlockAttributeValue32 GetBlockRotation GetBlockScale GetBlockTableRecordId GetBlockTableRecordId2 GetBlockTableRecordId232 GetBlockTableRecordId32 GetBoundingBox GetBreakHeight GetCellAlignment GetCellBackgroundColor GetCellBackgroundColorNone GetCellContentColor GetCellDataType GetCellExtents GetCellFormat GetCellGridColor GetCellGridLineWeight GetCellGridVisibility GetCellState GetCellStyle GetCellStyleOverrides GetCellTextHeight GetCellTextStyle GetCellType GetCellValue GetColumnName GetColumnWidth GetContentColor GetContentColor2 GetContentLayout GetContentType GetCustomData GetDataFormat GetDataType GetDataType2 GetExtensionDictionary GetFieldId GetFieldId2 GetFieldId232 GetFieldId32 GetFormat GetFormula GetGridColor GetGridColor2 GetGridDoubleLineSpacing GetGridLineStyle GetGridLinetype GetGridLinetype32 GetGridLineWeight GetGridLineWeight2 GetGridVisibility GetGridVisibility2 GetHasFormula GetMargin GetMinimumColumnWidth GetMinimumRowHeight GetOverride GetRotation GetRowHeight GetRowType GetScale GetSubSelection GetText GetTextHeight GetTextHeight2 GetTextRotation GetTextString GetTextStyle GetTextStyle2 GetValue GetXData Highlight HitTest InsertColumns InsertColumnsAndInherit InsertRows InsertRowsAndInherit IntersectWith IsContentEditable IsEmpty IsFormatEditable IsMergeAllEnabled IsMergedCell MergeCells Mirror Mirror3D Move MoveContent RecomputeTableBlock RemoveAllOverrides ReselectSubRegion ResetCellValue Rotate Rotate3D ScaleEntity Select SelectSubRegion SetAlignment SetAutoScale SetAutoScale2 SetBackgroundColor SetBackgroundColorNone SetBlockAttributeValue SetBlockAttributeValue2 SetBlockAttributeValue232 SetBlockAttributeValue32 SetBlockRotation SetBlockScale SetBlockTableRecordId SetBlockTableRecordId2 SetBlockTableRecordId32 SetBlockTableRecordId232 SetBreakHeight SetCellAlignment SetCellBackgroundColor SetCellBackgroundColorNone SetCellContentColor SetCellDataType SetCellFormat SetCellGridColor SetCellGridLineWeight SetCellGridVisibility SetCellTextHeight SetCellState SetCellStyle SetCellTextHeight SetCellTextStyle SetCellType SetCellValue SetCellValueFromText SetColumnName SetColumnWidth SetContentColor SetContentColor2 SetContentLayout SetCustomData SetDataFormat SetDataType SetDataType2 SetFieldId SetFieldId2 SetFieldId232 SetFieldId32 SetFormat SetFormula SetGridColor SetGridColor2 SetGridDoubleLineSpacing SetGridLineStyle SetGridLinetype SetGridLinetype32 SetGridLineWeight SetGridLineWeight2 SetGridVisibility SetGridVisibility2 SetMargin SetOverride SetRotation SetRowHeight SetScale SetSubSelection SetText SetTextHeight SetTextHeight2 SetTextRotation SetTextString SetTextStyle SetTextStyle2 SetToolTip SetValue SetValueFromText SetXData TransformBy UnmergeCells Update
List of Properties for Table:
AllowManualHeights AllowManualPositions Application BreaksEnabled BreakSpacing Columns ColumnWidth Direction Document EnableBreak EntityTransparency FlowDirection Handle HasExtensionDictionary HasSubSelection HeaderSuppressed Height HorzCellMargin Hyperlinks InsertionPoint Layer Linetype LinetypeScale Lineweight Material MinimumTableHeight MinimumTableWidth ObjectID ObjectID32 ObjectName OwnerID OwnerID32 PlotStyleName RegenerateTableSuppressed RepeatBottomLabels RepeatTopLabels RowHeight Rows StyleName TableBreakFlowDirection TableBreakHeight TableStyleOverrides TitleSuppressed TrueColor VertCellMargin Visible Width
So, Does anybody has a full list of DXF codes for Table entity?
Thanks
Abbas Aqdam
Hi Ajilal,
Thank you for your help, but at the top of my post, I have already mentioned to dxf links:
Common Group Codes for Entities (DXF):
http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-3610039E-27D1-4E23-B6D3-7E60B22BB5BD
TABLE (DXF):
http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-D8CCD2F0-18A3-42BB-A64D-539114A07DA0
the problem is they are not completed, for example they did not list (304 . "ACVALUE_END") or (91 . 262193) on their documatation!
or even about flags,....
actually I want to make a table with full control on each cell properties such as font and oblique and.... but there is no full documentation about it.
Thank you for your help!
Abbas
aqdam1978 wrote:
actually I want to make a table with full control on each cell properties such as font and oblique and.... but there is no full documentation about it.
Hi Abbas,
to format each cell font, oblique, bold... you'll have to format the text string, using MText formatting codes...
Take a look at this post by mid-awe and Lee Mac which should be useful.
As a "demo", from your test routine
(defun c:test () (MakeTable (getpoint "Where is the insertion point?") '(("{\\fArial|b1|i0|c0|p34;\\Q5;\\W1.25;A1\\Prow1}" "A2\\Prow1") ("B1\\Prow2" "{\\fArial|b1|i0|c0|p34;\\LB2\\Prow2}") ("{\\fArial|b1|i1|c0|p34;C1\\Prow3}" "C2\\Prow3") ) ) )
Henrique
Hi Henrique,
Thanks for your solution, but I don't like formatted-texts!
I know:
dxf 7 is for TextStyle
dxf 145 is for text rotation
dxf 140 is for text height
but there is no any documents for other properties!
I want pure lisp code to make tables and control them!
Thanks,
Abbas
Hello, dear friends.
I'm trying to change some table properties of a table via AutoLISP.
I am successful in change text in a cell (DXF 1 and 302).
The problem is encountered when I’m trying to change cell border thickness.
DXF codes responsible for cell borders are
– flag showing what border in a cell is affected: 172*,
– border thickness (multiplied by 100): 275 (right), 276 (lower), 278 (left), 279 (upper)
– border color: 65 (right), 66 (lower), 68 (left), 69 (upper).
I have compared one-cell table with cell border “ByBlock” (default value for tables) and one-cell table with different borders thicknesses. Generally, only above-mentioned DXFs differ.
I’m trying to reach the goal (to change border cell thickens) by:
1) changing DXF 172 from 0 to 1 (only upper border),
2) adding to a list the following DXF: (279 . 200) (69 . 0) (thickness 2.0 mm, no color). I’m adding this somewhere after (171 . 1) showing the start of a cell (actually in the same place if I change border thickness manually).
Entmod updates only text in a cell, but not cell border properties.
If I take a table with changed upper border thickness, steps 1) and 2) are works fine. Because DXF-groups have already been presented (but still no effect if I change group 172, add new groups 275-278, 65-68).
So, how to update/change table properties by changing DXF code 171, adding DXF codes for 275-279, 65-69?
Attached dwg (2013) and lsp files.
* DXF 172 is 0…15, meaning the following:
0 no borders changed
1 upper side
2 right side
3 upper+right sides
4 lower side
5 upper+lower sides
6 lower+right sides
7 upper+lower sides
8 left side
9 upper+left sides
10 left+right sides
11 upper+left+right sides
12 left+lower sides
13 upper+lower+left sides
14 lower+left+right sides
15 all sides
I can't explain it, but through error and trial I saw DXF 91 code from your right table and I changed the code to reflect that value... In the end it worked... So you have to figure out what that number means - left table has it different and because of that (entmod)-ing was prevented...
(defun c:ChangeTable ( / stringToReplace selected editedList ) ;; String to be placed in a one-cell table (setq stringToReplace (getstring "\nNew string to replace in a cell: ")) ;; The table itself (setq selected (entget (car (entsel "\nSelect a table: ")))) ;; In editedList we will make changes for DXF 1, 302 (cell text), 172 (border flag), 279 (upper border thickness), 69 (upper border color) ;; Rolling through the table DXF list (foreach X selected (progn (setq editedList (cons X editedList)) ;(princ X) ;; DXF=1 and 302 are found. Change cell text (if (eq 1 (car X)) (setq editedList (subst (cons 1 stringToReplace) (assoc 1 editedList) editedList)) ) (if (eq 302 (car X)) (setq editedList (subst (cons 302 stringToReplace) (assoc 302 editedList) editedList)) ) ;; DXF=145 is found. Place DXF 279 and 69 right after it (if (eq 145 (car X)) (progn ;; upper border width 0.5 mm (setq editedList (cons (cons 279 50) editedList)) ;; upper border color (setq editedList (cons (cons 69 0) editedList)) ) ) ) ; progn ) ; foreach ;; Changing the border flags (DXF=172) ;; 0 - none, 1 - upper, 2 - right, 3 - upper+right, 4 - lower, ;; 5 - upper+lower, 6 - lower+right, 7 - upper+lower+left, 8 - left, ;; 9 - upper+left, 10 - left+right, 11 - upper+left+right, 12 - lower+left, ;; 13 - upper+lower+left, 14 - lower+left+right, 15 - upper+lower+left+right (setq editedList (subst (cons 172 1) (assoc 172 editedList) editedList)) (setq editedList (subst (cons 91 279616) (assoc 91 editedList) editedList)) ;;; change last assoc 91 - DXFlist is still reversed so first assoc is from behind (setq selected (reverse editedList)) (entupd (cdr (assoc -1 (entmod selected)))) (princ) )
HTH, M.R.