Help with (vla-Addtable...)
Hello,
I tried using the (vla-Addtable....) Lisp function calling the AddTable method and need help to interpret the arguments : RowHeight & ColWidth.
Are they in CAD units or some row-relative measurements?
I have this piece of code:
(setq
RowHgt 1.0
ColWid 5.0
)
(vlax-invoke-method #ModelSpace 'AddTable (vlax-3d-point Insp) (+ nRows 2) nCols RowHgt ColWid)
and I expect to get a row height of 1.0 CAD unit and a column width of 5.0 CAD units.
But, it is not happening and I cannot figure out what and why.
Any pointers apprecaited to interpret these arguments.
Thanks in advance.
Regards
Rakesh
www.4d-technologies.com
Comments
-
You are interpreting the values correctly; I think it's a bug. If you create an imperial drawing it inserts correctly but if you create a metric one then then the rowheight is scaled by some unknown factor; though the width is correct. It's very reproducible so I suggest a support request.
Regards,
0 -
@Rakesh:
I think the min. height of a row, as determined by the text height and margins in your table style, is probably bigger than 1.0.
The row height you specify must be equal to or bigger than that min. height.I use something like this:
(setq RowHgt (* (vla-gettextheight tableStyleObject acdatarow) 2))0 -
Roy is correct, you should not be able to set the row height to less than the minimum row height, same goes for column the width. Try using
vla-GetMinimumColumnWidth
vla-GetMinimumRowHeight
0 -
Thank you Dainel (both!) and Roy, I will give this a try and see what happens.
0 -
Some info regarding column widths for those 'wrestling' with tables:
[code]
;; If you supply a very small value for the column width (e.g. 1e-300) Bricscad seems to use this width algortithm:
;; (max
;; (+ textHeightHeader horzCellMarginHeader horzCellMarginHeader)
;; (+ textHeightData horzCellMarginData horzCellMarginData)
;; )
;;
;; But the MinimumColumnWidth property for the table seems to be based on this algortithm:
;; (max
;; (+ textHeightTitle horzCellMargin horzCellMargin)
;; (+ textHeightTitle horzCellMarginTitle horzCellMarginTitle)
;; (+ textHeightHeader horzCellMargin horzCellMargin)
;; (+ textHeightHeader horzCellMarginHeader horzCellMarginHeader)
;; (+ textHeightData horzCellMargin horzCellMargin)
;; (+ textHeightData horzCellMarginData horzCellMarginData)
;; )
;;
;; To change the HorzCellMargin property for a table:
;; (vla-put-horzcellmargin (vlax-ename->vla-object (car (entsel))) 0.5)
;;
;; It should be possible to use the function (vla-put-horzcellmargin) on table styles too. But this does not work properly yet:
;; (vla-get-horzcellmargin tableStyleObject) => 1.5
;; (vla-set-horzcellmargin tableStyleObject 3.33)
;; (vla-get-horzcellmargin tableStyleObject) => 3.33
;; But after saving and reopening:
;; (vla-get-horzcellmargin tableStyleObject) => 1.0
[/code]0 -
@Rakesh
Hi Rakesh,
Did you moved one step over with your latest tests in LISP using Tables?
It looks like vla-InsertRowsAndInherit is still not implemented and I'm looking for a solution of matching properties for new rows. It's OK, vla-InsertRows works, but all of new inserted rows forces their formats into *any* format and that's unusable for me.
Did you find a simple method to copy formatting properties from the last row to a new row?
Thanks, Vaidas0 -
Vaidas
just an FYI, vla-InsertRowsAndInherit is implemented in the beta
0 -
i'm struggling also with this.
My table cell height was always minimum 9.0 and searching for an explanation i ended up here.
it appears that the text height and margin is (always ?) used from the "standard" table style (6 + 2 times 1.5) when you execute vla-addtable
Is it possible to make a custom tablestyle 'current' before adding the table ? Instead of having to alter the heights of the cell's afterwards.
ty !0 -
using variable "CTableStyle" seem to solve it...0
-
however not when there is only the single "standard" style ...
my cells are now 3.4 allthough i add cellsize 1.0...0 -
The obvious answer to your problem: Create a new table style and set it up so that the cell sizes you require are possible.
[code](defun c:Test ( / docObj tblObj tblStlObj)
(setq docObj (vla-get-activedocument (vlax-get-acad-object)))
(setq tblStlObj
(vla-addobject
(vla-add (vla-get-dictionaries docObj) "ACAD_TABLESTYLE")
"myTableStyle"
"AcDbTableStyle"
)
)
(vla-put-horzcellmargin tblStlObj 0.0)
(vla-put-vertcellmargin tblStlObj 0.0)
(vla-settextheight tblStlObj actitlerow 0.5)
(vla-settextheight tblStlObj acheaderrow 0.5)
(vla-settextheight tblStlObj acdatarow 0.5)
(vla-settextheight tblStlObj acunknownrow 0.5)
(setvar 'ctablestyle "myTableStyle")
(setq tblObj
(vla-addtable
(vla-get-modelspace docObj)
'(0.0 0.0 0.0)
5
5
1.0 ; RowHeight.
1.0 ; ColWidth.
)
)
(princ)
)[/code]0 -
This info may be useful:
[code];;; Row heights:
;;; ------------
;;; The minimum row height for rows without text seems to be based on this
;;; algorithm:
;;; (+ (* (/ 4.0 3.0) textHeight) vertCellMargin vertCellMargin)
;;; The same row with text can however return a smaller height![/code]0 -
horzcellmargin seems to be implemented as a cell property, not a table property? Itseems true with my lisp routines and through BricsCAD. Changing the table style is having no
affect on my tables.0 -
@ Donald:
A table object does have a horzcellmargin property. But each cell also has its own margin values.
It seems that a new horzcellmargin for the table will only overwrite cell margins that are smaller.
My Test:
[code](vla-getmargin (vlax-ename->vla-object (car (entsel))) 2 0 accellmarginleft) ; => 1.5
(vla-put-horzcellmargin (vlax-ename->vla-object (car (entsel))) 3.0)
(vla-getmargin (vlax-ename->vla-object (car (entsel))) 2 0 accellmarginleft) ; => 3.0
(vla-setmargin (vlax-ename->vla-object (car (entsel))) 2 0 accellmarginleft 6.0)
(vla-put-horzcellmargin (vlax-ename->vla-object (car (entsel))) 3.0)
(vla-getmargin (vlax-ename->vla-object (car (entsel))) 2 0 accellmarginleft) ; => 6.0[/code]0 -
...
No, my initial conclusion in incorrect. Once applied the cell margin values behave as overrides. I don't know if and how these can be removed.0