See the top rated post in this thread. Click here

Results 1 to 7 of 7

Thread: Easiest question in the world for a LISP programmer? (Maybe)

  1. #1
    Active Member
    Join Date
    2009-01
    Posts
    57
    Login to Give a bone
    0

    Default Easiest question in the world for a LISP programmer? (Maybe)

    Code:
    (DEFUN C:JHKINSERT ( / )
    (setvar 'attdia 0)
    (setq jp1 (getstring "\nWhat type?: "))
    (COND ((= "FD1" JP1)(command "-insert" "c:\\JHK_MEP\\BLOCKS\\FD1.DWG" PAUSE "" "" "" "" ))
    ((= "FD2" JP1)(command "-insert" "c:\\JHK_MEP\\BLOCKS\\FD2.DWG" PAUSE "" "" "" "" ))
    )
    )

    This simple little condition is working without issue, but the problem I have is the FD1 is case sensitive. I can't help from feeling this is from using "getstring" but I can't get getkword to function at all. It keeps saying "Invalid option keyword" regardless of what's typed, even if it's a true statement.

    What is the proper way to use the code above with a variable based on user input?

    (I also tend to see often when my parenthesis aren't formed correctly "Use Command-S to invoke.." should I be using "command-s" instead of "command" here? I don't really know the differences.
    Last edited by rkmcswain; 2015-03-04 at 02:05 PM. Reason: added [CODE]

  2. #2
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    1

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    Hi ,

    Just wrap your variable with the function strcase everywhere it is placed in your routine like this :
    Code:
     (strcase jp1)
    The commnad-s call is the new form of the command call in Autocad 2015 so if you wanted to run a routine that uses command calls in CAD 2015 you need to add -s to the command .

  3. #3
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    1

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    You should look at the initget and getkword functions.
    Code:
     (DEFUN C:JHKINSERT ( / attdia jp1) localize those variables!
     (setq attdia (getvar "attdia"))
     (setvar 'attdia 0)
     (initget "FD1 FD2")
     (setq jp1 (strcase(getkword " [FD1/FD2]: ")))
     (COND
      ((= "FD1" JP1)(princ "\nFD1 = "))
      ((= "FD2" JP1)(princ "\nFD2 = "))
      ((= "FD1" JP1)(command "-insert" "c:\\JHK_MEP\\BLOCKS\\FD1.DWG" PAUSE "" "" "" "" ))
      ((= "FD2" JP1)(command "-insert" "c:\\JHK_MEP\\BLOCKS\\FD2.DWG" PAUSE "" "" "" "" ))
      (T(princ "\nInvalid input"))
     )
     (setvar 'attdia attdia)
     (princ)
    )
    Then you can either pick your option with the mouse or type it in.

  4. #4
    Active Member
    Join Date
    2009-01
    Posts
    57
    Login to Give a bone
    0

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    AMAZING! Thank you so much!!!!

  5. #5
    Active Member
    Join Date
    2009-01
    Posts
    57
    Login to Give a bone
    0

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    I'm going to have to read up on the initget, I'm just horrible at what I know in LISP. I'm self taught, so I don't know very much! I knew my variables weren't localized yet, as troubleshooting I find it easier to make them public, then close them up toward the final spit shine and polish!
    I tend to have to make multiple attempts to get my ""'s right, and () in the right count. Lost In Stupid Parenthesis for sure for me! haha

    I really appreciate everyone's help, I don't have any resources to talk to about this stuff other than google, so what takes some seconds, takes me hours!

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,106
    Login to Give a bone
    0

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    That's why we are here.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    All AUGI, all the time
    Join Date
    2010-06
    Posts
    962
    Login to Give a bone
    0

    Default Re: Easiest question in the world for a LISP programmer? (Maybe)

    To check if the search path of the blocks is found , would be more accurate and safe .

Similar Threads

  1. CP304-1: LISP: Advance Yourself Beyond a Casual Programmer
    By Autodesk University in forum Customization and Programming
    Replies: 0
    Last Post: 2014-12-01, 02:05 AM
  2. need lisp to use current ucs not world
    By Hammer.John.J in forum AutoLISP
    Replies: 3
    Last Post: 2010-01-15, 09:06 PM
  3. Easiest way to share a tool bar???
    By cmason in forum AutoCAD CUI Menus
    Replies: 10
    Last Post: 2008-05-30, 04:26 PM
  4. Easiest, quickest way to do a truss layout?
    By still.james in forum Revit Architecture - General
    Replies: 12
    Last Post: 2008-01-24, 06:56 PM
  5. World Trade Center Question (was: Ernest)
    By ernestatar in forum Revit Architecture - General
    Replies: 14
    Last Post: 2005-02-24, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •