rkent 发表于 2022-7-6 14:40:01

lisp file help, add text to di

I want to take some existing code I found over on another site and change it to add user input.I have added a getstring line but I don't know how to get the program to evaluate that later when needed.So I have a setq ndimtext line, and later I need it to use that setq string in the setq NewDimValue line.Hopefully that makes sense.
 

; original code from Mike Perry, AUGI NG(defun c:DimAddText (/ DimObject ndimtext NewDimValue) (setq ndimtext (getstring "Enter text to add to dim: "))(princ "\nSelect Dimension to add \(REF.\) to: ") (setq DimObject (ssget '((0 . "DIMENSION")))) (if (not (eq DimObject nil))(progn(setq NewDimValue "\\X\( ndimtext \)")(command "._DimEdit" "_N" NewDimValue DimObject "")) ) (princ))

Lee Mac 发表于 2022-7-6 15:08:22

Perhaps:
 

; original code from Mike Perry, AUGI NG(defun c:DimAddText(/ DimObject ndimtext NewDimValue) (vl-load-com) (setq ndimtext (getstring t "\nEnter text to add to dim: ")) (princ "\nSelect Dimension to add \(REF.\) to: ") (if (setq DimObject (ssget '((0 . "DIMENSION"))))   (foreach Obj(mapcar 'vlax-ename->vla-object                   (vl-remove-if 'listp                     (mapcar 'cadr                     (ssnamex DimObject))))   (vla-put-TextOverride Obj (strcat "\\X" ndimtext)))   (princ "\n No Dimensions Selected ")) (princ))

rkent 发表于 2022-7-6 15:29:11

LeeMac,
Thanks, that works great.
rkent

Lee Mac 发表于 2022-7-6 15:48:26

No probs rkent - if you need anything about the code explained, just ask
页: [1]
查看完整版本: lisp file help, add text to di