Jump to content

my lisp stops when selection set = 0


vladthedog

Recommended Posts

I did try to search the forum before posting, but since I'm not even sure what I'm looking for I gave up on that. Ok, so I'm playing around with lisps. i have multiple setq lines that are using ssget to select items in various layers. The lisp works just fine when every layer that i use ssget has something in it. However, if a layer has no items then my lisp will stop working and just say "select objects". What do I need to do for the lisp to say to itself "ok, i am selecting 0 objects, lets move on" ? Thanks.

Link to comment
Share on other sites

We are going to need to see the code

 

Either attach as a file or paste it inline, using [noparse]

 

[/noparse] tags, like this:

 

(defun foo ()
 (function)
)

Link to comment
Share on other sites

don't laugh at it ;)

 

(defun c:danger (/ byby delcab deltext deldiv delsplash delsqft deldims)
 (setq byby (ssget))
 (command "_.ERASE" "_All" "_Remove" byby "")
 (prin1)
 (command "-layer" "s" "0" "")
 (setq delcab (ssget "x" '((8 . "cab lines"))))
 (setq deltext (ssget "x" '((8 . "text"))))
 (setq deldiv (ssget "x" '((8 . "drawing divider"))))
 (setq delsplash (ssget "x" '((8 . "splash"))))
 (setq delsqft (ssget "x" '((8 . "sqft"))))
 (setq deldims (ssget "x" '((0 . "dimension"))))
 (command "_.ERASE" delcab deltext deldiv delsplash delsqft deldims "")
)

Link to comment
Share on other sites

Maybe:

 

(defun c:danger (/ ss byby)
 (if (and (setq ss (ssget "x" '((8 . "cab lines,text,drawing divider,splash,sqft,dimension"))))
      (setq byby (ssget)))
   (progn
     (command "_.ERASE" "_All" "_Remove" byby "")
     (command "_.ERASE" ss""))
   (princ "\n<!> Nothing Found <!>"))
 (princ))
       

Link to comment
Share on other sites

Try replacing this...

 (setq delcab (ssget "x" '((8 . "cab lines"))))
 (setq deltext (ssget "x" '((8 . "text"))))
 (setq deldiv (ssget "x" '((8 . "drawing divider"))))
 (setq delsplash (ssget "x" '((8 . "splash"))))
 (setq delsqft (ssget "x" '((8 . "sqft"))))
 (setq deldims (ssget "x" '((0 . "dimension"))))
 (command "_.ERASE" delcab deltext deldiv delsplash delsqft deldims "")

 

...with this

 

 (if
   (setq sset (ssget "_X" '((8 . "cab lines,text,drawing divider,splash,sqft,dimension"))))
   (command "._ERASE" sset "")
 )

Link to comment
Share on other sites

If it is all dimension entities not a layer named dimension, then try this:

 [b][color=BLACK]([/color][/b]and
   [b][color=FUCHSIA]([/color][/b]setq ss
      [b][color=NAVY]([/color][/b]ssget [color=#2f4f4f]"X"[/color]
        [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons -4 [color=#2f4f4f]"<OR"[/color][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"DIMENSION"[/color][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"cab lines,text,drawing divider,splash,sqft"[/color][b][color=GREEN])[/color][/b]
              [b][color=GREEN]([/color][/b]cons -4 [color=#2f4f4f]"OR>"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
   [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.ERASE"[/color] ss [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

Link to comment
Share on other sites

If it is all dimension entities not a layer named dimension, then try this:

 [b][color=BLACK]([/color][/b]and
   [b][color=FUCHSIA]([/color][/b]setq ss
      [b][color=NAVY]([/color][/b]ssget [color=#2f4f4f]"X"[/color]
        [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons -4 [color=#2f4f4f]"<OR"[/color][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"DIMENSION"[/color][b][color=GREEN])[/color][/b]
                [b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"cab lines,text,drawing divider,splash,sqft"[/color][b][color=GREEN])[/color][/b]
              [b][color=GREEN]([/color][/b]cons -4 [color=#2f4f4f]"OR>"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
   [b][color=FUCHSIA]([/color][/b]command [color=#2f4f4f]"_.ERASE"[/color] ss [color=#2f4f4f]""[/color][b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

-David

 

 

Thanks David - completely missed the "0" for the dimension - must be blind... :P

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