dingtiedt 发表于 2015-7-29 14:11
无意中在G版提供的lee-mac的页面看到了 “string to list”,正符合其中的一个构想,先取得多重引线的多行文 ...
LeeMac的函数可以做到
- ;; MLeader Textbox - Lee Mac
- (defun LM:mleadertextbox ( ent / bpt enx hgt jus lst mat org prp rot wid )
- (if (= acmtextcontent (cdr (assoc 172 (reverse (setq enx (entget ent))))))
- (progn
- (setq prp (list (cons 40 (cdr (assoc 41 enx)))
- (cons 07 (cdr (assoc 02 (entget (cdr (assoc 340 enx))))))
- )
- lst (vl-remove-if 'null
- (mapcar
- '(lambda ( str / box )
- (if (setq box (textbox (cons (cons 1 str) prp)))
- (mapcar '- (cadr box) (car box))
- )
- )
- (LM:str->lst (cdr (assoc 304 enx)) "\\P")
- )
- )
- bpt (trans (cdr (assoc 12 enx)) 0 (cdr (assoc 11 enx)))
- rot (cdr (assoc 042 enx))
- jus (cdr (assoc 171 enx))
- wid (apply 'max (mapcar 'car lst))
- hgt (+ (apply '+ (mapcar 'cadr lst)) (* 0.68 (cdr (assoc 45 enx)) (1- (length lst))))
- org (list (cond ((member jus '(2 5 8)) (/ wid -2.0)) ((member jus '(3 6 9)) (- wid)) (0.0))
- (cond ((member jus '(1 2 3)) (- hgt)) ((member jus '(4 5 6)) (/ hgt -2.0)) (0.0))
- )
- mat (list
- (list (cos rot) (sin (- rot)) 0.0)
- (list (sin rot) (cos rot) 0.0)
- '(0.0 0.0 1.0)
- )
- )
- (mapcar '(lambda ( p ) (mapcar '+ (mxv mat p) bpt))
- (list org
- (mapcar '+ org (list wid 0))
- (mapcar '+ org (list wid hgt))
- (mapcar '+ org (list 0 hgt))
- )
- )
- )
- )
- )
- ;; String to List - Lee Mac
- (defun LM:str->lst ( str del / pos )
- (if (setq pos (vl-string-search del str))
- (cons (substr str 1 pos) (LM:str->lst (substr str (+ pos 1 (strlen del))) del))
- (list str)
- )
- )
- (defun mxv ( m v )
- (mapcar '(lambda ( r ) (apply '+ (mapcar '* r v))) m)
- )
_$ (setq e (ssget "_+.:E:S" '((0 . "MULTILEADER"))))
(setq e (ssname e 0))
(LM:mleadertextbox e)
<Selection set: 383>
<Entity name: 7ee384f8>
((1920.97 605.151 0.0) (1947.5 605.151 0.0) (1947.5 609.285 0.0) (1920.97 609.285 0.0)) |