Jump to content

Recommended Posts

Posted

What is the best way to load lisp routines. In older versions it use to be acad.lsp

but AutoDesk changed that and sort of made it confusing.

Also, is there a way to make your lisp routines load for each drawing is opened?

I thought there was a variable setting for that?

 

Thank you,

  • Replies 20
  • Created
  • Last Reply

Top Posters In This Topic

  • alanjt

    9

  • woodman78

    7

  • muck

    2

  • jammie

    2

Posted

Alanjt,

 

one doesn't exist for 2010 vanilla. Do i create one? I tried this but my lisps still won't load. I want to run them from a ribbon panel by creating a new command. The new command contains as the macro the defun lisp title.

 

Am I going down the wrong route??

Posted
Alanjt,

 

one doesn't exist for 2010 vanilla. Do i create one? I tried this but my lisps still won't load. I want to run them from a ribbon panel by creating a new command. The new command contains as the macro the defun lisp title.

 

Am I going down the wrong route??

Yes, you have to create the acad.lsp and acaddoc.lsp.

Posted

So do i put all my load lisps (load "A1.lsp") into the acaddoc.lsp and what goes into the acad.lsp file????

Posted
So do i put all my load lisps (load "A1.lsp") into the acaddoc.lsp and what goes into the acad.lsp file????

Nothing, the acad.lsp will only load once per session, the acaddoc.lsp will load for everything drawing.

 

Also, when using load, put something either a sting or nil in the 2nd variable to avoid error stops in the event the file cannot be found.

 

Example:

Command: (load "alskdj")
LOAD failed: "alskdj"
Command: (load "alskdj" nil)
nil

Command: (load "alskdj" "Did not load!")
"Did not load!"

 

Also, look into autoload

(autoload "LayerOff" '("LF" "LayerOff"))

This will cut down on loading time, since it will only fully load the routine when you type in the alias for the first time.

Posted

I have a lisp routine called 7.lsp that loads a series of lisp other routines I created.

So load 7.lsp in acaddoc.lsp?

Where is acaddoc.lsp or if I have to make one where do I put it on a network

version of autocad?

Posted
I have a lisp routine called 7.lsp that loads a series of lisp other routines I created.

So load 7.lsp in acaddoc.lsp?

Where is acaddoc.lsp or if I have to make one where do I put it on a network

version of autocad?

You have to create the acaddoc.lsp file and place it in any support path. If it's for a group of users, put it on a network. Version doesn't matter.

  • 6 months later...
Posted

I have an acaddoc.lsp file made up like this:

 

(Load "Bgblock" "bgblock.lsp failed to load")

(Load "Bglegend" "bglegend.lsp failed to load")

(Load "Bglegend1" "bglegend1.lsp failed to load")

 

I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up?

Posted
I have an acaddoc.lsp file made up like this:

 

(Load "Bgblock" "bgblock.lsp failed to load")

(Load "Bglegend" "bglegend.lsp failed to load")

(Load "Bglegend1" "bglegend1.lsp failed to load")

 

I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up?

 

Yes, it will speed load times up.

 

Straight from my signature: Load/AutoLoad Usage

Posted
I have an acaddoc.lsp file made up like this:

 

(Load "Bgblock" "bgblock.lsp failed to load")

(Load "Bglegend" "bglegend.lsp failed to load")

(Load "Bglegend1" "bglegend1.lsp failed to load")

 

I have hundreds of lisps loading and it takes a while. How do I use autoload and will it help to speed things up?

 

I have a startup directory where I save all the Lisp files I want to be loaded into a drawing session. Using the following routine, which is saved into my Acaddoc.lsp, every lisp file saved into that directory gets autoloaded

 

(defun AutoLoadLispDir (dir / FileLIst)
 (vl-load-com)
 (if

   (setq FileLIst (vl-directory-files dir "*.lsp" 1))
    (progn
      (princ
 (strcat "\nLoading ["
	 (rtos (length Filelist) 2 0)
	 "] routines from "
	 dir
 )
      )
      (foreach	n FileLIst
 (setq LoadMsg "loaded ok!")
 (load (strcat dir "\\" n) nil)
 (princ (strcat "\n" n))
 (repeat (- 50 (strlen n)) (princ "."))
 (princ LoadMsg)
      )
    )
 )
)
(AutoLoadLispDir "c:\\AcadUser\\Lisp\\Startup" )

 

Just food for thought

Posted

I have something very similar to that for loading subroutines...

 

((lambda (path)
  (vl-load-com)
  (if (findfile path)
    (foreach file (vl-directory-files path "*.LSP")
      (load (strcat path "\\" file) nil)
    )
  )
)
 "C:\\AlanThompson\\LSP\\_Subs"
)

 

However, this will NOT help load times, AUTOLOAD will.

 

 

 

BTW, Jammie, you should read the link I posted. It explains the issues of using the load function and not filling the second parameter.

Posted

How do i structure a line for Autload? it isn't very clear on a few of the websites.

Posted
How do i structure a line for Autload? it isn't very clear on a few of the websites.

Did you read the link I posted?

Posted
Jammie, you should read the link I posted. It explains the issues of using the load function and not filling the second parameter.

 

Good point, thanks. Previous code updated

Posted
Good point, thanks. Previous code updated

You're welcome. :)

Posted

I got it now. I am browsing at 60% so i didn't see it.

Posted

Alanjt,

I have change my acaddod to use the autoload but now only the first lisp loads and none of the others do. Due to an error in the first lisp.

 

I get this after the lisp has run:

Command: A1 Unknown command "A1". Press F1 for help.

 

This is the lisp:

 
(defun c:A1 ()
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin"
       (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
       "*"
     )
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
(command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if
 (command "-plot" "n" "" "A1" "" "n" "y" "n")
 (command "regenall")
 (command "_zoom" "e" "")
 (princ)
)

 

What can be causing this? Do i need another (princ) somewhere to silence that?

Posted
Alanjt,

I have change my acaddod to use the autoload but now only the first lisp loads and none of the others do. Due to an error in the first lisp.

 

I get this after the lisp has run:

Command: A1 Unknown command "A1". Press F1 for help.

 

This is the lisp:

 
(defun c:A1 ()
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin"
       (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
       "*"
     )
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
(command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if
 (command "-plot" "n" "" "A1" "" "n" "y" "n")
 (command "regenall")
 (command "_zoom" "e" [color=Red]""[/color])
 (princ)
)

What can be causing this? Do i need another (princ) somewhere to silence that?

Remove the extra "" from the zoom call (marked in red). BTW, just out of curiosity, did you get the coding to import the PageSetups from

AT: PageSetups? It's just exact same coding I used.

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