Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 08/23/2025 in all areas

  1. Perhaps this ? (vl-load-com) (defun c:lines2cell ( / js AcDoc Space nw_style oldim oldlay ins_pt_cell h_t w_c lst_id-seg lst_pt n obj dxf_10 dxf_11 mid_pt nb nw_obj ename_cell n_row n_column) (princ "\nSelect points.") (while (null (setq js (ssget '((0 . "LINE"))))) (princ "\nSelection empty, or is not a lines!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (cond ((null (tblsearch "LAYER" "Table-Lines")) (vla-add (vla-get-layers AcDoc) "Table-Lines") ) ) (cond ((null (tblsearch "STYLE" "Text-Cell")) (setq nw_style (vla-add (vla-get-textstyles AcDoc) "Text-Cell")) (mapcar '(lambda (pr val) (vlax-put nw_style pr val) ) (list 'FontFile 'Height 'ObliqueAngle 'Width 'TextGenerationFlag) (list (strcat (getenv "windir") "\\fonts\\arial.ttf") 0.0 (/ (* 15.0 pi) 180) 1.0 0.0) ) (command "_.ddunits" (while (not (zerop (getvar "cmdactive"))) (command pause) ) ) ) ) (setq oldim (getvar "dimzin") oldlay (getvar "clayer") ) (setvar "dimzin" 0) (setvar "clayer" "Table-Lines") (initget 9) (setq ins_pt_cell (getpoint "\nLeft-Up insert point of table: ")) (initget 6) (setq h_t (getdist ins_pt_cell (strcat "\nHigth text <" (rtos (getvar "textsize")) ">: "))) (if (null h_t) (setq h_t (getvar "textsize")) (setvar "textsize" h_t)) (initget 7) (setq w_c (getdist ins_pt_cell "\nWidth of cells: ")) (setq lst_id-seg '() lst_pt '() nb 0 ) (repeat (setq n (sslength js)) (setq obj (ssname js (setq n (1- n))) dxf_10 (cdr (assoc 10 (entget obj))) dxf_11 (cdr (assoc 11 (entget obj))) mid_pt (mapcar '* (mapcar '+ dxf_10 dxf_11) '(0.5 0.5 0.5)) lst_pt (cons (list dxf_10 dxf_11 mid_pt) lst_pt) nb (1+ nb) lst_id-seg (cons nb lst_id-seg) ) ) (mapcar '(lambda (p tx) (setq nw_obj (vla-addMtext Space (vlax-3d-point p) 0.0 tx ) ) (mapcar '(lambda (pr val) (vlax-put nw_obj pr val) ) (list 'AttachmentPoint 'Height 'DrawingDirection 'InsertionPoint 'StyleName 'Layer 'Rotation) (list 5 h_t 5 p "Text-Cell" "Table-Lines" 0.0) ) ) (mapcar 'caddr lst_pt) lst_id-seg ) (vla-addTable Space (vlax-3d-point ins_pt_cell) (+ 2 nb) 10 (+ h_t (* h_t 0.25)) w_c) (setq ename_cell (vlax-ename->vla-object (entlast)) n_row (1+ nb) n_column -1) (vla-SetCellValue ename_cell 0 0 (vlax-make-variant (strcat "Summary of " (itoa (sslength js)) " LINES") 8 ) ) (vla-SetCellTextStyle ename_cell 0 0 "Text-Cell") (vla-SetCellTextHeight ename_cell 0 0 (vlax-make-variant h_t 5)) (vla-SetCellAlignment ename_cell 0 0 5) (foreach n (mapcar'list (append lst_id-seg '("N°")) (append (mapcar 'rtos (mapcar 'caar lst_pt)) '("Start X")) (append (mapcar 'rtos (mapcar 'cadar lst_pt)) '("Start Y")) (append (mapcar 'rtos (mapcar 'caddar lst_pt)) '("Start Z")) (append (mapcar 'rtos (mapcar 'caadr lst_pt)) '("End X")) (append (mapcar 'rtos (mapcar 'cadadr lst_pt)) '("End Y")) (append (mapcar 'rtos (mapcar 'caddar (mapcar 'cdr lst_pt))) '("End Z")) (append (mapcar 'rtos (mapcar 'caaddr lst_pt)) '("Middle X")) (append (mapcar 'rtos (mapcar 'cadadr (mapcar 'cdr lst_pt))) '("Middle Y")) (append (mapcar 'rtos (mapcar 'caddar (mapcar 'cddr lst_pt))) '("Middle Z")) ) (mapcar '(lambda (el) (vla-SetCellValue ename_cell n_row (setq n_column (1+ n_column)) (vlax-make-variant el 8)) (vla-SetCellTextStyle ename_cell n_row n_column "Text-Cell") (vla-SetCellTextHeight ename_cell n_row n_column (vlax-make-variant h_t 5)) (if (eq n_row 1) (vla-SetCellAlignment ename_cell n_row n_column 5) (vla-SetCellAlignment ename_cell n_row n_column 6) ) ) n ) (setq n_row (1- n_row) n_column -1) ) (setvar "dimzin" oldim) (setvar "clayer" oldlay) (prin1) )
    1 point
  2. Not sure why you are asking me about units, you could try making the variable names "Aunits". with double quotes, works in Bricscad, else you can use a foreach loop but I would use car & cadr in the loop, (list (list "aunits" 2)("list 'auprec"4)(......)) Just a suggestion for labelling, the character "A" is (chr 65) (chr x) so you can start with a number and each time you run the section lisp it will add 1 to the x, this will do up to 26. You can save the value of X by using ldata so when dwg is opened again you still have next value and can display that in a prompt. So Enter will give next value. Yes there is code for AA AB etc. Why not a dynamic block then can have a single stretch parameter based on the two pick points.
    1 point
×
×
  • Create New...