Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 10/14/2022 in all areas

  1. In my case I think the problem was caused by escaping out of the LISP command (it doesn't have error checking). I'd be tempted to sneak into your bosses LISP and changing it about a bit!
    1 point
  2. One of my bosses lisp keeps making a temp dcl file every time you use the command but doesn't delete it. So in my temp folder I got 1000's of 3kb dcl file. If you don't want to keep the txt file just put the delete command at the end of the lisp or after the open command. So its only there while the lisp is running. then you don't have to check for it when you run the lisp again.
    1 point
  3. If you're happy with this, Retable, by @exceed Then you can do this, then RETABLE it. (defun drawText (pt hgt str) (entmakex (list (cons 0 "TEXT") (cons 10 pt) (cons 40 hgt) (cons 1 str))) ) ;; command CMBL for Count Mtext By Layer (defun c:cmbl ( / ss i layer val subvalue sum_by_layer xy x y pt hgt rowhgt str) ;; user selects Mtext objects (setq ss (ssget (list (cons 0 "MTEXT")))) ;; associated list. (list (cons layer_name sum) ... ) (setq sum_by_layer (list)) (setq i 0) (repeat (sslength ss) ;; read the layer name and value. (setq layer (cdr (assoc 8 (entget (ssname ss i))))) (setq val (cdr (assoc 1 (entget (ssname ss i))))) ;; check if that value is a number. If there's anything else than a number we'll skip it (if (> (atof val) 0.0) (progn ;; check if that layer already has an associated sub sum (if (assoc layer sum_by_layer) (progn ;; (setq subsum (cdr (assoc layer sum_by_layer))) ;; read the already present value (setq subsum (+ subsum (atof val))) ;; add new value ;; now substitute the assoc value ... (subst new old list) (subst (cons layer subsum) (assoc layer sum_by_layer) sum_by_layer ) ) (progn ;; add that layer-value couple to the list (setq sum_by_layer (append sum_by_layer (list (cons layer (atof val))))) ) ) ) (progn ) ) (setq i (+ i 1)) ) (princ sum_by_layer) ;;;; Table (setq xy (getpoint "\nTable position: ")) (setq x (nth 0 xy)) (setq y (nth 1 xy)) (setq hgt 2.5) ;; text height (setq rowhgt 8) ;; row height ;; (drawText (list (+ x 24.0) y) hgt "COUNT") (setq y (- y rowhgt)) (drawText (list x y) hgt "ITEM") (drawText (list (+ x 24.0) y) hgt "LAYER") (drawText (list (+ x 60.0) y) hgt "QTY") (drawText (list (+ x 80.0) y) hgt "DESCRIPTION") (foreach row sum_by_layer (setq y (- y rowhgt)) (drawText (list x y) hgt "PIPE") (drawText (list (+ x 24.0) y) hgt (car row)) (drawText (list (+ x 60.0) y) hgt (rtos (cdr row) 2 2)) (drawText (list (+ x 80.0) y) hgt ".") ) (princ) )
    1 point
  4. I had a problem with one of my LISPs that was freezing, one of the things I did was delete the temp file (it made DCL box), and solved it, so I tend to do this by default now. My thinking at the time was that the text file wasn't properly closed - so deleting it did that for me (my thinking was probably wrong of course) - even though there should be no need to delete the file normally
    1 point
  5. You can make an associated list (list (cons layer_name sum) ... ) sum_by_layer holds that value. Can you take it from here (I haven't looked at generating tables in a while)? Need extra help? ;; command CMBL for Count Mtext By Layer (defun c:cmbl ( / ss i layer val subvalue sum_by_layer) ;; user selects Mtext objects (setq ss (ssget (list (cons 0 "MTEXT")))) ;; associated list. (list (cons layer_name sum) ... ) (setq sum_by_layer (list)) (setq i 0) (repeat (sslength ss) ;; read the layer name and value. (setq layer (cdr (assoc 8 (entget (ssname ss i))))) (setq val (cdr (assoc 1 (entget (ssname ss i))))) ;; check if that value is a number. If there's anything else than a number we'll skip it (if (> (atof val) 0.0) (progn ;; check if that layer already has an associated sub sum (if (assoc layer sum_by_layer) (progn ;; (setq subsum (cdr (assoc layer sum_by_layer))) ;; read the already present value (setq subsum (+ subsum (atof val))) ;; add new value ;; now substitute the assoc value ... (subst new old list) (subst (cons layer subsum) (assoc layer sum_by_layer) sum_by_layer ) ) (progn ;; add that layer-value couple to the list (setq sum_by_layer (append sum_by_layer (list (cons layer (atof val))))) ) ) ) (progn ) ) (setq i (+ i 1)) ) (princ sum_by_layer) (princ) )
    1 point
×
×
  • Create New...