Jump to content

Error in my code, Changing text in a layer to a other text style.


yonderbob

Recommended Posts

Hello,

 

I have my code and it works fine untill i have a layer in my drawing, where there are no text entity's in. If that is the case i get the following error;

"Command: ; error: bad argument type: lselsetp nil"

I have tried to add a If statement nil on my variable L14 but that did not remove the problem.

So to clarify: i belive the problem occurs because i have a layer but there is no "text" in that specific layer in the specific drawing. In other drawings there are so the code is needed and works if there is text.

Could anyone help me with the correct if statement to resolve this problem.

 

 

  (setq L14 (tblsearch "layer" "E_B_KV23_KABEL_LABEL_VB"))
 (if (/= L14 nil)
   (progn
       (setq cnt 0 sset (ssget "x" '((8 . "E_B_KV23_KABEL_LABEL_VB"))))(setq len(sslength sset))(setq valid 0 erms "")
(setq cnt 0)
 (while (> len 0)
      (setq en (ssname sset 0))
      (if (= (cdr (assoc 0 (entget en))) "TEXT")
       (progn(command "change" en "" "" "" "isocp2_08" "" "" )(setq cnt(+ cnt 1))
     )
)
(setq sset (ssdel en sset))(setq len(- len 1))
)
   )
 )
 (if (= L14 nil)
   (setq L14 nil)
 )

 

Thanks in advance,

 

Bob

Link to comment
Share on other sites

This Line

(setq len(sslength sset)) and the rest after that will run regardless of the result of (setq cnt 0 sset (ssget "x" '((8 . "E_B_KV23_KABEL_LABEL_VB")))) Nil or not

 

so try changing it to:

 

 
(if (and  (/= L14 nil)
            (setq cnt 0 sset (ssget "x" '((8 . "E_B_KV23_KABEL_LABEL_VB")))))
(progn
              (setq len(sslength sset))(setq valid 0 erms "")......

Link to comment
Share on other sites

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