Startup Lisp Routine

Startup Lisp Routine

ODO18
Advocate Advocate
2,856 Views
13 Replies
Message 1 of 14

Startup Lisp Routine

ODO18
Advocate
Advocate

Our company has a startup lisp routine that we run from the appload startup suite in Vanilla CAD and Civil 3D.  It seems the CMDECHO is not resetting back to 1.  This lisp routine has been around for a while and we just add to the middle so I thought I would post the whole thing just in case anyone has any recommendations on any of it, but hopefully the answer is just in the bottom in the "Settings at LISP close" part.

 

;;Company Name
;;Company-wide custom lisp routines to be loaded with AutoCAD Civil 3D - Revised 03-18-2021

 

:------------------

 

(defun lalf ()

 

;;SETTINGS AT LISP OPEN
  (SETVAR "cmdecho" 0)

 

;;COMMANDS & SYSTEM VARIABLES
  (COMMAND "MAXSORT" "5000")
  (COMMAND "HPORIGINMODE" "5")

 

;;LOAD LISPS
  ;;path for lisp
  (setq b:lsppath "x:\\_autocad\\lsp\\")

 

  ;;path to blocks used by lisp routines
  (setq b:blkpath "x:\\_autocad\\lsp\\blks\\")

 

(load (strcat b:lsppath "civilobjectson"))
(load (strcat b:lsppath "cena"))
(load (strcat b:lsppath "ddeans"))
(load (strcat b:lsppath "demolish"))
(load (strcat b:lsppath "dho"))
(load (strcat b:lsppath "dis"))
(load (strcat b:lsppath "dvdwg"))
(load (strcat b:lsppath "dvo"))
(load (strcat b:lsppath "em"))
(load (strcat b:lsppath "featurelinequickkeys"))
(load (strcat b:lsppath "fndshape"))
(load (strcat b:lsppath "ho"))
(load (strcat b:lsppath "inv"))
(load (strcat b:lsppath "lblarea"))
(load (strcat b:lsppath "ll"))
(load (strcat b:lsppath "MergeHatch"))
(load (strcat b:lsppath "Narrow"))
(load (strcat b:lsppath "parea"))
(load (strcat b:lsppath "pld"))
(load (strcat b:lsppath "rarea"))
(load (strcat b:lsppath "rc"))
(load (strcat b:lsppath "SETPRINT"))
(load (strcat b:lsppath "slope"))
(load (strcat b:lsppath "systemvariables"))
(load (strcat b:lsppath "ta"))
(load (strcat b:lsppath "tl"))
(load (strcat b:lsppath "tlen"))
(load (strcat b:lsppath "tWlsp"))
(load (strcat b:lsppath "VP(UN)LOCK"))
(load (strcat b:lsppath "VPLOCK"))
(SETQ ABCDEF (GETVAR "DWGNAME"))
)

 

;;SETTINGS AT LISP CLOSE
  (SETVAR "cmdecho" 1)

 

;;----------

 

;;----------
(lalf)
(print "Loading Custom Lisp Routines")
(print "Revised 03/18/2021")
(princ)

0 Likes
2,857 Views
13 Replies
Replies (13)
Message 2 of 14

Moshe-A
Mentor
Mentor
Accepted solution

@ODO18 ,


@ODO18 wrote:

  It seems the CMDECHO is not resetting back to 1.

 

if there is an error in one (or more) loaded lisp files then the code is stopped. to find the file arising the error start by commenting half of the code and narrow it each step by half until you'll find it 😀

 

Moshe

 

 

0 Likes
Message 3 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

Since you use only the two (command) functions right after setting CMDECHO to 0, and since it only affects (command) functions echoing their prompts to the command line, I would suggest resetting it to 1 immediately after those, and before any of the AutoLisp (setq)/(load) functions.  Then, even if some function later fails to load, and causes the rest of the (load) operations to not happen [which you should still investigate], at least CMDECHO will be reset.

 

By the way, if you put that AutoLisp filepath into the Support File Search Path list in OPTIONS, you don't need to include it again and again, in every (load) function, and those functions can be simply:

  (load "civilobjectson")
  (load "cena")

etc.

Kent Cooper, AIA
0 Likes
Message 4 of 14

ODO18
Advocate
Advocate
Great idea. Unfortunately deleting everything but the top and then everything but the bottom one, both scenarios returned the same result. So not sure it could be all of them. But a good solution to testing and will allow me to figure out more.
0 Likes
Message 5 of 14

ODO18
Advocate
Advocate
Good point. Thank you that worked. One of our LISP requests for system variable changes, but I am not sure why I could not just pull those out and add them to the other commands and variables. Besides that it seems the other ones are unaffected by moving that up.
0 Likes
Message 6 of 14

ВeekeeCZ
Consultant
Consultant
Accepted solution

@ODO18 wrote:

Our company has a startup lisp routine that we run from the appload startup suite in Vanilla CAD and Civil 3D.  It seems the CMDECHO is not resetting back to 1.  This lisp routine has been around for a while and we just add to the middle so I thought I would post the whole thing just in case anyone has any recommendations on any of it, but hopefully the answer is just in the bottom in the "Settings at LISP close" part.

 

;;Company Name
;;Company-wide custom lisp routines to be loaded with AutoCAD Civil 3D - Revised 03-18-2021

 

:------------------

 

