Results 1 to 5 of 5

Thread: Visual LISP: If and then?

  1. #1
    Active Member
    Join Date
    2007-02
    Location
    Calgary, Alberta, Canada
    Posts
    73
    Login to Give a bone
    0

    Default Visual LISP: If and then?

    Hey guys. First post on here! I've read alot on this site over the last year though.

    Now it's my turn to ask for help......

    I'm using visual lisp to modify registry entries. Modifying the entry isn't the problem though (since that part already works).

    What I would like to do, is write code using if and then (I think that would be the correct way) so that if it finds a certain registry key, it will modify it, and if it doesn't find the key, it doesn't modify anything.

    Here is part of my code already: I want it to find the Mechanical profile, and if it does, change the plot stamp entry to 1. If it doesn't find the Mechanical profile, go on to the CADWorx_Raptor profile and if it finds it, change the plot stamp to 1.

    Code:
     (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\Mechanical\\Dialogs\\Plot Stamp" "PlotStamp" 1)
     (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Raptor\\Dialogs\\Plot Stamp" "PlotStamp" 1)
    Anyone up for a small challenge?

  2. #2
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Visual LISP: If and then?

    You should be able to use a standard IF statement.

    Code:
    
    (if condition
      (vl-registry-write.......) ;; if condition is true
      (vl-registry-write.......) ;; if condition is false
    )
    
    R.K. McSwain | CAD Panacea |

  3. #3
    Active Member
    Join Date
    2007-02
    Location
    Calgary, Alberta, Canada
    Posts
    73
    Login to Give a bone
    0

    Default Re: Visual LISP: If and then?

    Thanks. Here is what I came up with. It's just the three bits and pieces I needed, and obviously not the whole lisp file.

    Code:
       
    (setq stampon (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Plant_2007\\Dialogs\\Plot Stamp" "PlotStamp"))
       (if (= stampon 0)
          (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Plant_2007\\Dialogs\\Plot Stamp" "PlotStamp" 1)
    
       )
    
    (setq stampfile (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_plant_2007\\Dialogs\\Plot Stamp" "PSPFilename"))
       (if (/= stampfile "J:/CAD/Plot Stamp.pss")
          (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Plant_2007\\Dialogs\\Plot Stamp" "PSPFilename" "J:/CAD/Plot Stamp.pss")
    
       )
    
    (setq savetime (vl-registry-read "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Plant_2007\\Editor Configuration" "AutomaticSaveMinutes"))
       (if (/= savetime 5)
          (vl-registry-write "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409\\Profiles\\CADWorx_Plant_2007\\Editor Configuration" "AutomaticSaveMinutes" 5)
    
       )

  4. #4
    Administrator rkmcswain's Avatar
    Join Date
    2004-09
    Location
    Earth
    Posts
    9,804
    Login to Give a bone
    0

    Default Re: Visual LISP: If and then?

    On your last point, if your goal is just to ensure that the autosave time is set to 5 - don't bother checking it, just set it.

    Code:
    
    (setvar "SAVETIME" 5)
    
    Looks like you could skip the IF statement in your second bit of code also.
    R.K. McSwain | CAD Panacea |

  5. #5
    Active Member
    Join Date
    2007-02
    Location
    Calgary, Alberta, Canada
    Posts
    73
    Login to Give a bone
    0

    Default Re: Visual LISP: If and then?

    Good point. I changed it to reflect that. Thanks for the time and space saver!
    Last edited by mikelf; 2008-04-17 at 10:54 PM.

Similar Threads

  1. visual lisp editor should be like visual studio
    By Wish List System in forum AutoCAD Wish List
    Replies: 1
    Last Post: 2011-11-17, 05:33 PM
  2. Programacion en Lisp y Visual Lisp
    By ralmavar in forum AutoCAD General
    Replies: 7
    Last Post: 2009-06-15, 01:52 PM
  3. Visual LISP vs VBA
    By lxpichet in forum AutoCAD Customization
    Replies: 14
    Last Post: 2009-04-07, 10:56 PM
  4. Replies: 2
    Last Post: 2008-02-01, 09:05 PM
  5. Visual Lisp and .Net
    By clopez_tcs in forum AutoCAD Customization
    Replies: 2
    Last Post: 2005-07-13, 01:04 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
  •