当命令处于活动状态时,存在以下情况:
- (defun c:zmblk (/ *error* StrBrk _3dPoint *ACAD BPNT DOC DPNT ELST FILE
- LST MAXP MINP NL OFILE PTS UFLAG)
- (vl-load-com)
- (defun *error* (msg)
- (and uFlag (vla-EndUndoMark doc))
- (and oFile (close oFile))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
- (defun StrBrk (str chrc / pos lst)
- (while (setq pos (vl-string-position chrc str))
- (setq lst (cons (substr str 1 pos) lst)
- str (substr str (+ pos 2))))
- (reverse (cons str lst)))
- [color=Red](setq _3dPoint (lambda (x) (vlax-3d-point (trans x 1 0))))[/color]
-
- (if (setq file (getfiled "Select Text File" (if *load *load "") "txt" )
- (progn
- (setq doc (vla-get-ActiveDocument (setq *acad (vlax-get-acad-object)))
- uflag (not (vla-startUndoMark doc)))
- (setq *load file ofile (open file "r"))
-
- (while (setq nl (read-line ofile))
- (princ nl)
- (setq lst (cons (car (StrBrk nl 9)) lst)))
- (setq ofile (close ofile))
-
- (if (setq elst (vl-remove-if 'null
- (mapcar 'handent
- (mapcar (function (lambda (x) (substr x 2))) (reverse lst)))))
-
- (foreach Obj (mapcar 'vlax-ename->vla-object elst)
- (vla-getBoundingBox Obj 'Minp 'Maxp)
-
- (setq pts (mapcar 'vlax-safearray->list (list Minp Maxp)))
- (vla-ZoomCenter *acad
- (vlax-3D-point (polar (car pts) (apply 'angle pts) (/ (apply 'distance pts) 2.))) 400.)
- (if (and (setq bPnt (getpoint "\nPick Base point: "))
- (setq dPnt (getpoint bPnt "\nPick Destination: ")))
- ;;(vl-cmdf "_.move" (vlax-vla-object->ename obj) "" bPnt dPnt))))
- [color=Red](vl-catch-all-apply 'vla-move (list obj (_3dPoint bPnt) (_3dPoint dPnt))))))[/color]
- (setq uflag (vla-EndUndoMark doc)))
-
- (princ "\n<< No File Selected >>"))
- (princ))
|