Jump to content

Recommended Posts

Posted

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!

Posted (edited)

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
Posted

Awesome! that makes sense...

Posted (edited)

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'
Posted

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.

Posted
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?

Posted

Sorry i was using it to test with. I just commented out the other line.

Posted

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

 

Posted

lol looks like we all did it.

Posted (edited)
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
Posted

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

  • Like 1
Posted (edited)

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
Posted

Another example:

(mapcar 'set '(a b c) '(1 2 3))
(mapcar 'print (list a b c))

 

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