yonderbob Posted September 2, 2011 Share Posted September 2, 2011 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted September 2, 2011 Share Posted September 2, 2011 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 "")...... Quote Link to comment Share on other sites More sharing options...
yonderbob Posted September 2, 2011 Author Share Posted September 2, 2011 Thanks alot pBe. That solved the problem like a charm . bob Quote Link to comment Share on other sites More sharing options...
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.