试一试:
- (defun c:VPortField (/ *error* DOC ENT OBJ PT UFLAG)
- (vl-load-com)
- ;; Lee Mac ~ 25.02.10
- (defun *error* (msg)
- (and UFlag (vla-EndUndoMark doc))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ))
-
- (while
- (progn
- (setq ent (car (entsel "\nSelect Viewport to Retrieve Scale: ")))
- (cond ( (eq 'ENAME (type ent))
- (if (eq "AcDbViewport"
- (vla-get-Objectname
- (setq Obj (vlax-ename->vla-object ent))))
- (if (setq pt (getpoint "\nSelect Point for Field: "))
- (progn
- (setq uFlag
- (not (vla-StartUndomark
- (setq doc
- (vla-get-ActiveDocument
- (vlax-get-acad-object)))))
- pt (trans pt 1 0))
- (vla-AddMText
- (if (zerop (vla-get-ActiveSpace doc))
-
- (if (eq :vlax-true
- (vla-get-mspace doc))
- (vla-get-ModelSpace doc)
- (vla-get-PaperSpace doc))
- (vla-get-ModelSpace doc))
- (vlax-3D-point pt) 0.
- (strcat "%<\\AcExpr %<\\AcObjProp Object(%<\\_ObjId "
-
- (itoa (vla-get-ObjectId obj))
- ">%).CustomScale >% * 2.0 \\f "1:%lu2%ct1%qf2816">%"))
- (setq uFlag (vla-EndUndomark doc))))
-
- (princ "\n** Object Must be a Viewport **"))))))
- (princ))
-
-
-
-
-
-
-
-
|