@pbejse wrote:
On this forum, you will get what you asked for marlance...
..
Command: ThistablesisNOTexploded
Select Table....
Wonder what happened to this request. The code I posted was meant to be funny ( no one is laughing :O, apparently not ), it is a literal solution based on the posted sample drawing. I had fun writing the code though.
Screencast will be displayed here after you click Post.
27c0bf98-a859-4951-97e8-226c197b7180
In any case, I'm posting another one that updating the "table" values and changing the color (could be commented if needed ). This time the table is exploded.
;;; pBe Feb2019 | Compare Plans and table value | Autodesk Forum ;;;
(defun c:whyisthetablesexploded ( / Near2point _Makeit5 Mtxt_Table ML_Collected _dxf _rtos _TheValues)
;;;; ;;;
(Defun Near2point (pt pts / p B e)
(setq e (list pt 1e12))
(while (setq p (car pts))
(if (< (setq B (distance pt p)) (cadr e) )
(setq e (list p B)))
(setq pts (cdr pts)))
(car e))
(defun _Makeit5 (l)
(if l
(cons
(list
(car l) (Cadr l) (caddr l)
(cadddr l) (cadddr (cdr l)) )
(_Makeit5 (cddddr (cdr l)))
)
)
)
(defun _TheValues (str / p)
(if (setq p (vl-string-search "\\P" str))
(cons (substr str 1 p) (_TheValues (substr str (+ 3 p))))
(reverse (cons str l))
)
)
(setq _Num (lambda (str)
(vl-some '(lambda (s)
(if (vl-string-search s str)
(vl-string-subst "" s str)))
'("EG=" "FG="))
)
)
;;;; ;;;
(setq Mtxt_Table nil ML_Collect nil BL_Collect nil)
(setq _dxf (lambda (d)(cdr (assoc d ent))))
(setq _rtos (lambda (n)(rtos n 2 3)))
(if
(and
(princ "\nSelect Table")
(setq Table (ssget '((0 . "MTEXT") (1 . "P##*#,#*#"))))
(princ "\nSelect Blocks & label")
(setq Blks&ML (ssget '((-4 . "<OR")
(-4 . "<AND")(0 . "INSERT")(2 . "PNT")(-4 . "AND>")
(0 . "MULTILEADER")
(-4 . "OR>"))))
)
(progn
(repeat (setq i (sslength Table))
(setq e (ssname Table (setq i (1- i))) ent (entget e))
(setq Mtxt_Table (cons (list (_dxf 10)(_dxf 1) e) Mtxt_Table))
)
(repeat (setq i (sslength Blks&ML))
(setq e (ssname Blks&ML (setq i (1- i))) ent (entget e) otype (_dxf 0))
(cond
( (eq otype "MULTILEADER")
(setq ML_Collect (Cons (list (_dxf 110) e) ML_Collect))
)
( (eq otype "INSERT")
(setq BL_Collect (Cons (_dxf 10) BL_Collect))
)
)
)
(setq Mtxt_Table
(mapcar 'cdr
(vl-sort Mtxt_Table
'(lambda (a b)
(cond
((> (cadar a) (cadar b)) T)
((equal (cadar a) (cadar b) 0.1)
(< (caar a) (caar b))
)
)
)
)
)
)
(and
(= (length ML_Collect)(length BL_Collect))
(foreach p_ ML_Collect
(setq ML_Collect (subst
(list (Near2point (Car p_) BL_Collect) (cadr p_)) p_ ML_Collect))
)
(setq ML_Collected
(mapcar '(lambda (itm)
(Setq ip (mapcar '_rtos (Car itm)) ent (entget (Cadr itm)))
(setq EG:PG (_TheValues (_dxf 304)))
(list
(car EG:PG) (_Num (cadr EG:PG))(_Num (caddr EG:PG))
(car ip)(cadr ip))
) ML_Collect)
)
(foreach info (_makeit5 Mtxt_Table)
(setq string_info (mapcar 'car info))
(if (setq f (vl-some '(lambda (d)
(if (and
(equal (car d) (Car string_info))
(not (equal d string_info))
)
d
)
)
ML_Collected
)
)
(progn
(setq ML_Collected (vl-remove f ML_Collected))
(mapcar '(lambda ( u v)
(if (not (eq (car u) V))
(progn
(Vla-put-color (vlax-ename->vla-object (Cadr u)) 2)
(vla-put-textstring
(vlax-ename->vla-object (Cadr u)) v)))
)
(Cdr info )(cdr f)
)
)
)
)
);and
);progn
);if
(princ)
);defun
(vl-load-com)
HTH