(defun lalf ()

 

;;SETTINGS AT LISP OPEN
  (SETVAR "cmdecho" 0)

 

;;COMMANDS & SYSTEM VARIABLES
  (COMMAND "MAXSORT" "5000")
  (COMMAND "HPORIGINMODE" "5")

 

;;LOAD LISPS
  ;;path for lisp
  (setq b:lsppath "x:\\_autocad\\lsp\\")

 

  ;;path to blocks used by lisp routines
  (setq b:blkpath "x:\\_autocad\\lsp\\blks\\")

 

(load (strcat b:lsppath "civilobjectson"))
(load (strcat b:lsppath "cena"))
(load (strcat b:lsppath "ddeans"))
(load (strcat b:lsppath "demolish"))
(load (strcat b:lsppath "dho"))
(load (strcat b:lsppath "dis"))
(load (strcat b:lsppath "dvdwg"))
(load (strcat b:lsppath "dvo"))
(load (strcat b:lsppath "em"))
(load (strcat b:lsppath "featurelinequickkeys"))
(load (strcat b:lsppath "fndshape"))
(load (strcat b:lsppath "ho"))
(load (strcat b:lsppath "inv"))
(load (strcat b:lsppath "lblarea"))
(load (strcat b:lsppath "ll"))
(load (strcat b:lsppath "MergeHatch"))
(load (strcat b:lsppath "Narrow"))
(load (strcat b:lsppath "parea"))
(load (strcat b:lsppath "pld"))
(load (strcat b:lsppath "rarea"))
(load (strcat b:lsppath "rc"))
(load (strcat b:lsppath "SETPRINT"))
(load (strcat b:lsppath "slope"))
(load (strcat b:lsppath "systemvariables"))
(load (strcat b:lsppath "ta"))
(load (strcat b:lsppath "tl"))
(load (strcat b:lsppath "tlen"))
(load (strcat b:lsppath "tWlsp"))
(load (strcat b:lsppath "VP(UN)LOCK"))
(load (strcat b:lsppath "VPLOCK"))
(SETQ ABCDEF (GETVAR "DWGNAME"))
)

 

;;SETTINGS AT LISP CLOSE
  (SETVAR "cmdecho" 1)

 

;;----------

 

;;----------
(lalf)
(print "Loading Custom Lisp Routines")
(print "Revised 03/18/2021")
(princ)


The only issue is that cmd reset lies outside the function.

0 Likes
Message 7 of 14

Sea-Haven
Mentor
Mentor
Accepted solution

Just a suggestion whilst your loading lots of lisps how many get used in a session 3-4 ? Using Autoload instead of load means they are ready to be used but load when actually required.

(autoload "COPY0" '("COPY0"))
(autoload "COPYCOMMAND" '("ZZZ"))
(autoload "COVER" '("COVER"))
(autoload "DIMFLIP" '("DIMFLIP"))

 

0 Likes
Message 8 of 14

TomBeauford
Advisor
Advisor

Why not just replace:

;;SETTINGS AT LISP OPEN
  (SETVAR "cmdecho" 0)

 

;;COMMANDS & SYSTEM VARIABLES
  (COMMAND "MAXSORT" "5000")
  (COMMAND "HPORIGINMODE" "5")

with:

(setvar 'HPORIGINMODE 5)
(setvar 'MAXSORT 5000)

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes
Message 9 of 14

ODO18
Advocate
Advocate

Do you have a good link or anything to explain autoload a little better and how it should be written and how it works?  I cannot seem to find anything.  When I put auto in front of load it returns an error when loading the lisp routine.

 

Thank you,

0 Likes
Message 10 of 14

ODO18
Advocate
Advocate

Is there a good way to know which prompts I should do as setvar and which ones I should do as commands?  For example I have another lisp that I could not figure out what the issue was until I narrowed it down to the dwgprefix variable.  When I typed in the command in CAD it showed the infinity symbol next to it which is what I have been using to know if something is a variable or a command.  So even though dwgprefix is a variable I switched it to command and then everything worked fine.

0 Likes
Message 12 of 14

Kent1Cooper
Consultant
Consultant

@ODO18 wrote:

Do you have a good link or anything to explain autoload a little better and how it should be written and how it works?  ....


See >Help about it<.

Kent Cooper, AIA
0 Likes
Message 13 of 14

Kent1Cooper
Consultant
Consultant
Accepted solution

@ODO18 wrote:

Is there a good way to know which prompts I should do as setvar and which ones I should do as commands?  .... the dwgprefix variable.  .... even though dwgprefix is a variable I switched it to command and then everything worked fine.


That one's a Read-only System Variable [see >here<], so you can't use (setvar) on it, but you can read what's in it with (getvar).  Commands can be used to change some of those that can't be done with (setvar).

 

Using (setvar) [for those it can be used for] will be faster than using (command), though you'd never notice the difference unless you're doing it with very large quantities of them.  Since one (command) function can contain as many command operations as you want, I sometimes use it to set such things if adjacent to and related to other commands, to avoid the need to end a (command) function, do a (setvar), and start another (command) function.  A simple example:

 

  (command

    "_.undo" "_mark"

    "_.layer" "_set" "MyDesiredLayer" ""

    "_.plinegen" 1 ; ensure Polyline linetype generation is on

    "_.osmode" 163 ; END/MID/INT/PER running Osnap combination

    "_.pline"

    ....

Kent Cooper, AIA
0 Likes
Message 14 of 14

TomBeauford
Advisor
Advisor

Others like AREA have a different function as commands -vs- system variables: https://help.autodesk.com/view/ACD/2021/ENU/?guid=GUID-CD078D73-FE99-49A0-8FFA-0D2FFA906167

64bit AutoCAD Map & Civil 3D 2023
Architecture Engineering & Construction Collection
2023
Windows 10 Dell i7-12850HX 2.1 Ghz 12GB NVIDIA RTX A3000 12GB Graphics Adapter
0 Likes