Jump to content

Recommended Posts

Posted

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

Posted (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 by Lee Mac
  • Like 1
  • Thanks 1

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...