Author Topic: Calling a command  (Read 1122 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Calling a command
« on: March 10, 2017, 05:45:00 PM »
I have the following code, and I am trying to call the SBL command and have it select the previous selection with the ssget. Not understanding why it would error out with a simple command line.

The below is a example routine. I have others I would like to code similar to this if I can figure it out.

Code: [Select]
(defun c:SBL ()
(command "setbylayer" "al" "" "n" "y")
(princ)
)


(defun C:FixTheseBlocks ()

(ssget "x" '((0 . "INSERT")(2 .  "12CES,15CES,18CES,21CES,24CES,27CES,30CES,33CES,36CES,48CES")))

(C:SBL "previous" "")

(princ)
)

Thanks for all the help guys!
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Calling a command
« Reply #1 on: March 10, 2017, 05:59:33 PM »
Your function c:sbl is not defined to accept arguments, therefore you cannot supply two arguments ("previous" & "") when evaluating this function.

I would suggest:
Code - Auto/Visual Lisp: [Select]
  1. (defun sbl ( s ) (command "_.setbylayer" s "" "_n" "_y") (princ))
  2. (defun c:sbl ( ) (sbl "_all"))
  3. (defun c:FixTheseBlocks ()
  4.     (if (setq s (ssget "x" '((0 . "INSERT") (2 . "*CES") (2 . "12*,15*,18*,21*,24*,27*,30*,33*,36*,48*")))) (sbl s))
  5. )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Calling a command
« Reply #2 on: March 13, 2017, 07:08:04 AM »
Smaller is definitely easier to see. Thank you Lee.
Civil3D 2020

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: Calling a command
« Reply #3 on: March 13, 2017, 09:02:18 AM »
You're welcome - happy to help.