Jump to content

Continue command when files are missing


rcb007

Recommended Posts

I am running into error when I am running my routine. It basically states a draworder based upon xref drawing names.

In some instances, the drawing I run this in does not have an Aerial , or Building. But usually once it activates that command it stops and does not finish the routine.

 

(command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 .  "*Aerial*"))) "" "_B")
(command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 .  "*Proposed*"))) "" "_B")
(command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 .  "*survey*"))) "" "_B")
(command "._DRAWORDER" (ssget "_x" '((0 . "INSERT")(2 .  "*Building*"))) "" "_B")

 

Anyone have an idea around this possibly? Thank you!

Link to comment
Share on other sites

Use if statements

If anything selected use Draworder command on the selection set else skip it

 

(if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*"))))
  (vl-cmdf "._DRAWORDER" SS "" "_B")
)
(if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Proposed*"))))
  (vl-cmdf "._DRAWORDER" SS "" "_B")
)
(if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*survey*"))))
  (vl-cmdf "._DRAWORDER" SS "" "_B")
)
(if (setq SS (ssget "_x" '((0 . "INSERT") (2 . "*Building*"))))
  (vl-cmdf "._DRAWORDER" SS "" "_B")
)

 

 

Edited by mhupp
Changed 'set to 'setq
Link to comment
Share on other sites

Here's another way to refactor it:

(foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*")
  (if (setq ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f))))
    (vl-cmdf "._DRAWORDER" ss "" "_B")
  )
)

Or if you're just sending them all to back without regard to each other:

(if (setq ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*"))))
  (vl-cmdf "._DRAWORDER" ss "" "_B")
)

 

Edited by ronjonp
*changed 'set to 'setq'
Link to comment
Share on other sites

Sorry to bring this up again. I do know what happened. It was working but now get the following error.

From what I see everything looks ok.

 

Command: basic
; error: bad argument type: symbolp nil

 

(defun c:Basic (/ ss)
(if (set ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*"))))
  (vl-cmdf "._DRAWORDER" ss "" "_B")
)

(foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*")
  (if (set ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f))))
    (vl-cmdf "._DRAWORDER" ss "" "_B")
  )
)
(princ))

 

Thank you for any help.

Link to comment
Share on other sites

3 minutes ago, rcb007 said:

Sorry to bring this up again. I do know what happened. It was working but now get the following error.

From what I see everything looks ok.

 


Command: basic
; error: bad argument type: symbolp nil

 


(defun c:Basic (/ ss)
(if (set ss (ssget "_x" '((0 . "INSERT") (2 . "*Aerial*,*Proposed*,*survey*,*Building*"))))
  (vl-cmdf "._DRAWORDER" ss "" "_B")
)

(foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*")
  (if (set ss (ssget "_X" (list '(0 . "INSERT") (cons 2 f))))
    (vl-cmdf "._DRAWORDER" ss "" "_B")
  )
)
(princ))

 

Thank you for any help.

Not sure what is going on but why are you running both of the draworder functions?

Link to comment
Share on other sites

i don't know but it has set instead of setq is that a thing?

 

(defun c:Basic ()
  (foreach f '("*Aerial*" "*Proposed*" "*survey*" "*Building*")
    (if (setq ss (ssget "_X" '((0 . "INSERT") (cons 2 f))))
      (vl-cmdf "._DRAWORDER" ss "" "_B")
    )
  )
(princ)
)

 

Link to comment
Share on other sites

10 minutes ago, mhupp said:

lol looks like we all did it.

Hahahaha .. that's what a copy paste gets you 😅

Edited by ronjonp
  • Like 1
Link to comment
Share on other sites

Interesting...  Something like that. It seems its working. so guilty with the copy paste thing lol. Thank you again guys!

  • Like 1
Link to comment
Share on other sites

For your info SET is a valid function used often to create variables on the fly.

(set 'a "abc")

(setq num 123)
(setq abc "werrt")
(set (read (strcat "X" (rtos num 2 0))) abc)

 

Edited by BIGAL
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...