Vla-generatelayout
- 構文
- (vla-generatelayout vla-object ' ' ')
- 機能
- 表のレイアウトを生成する。
- 引数
-
- vla-object … Table の VLAオブジェクト
- 戻り値
- nil
- 注意: このメソッドは、現在の表スタイルに従って Table オブジェクトを更新する。表のジオメトリ(罫線、文字の内容、ブロックの内容、背景の塗り潰しを含む)を計算する。
- サンプル
(defun C:BOM (/ acmcol adoc axss cnt col columns dht headers row rows table table_data total) (if (< (atof (getvar "ACADVER")) 16.0) (alert "このコマンドは\nACADだと2005 以上じゃないと動きません") (progn (vl-load-com) (or adoc (setq adoc (vla-get-activedocument (vlax-get-acad-object)))) (or acsp (setq acsp (if (= (getvar "TILEMODE") 0) (vla-get-paperspace adoc) (vla-get-modelspace adoc)) ) ) (make-tablestyle "BOM_table" "BOM table" "表本文" 3.0 2.25 3.0) (setvar "CTABLESTYLE" "BOM_table") (setq acmCol (vla-getinterfaceobject (vlax-get-acad-object) (strcat "AutoCAD.AcCmColor." (substr (getvar "ACADVER") 1 2)))) (setq dht (getvar "dimtxt")) ;<--text height (if (< dht 2.)(setq dht 2.)) (setq table_data (list '("EP-1" 1 "12x200x350" 6.59) '("EP-2" 2 "11x200x350" 6.49) '("EP-3" 3 "10x200x350" 6.39) '("EP-4" 4 "9x200x350" 6.29) '("EP-5" 5 "8x200x350" 6.19) '("EP-6" 6 "7x200x350" 6.09)) ) (setq total (apply '+ (mapcar '* (mapcar 'cadr table_data) (mapcar 'last table_data)) )) (setq columns (length (car table_data)) rows (length table_data) ) (setq table (vlax-invoke acsp 'Addtable (getpoint "\n表の左上点を指示 : \n") (+ 2 rows) columns 5.0 ;; 行高さ: 50.0 ;; 列幅: ) ) (vla-put-titlesuppressed table :vlax-true) (vla-put-headersuppressed table :vlax-false) (vla-put-regeneratetablesuppressed table :vlax-true) (vla-put-layer table "0") (vla-put-horzcellmargin table 0.25) (vla-put-vertcellmargin table 0.25) (vla-settextstyle table 4 "表タイトル") ; <-文字スタイルは作っとくこと (vla-settextstyle table 2 "表本文") (vla-settextstyle table 1 "表本文") (vla-setrowheight table 4 (* dht 2)) (vla-setrowheight table 2 (* dht 1.5)) (vla-setrowheight table 1 (* dht 2)) (vla-settextheight table 4 dht) (vla-settextheight table 2 (* dht 1.15)) (vla-settextheight table 1 (* dht 1.5)) (vla-put-colorindex acmcol 256) (vla-put-truecolor table acmcol) (vla-setcolumnwidth table 0 37) (vla-setcolumnwidth table 1 12) (vla-setcolumnwidth table 2 62) (vla-setcolumnwidth table 3 24) (vla-put-colorindex acmcol 102) (setq headers '("型番" "番号" "説明" "重量")) (vl-catch-all-apply 'vlax-invoke (list table 'UnMergeCells 0 0 0 (1- columns)); <-- unmerge cells ) (setq col 0 row 0 ) (foreach a headers (vla-setcellvalue table row col a) (vla-setrowheight table 0 8) (vla-setcelltextheight table row col (* dht 1.5)) (vla-setcellcontentcolor table row col acmcol) (setq col (1+ col)) ) (vla-put-colorindex acmcol 182) (setq cnt 0 row 1) (foreach i table_data (vla-setrowheight table cnt 5) (setq col 0) (foreach a i (vla-setcellvalue table row col a) (vla-setcelltextheight table row col (* dht 1.5)) (cond ((/= col 3) (progn (vla-setcelldatatype table row col acstring acunitless) (vla-setcellformat table row col "@"))) (T (progn(vla-setcelldatatype table row col acdouble acunitless) (vla-setcellformat table row col "%lu2%pr2%th44")) ;<-- 小数点2桁ドット区切り )) (vla-setcellalignment table row col acMiddleCenter) (vla-setcellcontentcolor table row col acmcol) (setq col (1+ col))) (setq row (1+ row)) ) (vl-catch-all-apply 'vlax-invoke (list table 'MergeCells row row 0 (- columns 2));<--merge cells ) (vla-put-colorindex acmcol 12) (vla-setrowheight table row 5) (vla-setcelltextheight table row 0 (* dht 1.5)) (vla-settext table row 0 "合計 :\t") (vla-setcellalignment table row 0 acMiddleRight) (vla-setcellcontentcolor table row 0 acmcol) (vla-setcellvalue table row (1- columns) total) (vla-setcelldatatype table row (1- columns) acdouble acunitless) (vla-setcellformat table row (1- columns) "%lu2%pr2%th44" ) ;<-- 小数点2桁ドット区切り (vla-settooltip table row (1- columns) "合計重量") (vla-setcelltextheight table row (1- columns) (* dht 1.5)) (vla-setcellalignment table row (1- columns) acMiddleCenter) (vla-setcellcontentcolor table row (1- columns) acmcol) (vla-generatelayout table) (vla-recomputetableblock table :vlax-true) (vla-put-regeneratetablesuppressed table :vlax-false) (vl-catch-all-apply (function (lambda () (progn (vla-clear axss) (vla-delete axss) (mapcar 'vlax-release-object (list axss table)) )))) (vla-regen adoc acactiveviewport) ) ) (princ) );_end_defun_C:BOM
関連事項