Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/27/2021 in all areas

  1. My attempt. (setq lst '(("aa" "A") ("bb" "B") ("cc" "A") ("dd" "C") ("ee" "D") ("ff" "B") ("gg" "C") ("hh" "A"))) Test: (while lst (setq itm (car lst)) (or (and (vl-some (function (lambda (x) (and (= (cadr itm) (cadr x)) (setq fnd x)))) itms) (setq itms (subst (list (strcat (car fnd) (car itm)) (cadr itm)) fnd itms)) ) (setq itms (cons itm itms)) ) (setq lst (vl-remove itm lst)) ) (reverse itms)
    1 point
  2. You can use following function to get desired result: (defun foo (l f / r z) (foreach x l (if (setq z (vl-some '(lambda (y) (if (f x (car y)) y ) ) r ) ) (setq r (subst (cons x z) z r)) (setq r (cons (list x) r)) ) ) (reverse (mapcar 'reverse r)) ) (setq lst (mapcar '(lambda (x) (cons (apply 'strcat (mapcar 'car x)) (cadar x)) ) (foo l (lambda (e1 e2) (equal (cadr e1) (cadr e2)))) ) ) Result: _$ (setq l '(("aa" "A") ("bb" "B") ("cc" "A") ("dd" "C") ("ee" "D") ("ff" "B") ("gg" "C") ("hh " "A"))) (("aa" "A") ("bb" "B") ("cc" "A") ("dd" "C") ("ee" "D") ("ff" "B") ("gg" "C") ("hh " "A")) _$ (setq lst (mapcar '(lambda (x) (cons (apply 'strcat (mapcar 'car x)) (cadar x)) ) (foo l (lambda (e1 e2) (equal (cadr e1) (cadr e2)))) ) ) (("aacchh " . "A") ("bbff" . "B") ("ddgg" . "C") ("ee" . "D"))
    1 point
  3. (defun C:00 (/ E1 E2 L1 L2 LST L0) (setq l0 nil l1 nil l2 nil) (setq lst (list '("aa" "A") '("bb" "B") '("cc" "A") '("dd" "C") '("ee" "D") '("ff" "B") '("gg" "C") '("hh " "A")) ) (setq l0 (mapcar '(lambda (x) (vl-remove-if '(lambda (y) (/= (cadr y) (cadr x))) lst)) (vl-sort lst '(lambda (e1 e2) (< (cadr e1) (cadr e2)))) ) ) (setq l1 (mapcar '(lambda (e1) (list (apply 'strcat (mapcar '(lambda (e2) (car e2)) e1)) (cadr (last e1))) ) l0 ) ) (setq l2 (LM:UniqueFuzz l1 1e-8)) (princ l2) (princ) ) (defun LM:UniqueFuzz (l f) (if l (cons (car l) (LM:UniqueFuzz (vl-remove-if (function (lambda (x) (equal x (car l) f))) (cdr l) ) f ) ) ) ) You try!
    1 point
  4. (defun C:ADDTAB (/ ss lista2d arealist index ename listpoint pointtable objtable) (if (not (setq ss (ssget '((0 . "LWPOLYLINE")(8 . "BOUNDARY"))))) (vl-exit-with-error "") ) (defun lista2d (lst) (if lst (cons (list (car lst) (cadr lst)) (lista2d (cddr lst)) ) ) ) (setq arealist '()) (repeat (setq index (sslength ss)) (setq ename (ssname ss (setq index (1- index)))) (setq listpoint (lista2d (safearray-value (variant-value (vla-get-Coordinates (vlax-ename->vla-object ename)))))) (if (not (setq sstext (ssget "_WP" listpoint '((0 . "MTEXT")(8 . "TABLE TEXT"))))) (ssdel ename ss) (setq arealist (cons (list (vla-get-Textstring (vlax-ename->vla-object (ssname sstext 0))) (vla-get-Area (vlax-ename->vla-object ename))) arealist)) ) ) (setq pointtable (getpoint "\nSelect point insertion table: ") objtable (vla-AddTable (vla-get-modelspace (vla-get-ActiveDocument (vlax-get-acad-object))) (vlax-3d-Point pointtable) (+ 2 (sslength ss)) 2 6 17) index 0 ) (vla-SetText objtable index 0 "AREA TABLE") (vla-SetCellTextHeight objtable index 0 2.40) (vla-SetCellAlignment objtable index 0 acMiddleCenter) (vla-SetText objtable (setq index (1+ index)) 0 "PLOT NO.") (vla-SetCellTextHeight objtable index 0 2.10) (vla-SetCellAlignment objtable index 0 acMiddleCenter) (vla-SetText objtable index 1 "AREA") (vla-SetCellTextHeight objtable index 1 2.10) (vla-SetCellAlignment objtable index 1 acMiddleCenter) (foreach elem arealist (vla-SetText objtable (setq index (1+ index)) 0 (car elem)) (vla-SetCellTextHeight objtable index 0 2.40) (vla-SetCellAlignment objtable index 0 acMiddleCenter) (vla-SetText objtable index 1 (rtos (cadr elem) 2 3)) (vla-SetCellTextHeight objtable index 1 2.10) (vla-SetCellAlignment objtable index 1 acMiddleCenter) ) ) This should be fine. The programme selects the polylines on the BOUNDARY layer, the vertices of the polylines act as a selection for any text inside. If there is no text, the polyline is deleted from the selection set, otherwise a list is created with the text string and the corresponding polyline area. The rest is easy, the table is created with the list data in the AREALIST variable.
    1 point
  5. Not sure what your doing wrong this is what you are talking about, but Autocad or Bricscad. Only way for any one to check would be to post a dwg and a pdf.
    1 point
×
×
  • Create New...