本帖最后由 csharp 于 2017-3-3 21:44 编辑

- (defun c:tt (/ ss _getatt a4 al lst getposition)
- (defun _getatt (l tag)
- (car (vl-remove-if-not
- (function (lambda (x) (= (xdrx_getpropertyvalue x "tag") tag)))
- l
- )
- )
- )
- (defun getposition (b p str / p1 v l atts)
- (setq p1 (xdrx_getpropertyvalue b "position")
- v (mapcar '- p1 (mapcar '+ '(4.5 5.0 0) p))
- l (mapcar 'fix (mapcar '/ v '(36.0 50.0 1.)))
- atts (xdrx_getpropertyvalue b "attributeentities")
- )
- (list (xdrx_getpropertyvalue (_getatt atts "WIRENO") "textstring")
- (_getatt atts "XREF")
- (strcat "/"
- str
- "."
- (itoa (1+ (car l)))
- (chr (+ 65 (cadr l)))
- )
- )
- )
- (if (and (setq ss (ssget '((0 . "INSERT") (2 . "HA1S1"))))
- (setq a4 (ssget "x" '((0 . "INSERT") (2 . "A4"))))
- )
- (progn
- (setq al (xdrx_pickset->ents ss)
- lst (mapcar
- '(lambda (x / p2 atts no l)
- (mapcar 'set '(p2 atts box) (xdrx_getpropertyvalue x "position" "attributeentities" "boundingbox"))
- (setq no (last (xdrx_string_split
- (xdrx_getpropertyvalue (_getatt atts "4") "textstring")
- "-"
- )
- )
- )
- (setq l (vl-remove-if-not
- (function (lambda (a)
- (xdrx_point_isinside (xdrx_getpropertyvalue a "position") box)
- )
- )
- al
- )
- )
- (if l
- (progn
- (foreach i l (setq al (vl-remove i al)))
- (mapcar '(lambda (a) (getposition a p2 no)) l)
- )
- nil
- )
- )
- (xdrx_pickset->ents a4)
- )
- lst (xd::list:groupbyindex (apply 'append lst) 0)
- )
- (mapcar '(lambda (x)
- (if (= (length x) 2)
- (progn
- (xdrx_setpropertyvalue (caar x) "textstring" (cadadr x))
- (xdrx_setpropertyvalue (caadr x) "textstring" (cadar x))
- )
- )
- )
- (mapcar 'cdr lst)
- )
- )
- )
- (princ)
- )
|