Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

use a lisp to edit the properties of a table

2 REPLIES 2
Reply
Message 1 of 3
camardi
2491 Views, 2 Replies

use a lisp to edit the properties of a table

guys i've forgotten how to write lisps as i havent written code since autocad 2000-2004

 

can anybody help me out?

 

i would like to be able to quickly edit the following properties

 

select a table

changet the table style

change the row heights (the first height 10, then the rest at 6)

change the cell widths (first at 10 then rest at 25)

change the cell format of one column to angular with no decimals

 

can anyone tell me what i need to type?

 

so far googled and found this which sort of works for me

 

(defun c:Rz()
(vl-load-com)
(setq tbl (vlax-ename->vla-object(car(entsel))))
(vla-setcolumnwidth tbl 0 10)
(vla-setcolumnwidth tbl 1 25)
(vla-setcolumnwidth tbl 2 25)
(vla-setcolumnwidth tbl 3 25)
(vla-setcolumnwidth tbl 4 25)
(vla-setcolumnwidth tbl 5 25)

(setq rows (vla-get-rows tbl)) ;;get number of rows

 

(setq currentRow 0)
(repeat rows - 2 ;;repeat for all the rows in the table
(vla-SetCellAlignment tbl currentRow 0 acMiddleCenter)
(vla-SetCellAlignment tbl currentRow 1 acMiddleCenter)
(vla-SetCellAlignment tbl currentRow 2 acMiddleCenter)

(vla-SetCellAlignment tbl currentRow 3 acMiddleCenter)

(vla-SetCellAlignment tbl currentRow 4 acMiddleCenter)
(vla-SetCellAlignment tbl currentRow 5 acMiddleCenter)
;;(vla-setrowheight tbl currentRow 1) ;Change row height (TEST)
(setq currentRow (+ 1 currentRow))

 

(vla-setrowheight tbl 0 10)
(vla-setrowheight tbl 1 6)
(vla-setrowheight tbl 2 6)
(vla-setrowheight tbl 3 6)
(vla-setrowheight tbl 4 6)

 

 

the last section is what i cannot get to work, most likely because acad doesnt recognise the command

 

 

any help guys?

2 REPLIES 2
Message 2 of 3
hmsilva
in reply to: camardi

camardi

if you are setting the row height, first you have to set text height

 

(vla-setcelltextheight table row colum height)

 

and the vertical margin

 

(vlax-put tbl 'VertCellMargin 1)

 

the [celltextheight + (2 x VertCellMargin)] equal to or greater than (row height)

 

i.e.

if your text height is set to 3 and the vertical cell margin to 1, now you can set the row height to 6...

 

hope that helps

Henrique

EESignature

Message 3 of 3
hmsilva
in reply to: hmsilva

camardi,
in my previous post, where I wrote greater, I meant lesser...

 

Henrique

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost