Results 1 to 7 of 7

Thread: Run Lisp on Open

  1. #1
    I could stop if I wanted to de-co1's Avatar
    Join Date
    2005-07
    Location
    Jhb - ZA
    Posts
    274
    Login to Give a bone
    0

    Default Run Lisp on Open

    Hi All,

    It feels like years since I've been in AUGI... I'm back in the game now but have never got anywhere with lisps.

    I would like to know how to have a lisp run automatically. I have the following code that runs fine using the command line

    Code:
    (defun c:upu (/ OldLayer)
    (setq OldLayer (getvar "clayer"))
    (setvar "clayer" "0")
    (vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items.
    (vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items a second time, just in case.
    (vl-cmdf "._-purge" "r" "*" "N"); Purges all unreferenced, registered applications.
    (if (tblsearch "LAYER" OldLayer) ; Check to see if old layer still exsists
    (setvar "clayer" OldLayer) ; If old layer still exists set it back to current
    )
     )
    I firstly added the path to my own lisp folder and moved the path to the top of the support list. This lisp is also added in my startup. I read on another post that the OP's VPLOCK.lsp routine works automatically on opening a drawing and this would be handy too, but I don't understand how it runs automatically on opening. My knowledge in lisp is little to non-existent.

    http://forums.augi.com/showthread.ph...=automatically

  2. #2
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    Quote Originally Posted by de-co1 View Post
    Hi All,

    It feels like years since I've been in AUGI... I'm back in the game now but have never got anywhere with lisps.

    I would like to know how to have a lisp run automatically. I have the following code that runs fine using the command line

    Code:
    (defun c:upu (/ OldLayer)
    (setq OldLayer (getvar "clayer"))
    (setvar "clayer" "0")
    (vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items.
    (vl-cmdf "._-purge" "all" "*" "N"); Purges all unused items a second time, just in case.
    (vl-cmdf "._-purge" "r" "*" "N"); Purges all unreferenced, registered applications.
    (if (tblsearch "LAYER" OldLayer) ; Check to see if old layer still exsists
    (setvar "clayer" OldLayer) ; If old layer still exists set it back to current
    )
     )
    I firstly added the path to my own lisp folder and moved the path to the top of the support list. This lisp is also added in my startup. I read on another post that the OP's VPLOCK.lsp routine works automatically on opening a drawing and this would be handy too, but I don't understand how it runs automatically on opening. My knowledge in lisp is little to non-existent.

    http://forums.augi.com/showthread.ph...=automatically
    Welcome back, David!

    That code defines a function named "UPU" which can be invoked by command line as such, or what is known as 'called' by using this... Which can be placed after the DEFUN statement and will result in the code being evaluated when loaded:

    Code:
    (defun c:UPU (/ *error* clayer)
    
      (defun *error* (msg)
        (and clayer (tblsearch "layer" clayer) (setvar 'clayer clayer))
        (cond ((not msg))                                                   ; Normal exit
              ((member msg '("Function cancelled" "quit / exit abort")))    ; <esc> or (quit)
              ((princ (strcat "\n** Error: " msg " ** ")))                  ; Fatal error, display it
        )
        (princ)
      )
    
      (setq clayer (getvar 'clayer))
      (setvar 'clayer "0")
      (command "._undo" "_e" "._undo" "_be" "._-purge" "_a" "*" "_n"
               "._-purge" "_a" "*" "_n" "._-purge" "_r" "*" "_n" "._undo"
               "_e"
              )
      (*error* nil)
    )
    (c:UPU)


    As for purging registry applications (aka regapps), you may find this to be of use.

    Cheers
    Last edited by BlackBox; 2014-10-23 at 01:10 PM.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  3. #3
    Member
    Join Date
    2015-10
    Location
    Alhambra
    Posts
    27
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    To have this function run automatically, locate acaddoc.lsp and open it with Notepad. Then include at end this code:

    Code:
    (c:upu)
    You can read up more about what acaddoc.lsp and acad.lsp does at this link:
    http://forums.autodesk.com/t5/visual...sp/td-p/883468

    Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator | Layer Apps | List on Steroids | VP Zoom Scales
    Exchange App Store
    Paul Li
    Senior Associate
    ALTOON PARTNERS LLP
    Los Angeles • Amsterdam • Shanghai
    617 West 7th Street • Suite 400 • Los Angeles • California • 90017-3889
    D +1 213 225 1944 • T +1 213 225 1900 • www.altoonpartners.com
    Last edited by BlackBox; 2014-10-23 at 08:41 PM. Reason: Please use [CODE] Tags

  4. #4
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    Quote Originally Posted by pli View Post
    To have this function run automatically, locate acaddoc.lsp and open it with Notepad. Then include at end this code:

    Code:
    (c:upu)
    The OP stated this LISP has been added to their 'startup'.

    *IF*... That is indicative of 'Startup Suite' then this suggestion will result in an error, _unless_ one also precedes the function's call with the function's definition, within AcadDoc.lsp, as Startup Suite routines are not loaded until after all Acad* files, and CUI-associated files have been loaded in the Startup Sequence.

    For those using 2012+ versions, the Autoloader mechanism is another option for customizations as well.

    Cheers



    [Edit] - Also, please remove your signature from the body of your posts, and instead add to your forum signature... Control Panel, My Settings, Edit Signature.
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

  5. #5
    Member
    Join Date
    2015-10
    Location
    Alhambra
    Posts
    27
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    BlackBox, thanks for the instructions on filling in my signature. I didn't know how to do this.
    Last edited by pli; 2014-10-24 at 12:17 AM.

  6. #6
    Member
    Join Date
    2015-10
    Location
    Alhambra
    Posts
    27
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    should show signature now.
    Thanks BlackBox
    Last edited by pli; 2014-10-24 at 07:02 AM.

  7. #7
    Administrator BlackBox's Avatar
    Join Date
    2009-11
    Posts
    5,719
    Login to Give a bone
    0

    Default Re: Run Lisp on Open

    Quote Originally Posted by pli View Post
    BlackBox, thanks for the instructions on filling in my signature. I didn't know how to do this.
    Quote Originally Posted by pli View Post
    should show signature now.
    Thanks BlackBox
    No worries; we all start somewhere.

    Cheers
    "How we think determines what we do, and what we do determines what we get."

    Sincpac C3D ~ Autodesk Exchange Apps

    Computer Specs:
    Dell Precision 3660, Core i9-12900K 5.2GHz, 64GB DDR5 RAM, PCIe 4.0 M.2 SSD (RAID 0), 16GB NVIDIA RTX A4000

Similar Threads

  1. Replies: 3
    Last Post: 2009-02-12, 10:19 PM
  2. How to open a file with a lisp code?
    By ccatinean in forum AutoLISP
    Replies: 11
    Last Post: 2009-01-19, 01:08 PM
  3. Lisp command for open dwg file.
    By lucianno in forum AutoLISP
    Replies: 4
    Last Post: 2007-11-14, 01:34 AM
  4. LISP routine to open a DWG
    By katkinson0082914 in forum AutoLISP
    Replies: 6
    Last Post: 2006-09-04, 01:42 AM

Posting Permissions

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