2
10
8
初来乍到
使用道具 举报
114
1万
中流砥柱
;; Put Field in Cell, by Lee McDonnell 11.07.2009(defun c:putfld (/ *error* doc spc chx ent Obj tStr flag grdat gr dat osPt tss lst row col) (vl-load-com) (defun *error* (msg) (and tObj (not (vlax-erased-p tObj)) (vla-delete tObj)) (if (not (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")) (princ (strcat "\n<< Error: " msg " >>")) (princ "\n*Cancel*")) (princ)) (setq doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) spc (if (zerop (vla-get-activespace doc)) (if (= (vla-get-mspace doc) :vlax-true) (vla-get-modelspace doc) ; Vport (vla-get-paperspace doc)) (vla-get-modelspace doc))) (or *mac (setq *mac "Select")) (while (progn (initget "Select Polyline Quit") (setq chx (getkword (strcat "\nSelect Object or Draw Polyline [sel/Poly/Quit] <" *mac "> : "))) (or (not chx) (setq *mac chx)) (setq flag nil) (cond ((eq "Quit" chx) nil) (t (cond ((eq "Select" *mac) (while (progn (setq ent (car (entsel "\nSelect Object: "))) (cond ((eq 'ENAME (type ent)) (if (not (and (vlax-property-available-p (setq Obj (vlax-ename->vla-object ent)) 'Area) (vlax-property-available-p Obj 'Length))) (princ "\n** Invalid Object Selected **"))) (t (princ "\n** Nothing Selected **")))))) ((eq "Polyline" *mac) (command "_.pline") (while (eq 1 (logand 1 (getvar 'CMDACTIVE))) (command pause)) (setq Obj (vlax-ename->vla-object (entlast))))) (if Obj (progn (repeat 2 (setq tStr (strcat "%<\\AcObjProp.16.2 Object(%<\\_ObjId " (vl-princ-to-string (vla-get-Objectid Obj)) ">%)." (if flag "Length" "Area") " \\f "%lu2%pr2">%")) (setq tObj (vla-addMText spc (vlax-3D-point '(0 0 0)) 0 tStr)) (vla-put-visible tObj :vlax-false) (princ (strcat "\nPlace " (if flag "Length" "Area") " Field...")) (while (progn (setq grdat (grread t 15 0) gr (car grdat) dat (cadr grdat)) (cond ((and (eq 5 gr) (listp dat)) (redraw) (vla-put-visible tObj :vlax-true) (vla-move tObj (vla-get-InsertionPoint tObj) (vlax-3D-point dat)) t) ((eq 2 gr) (cond ((vl-position dat '(32 13)) nil) (t t))) ((eq 25 gr) (and tObj (not (vlax-erased-p tObj)) (vla-delete tObj)) nil) ((eq 3 gr) (if (and (setq tss