Jump to content

Adding "if" command to only work if text at certain heights exists


Pnoraa1

Recommended Posts

Hi I created this lisp from parts of other lisps I found and it works fine to resize text that is height 8 and 6 to 0.2, however, it spits an error if there is no text in the drawing at 6 or 8mm.

 

Is anyone able to provide assistance as to how resolve this, I'm assuming I need to first check if text at each of these heights exists first but I can't find out how to do this.

 

(defun C:FIXTXT ()(vl-load-com)
(foreach ent (mapcar 'cadr (ssnamex (ssget "X" (list '(0 . "TEXT") (cons 40 6)))))
 (vla-put-height (vlax-ename->vla-object ent) 0.2))

(foreach ent (mapcar 'cadr (ssnamex (ssget "X" (list '(0 . "TEXT") (cons 40 8)))))
 (vla-put-height (vlax-ename->vla-object ent) 0.2))

 

Thanks

Link to comment
Share on other sites

Hi,

Welcome to the forum. :)

Try the following although it would be much better if you just used the DXF codes instead of converting each object to vla-object in this case but anyway that works as well.

 

(defun C:FIXTXT (/ ss)
  (if (setq ss (ssget "X" '((0 . "TEXT") (-4 . "<OR") (40 . 6) (40 . 8) (-4 . "OR>"))))
    (foreach ent (mapcar 'cadr (ssnamex ss))
      (vla-put-height (vlax-ename->vla-object ent) 0.2)
    )
  )
  (princ)
) (vl-load-com)

 

Link to comment
Share on other sites

  • 1 month later...

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...