试试这个,
- ;; getblkename by ymg ;
- ;; ;
- ;; Original Code by Tim Wiley ;
- ;; Argument: Block Name ;
- ;; Returns: list of enames Block in Drawing ;
- (defun getblkename (blkname / blklst)
- (vlax-for obj (vla-get-ModelSpace (vla-get-ActiveDocument (vlax-get-Acad-Object)))
- (if (and (= (vla-get-ObjectName obj) "AcDbBlockReference")
- (= (vla-get-EffectiveName obj) blkname)
- )
- (setq blkLst (cons (vlax-vla-object->ename obj) blkLst))
- )
- )
- )
- (defun c:test (/ al bl el en pos stl svl)
- (setq bl (getblkename "RMELDER")
- al nil
- )
- (foreach ent bl
- (vl-cmdf "._-insert" "BISATT" (cdr (assoc 10 (entget ent))) 100.0 100.0 0.0)
- (setq al (cons (entlast) al))
- )
- (setq al (reverse al))
- (foreach e bl
- (setq en (entnext e)
- svl nil
- stl nil
- )
- (while (= (cdr (assoc 0 (setq el (entget en)))) "ATTRIB")
- (setq stl (cons (cdr (assoc 2 el)) stl)
- svl (cons (cdr (assoc 1 el)) svl)
- en (entnext en)
- )
- )
- (setq en (entnext (car al))
- al (cdr al)
- )
- (while (= (cdr (assoc 0 (setq el (entget en)))) "ATTRIB")
- (if (setq pos (vl-position (cdr (assoc 2 el)) stl))
- (entmod (subst (cons 1 (nth pos svl)) (assoc 1 el) el))
- )
- (setq en (entnext en))
- )
- )
- )
|