w64bit Posted February 28, 2021 Posted February 28, 2021 Hi, I am using this code to change all text of 1.02 width to 1.0 width. The code is looking like this because I am using it in a SCR file (no defun necessary). (if (setq txtwd (ssget "_X" '((0 . "TEXT") (41 . 1.02) (410 . "Model")))) (progn (repeat (setq idx (sslength txtwd)) (entmod (subst '(41 . 1.0) '(41 . 1.02) (entget (ssname txtwd (setq idx (1- idx))))))) (princ))) What changes I have to do in order to use it to modify all text having the width >= 1.0? I think that the selection should be like this: (if (setq txtwd (ssget "_X" '((0 . "TEXT") (-4 . ">=") (41 . 1.0) (410 . "Model")))) Thank you Quote
Lee Mac Posted February 28, 2021 Posted February 28, 2021 (edited) Since the existing width factor could be any value greater than 1.0, you'll need to acquire the existing value for use within the subst expression, e.g.: (defun c:fixtw ( / i s x ) (if (setq s (ssget "_X" '((0 . "TEXT") (-4 . ">") (41 . 1.0) (410 . "Model")))) (repeat (setq i (sslength s)) (setq i (1- i) x (entget (ssname s i)) ) (entmod (subst '(41 . 1.0) (assoc 41 x) x)) ) ) (princ) ) Aside, I'm unsure why you are changing the structure of the function for use in an AutoCAD Script - I would suggest saving the above function to an AutoLISP file located in a trusted support path, and then loading & evaluating it from your Script using something like the following: (load "fixtw.lsp" nil) (if c:fixtw (c:fixtw)) Edited February 28, 2021 by Lee Mac 1 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.