Jump to content

Recommended Posts

Posted

I have this lisp I made from a templete someone give why won't it work?

 

(defun c:seal ()

  (initget "Gene Jason Lynn Paul Stuart Todd"
(setq UsrName (getkword "\nEnter name [G]ene,[J]ason,[L]ynn,[P]aul,[s]tuart,[T]odd: ")
(command "-LA" "" "ON" "" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "THAW" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "" "");;run this for all users first
(cond
   ((= Usrname "Gene")
       (command "-LA" "" "OFF" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "THAW" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "" "");;GENE'S commands
   )
   ((= Usrname "Jason")
       (command "-LA" "" "OFF" "" "XTB|PE-GENE" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-TODD" "THAW" "XTB|PE-GENE" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "" "");;JASON'S commands
   )
   ((= Usrname "LYNN")
       (command "-LA" "" "OFF" "" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "THAW" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "" "");;LYNN'S commands
   )
   ((= Usrname "PAUL")
       (command "-LA" "" "OFF" "" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "THAW" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-STUART" "" "XTB|PE-TODD" "" "");;PAUL'S commands
   )        
   ((= Usrname "STUART")
       (command "-LA" "" "OFF" "" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-TODD" "THAW" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-TODD" "" "");;STUART'S commands
   )
   ((= Usrname "TODD")
       (command "-LA" "" "OFF" "" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "THAW" "XTB|PE-GENE" "" "XTB|PE-JASON" "" "XTB|PE-LYNN" "" "XTB|PE-PAUL" "" "XTB|PE-STUART" "" "");;TODD'S commands
   )
 )
)

 

It won't even run it, it will load it but not when I type seal it errors.

 

Thanks in advance for any help in the future.

Posted

Just a very quick glance, and I may be wrong but am not going to check right now, do you have enough ) and in the right place to close the ( ??

Posted

from LCE's reply, just add the red parenthesis in your lisp file

 

(initget "Gene Jason Lynn Paul Stuart Todd")

(setq UsrName (getkword "\nEnter name [G]ene,[J]ason,[L]ynn,[P]aul,tuart,[T]odd: "))

Posted

ok that works now when I select a name it runs the command for them is saying -La unknown command does anyone know why?

Posted

Sorry, I can not help you with this as I am not a big fan of lisp and won't spend the time looking at it now.

However, if you are not particularly fussed about having it in lisp, I can do it in VBA or VB.NET for you.

 

Let me know if you want that, if not, I am sure someone else will be along soon who does like lisp.

 

Cheers

 

EDIT: See, there you go, someone even beat me to it.

Posted

now it does not except the on in layers

Posted

try this format:

 

 

(defun c:seal ()

  (initget "Gene Jason Lynn Paul Stuart Todd")
(setq UsrName (getkword "\nEnter name [G]ene,[J]ason,[L]ynn,[P]aul,[s]tuart,[T]odd: "))
(command "_.layer" "" "ON" "" "XTB|PE-GENE,XTB|PE-JASON,XTB|PE-LYNN,XTB|PE-PAUL,XTB|PE-STUART,XTB|PE-TODD" "THAW" "XTB|PE-GENE,XTB|PE-JASON,XTB|PE-LYNN,XTB|PE-PAUL,XTB|PE-STUART,XTB|PE-TODD" "");;run this for all users first
(cond
   ((= Usrname "Gene")
       (command "_.layer" "OFF"  "XTB|PE-JASON,XTB|PE-LYNN,XTB|PE-PAUL,XTB|PE-STUART,XTB|PE-TODD" "THAW" "XTB|PE-JASON,XTB|PE-LYNN,XTB|PE-PAUL,XTB|PE-STUART,XTB|PE-TODD" "");;GENE'S commands
   )
   ...........
 )
)

Posted

Its works is there any way to make it run faster.

Posted

thanks for everything!

Posted

The problem looks like it is in your COMMAND line. After doing "-la" you have "" which tells Autocad to hit enter/space, which ends the layer command. You also have one after "ON" and between all your layer names, which are unnecessary. Also, you want to call "-layer". When using autocad commands in LISP, you have to call the complete command name as LISP doesn't recognize aliases set up in your ACAD.PGP file.

Posted

To make it a little faster, you might want to turn CMDECHO off before running all your COMMANDs.

Posted

is there a wa to turn mult layers off like maybe a comma in between them instead of "off" "layer" "off" "another layer"?

  • 4 months later...
Posted

You can turn on, off, freeze, thaw multiple layers at a time by using wildcards like "?" or "*" in your layer names. I'd suggest something like:

(command "_layer" "T" "XTB*" "OFF" "XTB*" "ON" "XTB|PE_PAUL" "")

for Paul's commands.

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