PDA

View Full Version : acaddoc.lsp for AutoCAD Mechanical 2006



rmoore
2005-10-03, 07:09 PM
We are in the process of switching over from AutoCAD 2004 to AutoCAD Mechanical 2006. In past AutoCAD versions, I had always loaded custom lisp routines via the s::startup routine in the acaddoc.lsp file. WIth mechanical, when I open that file I get this:


;;;*-*TXT acad.lsp is loaded once, acaddoc.lsp is loaded for each
;;; document, s::startup in any case is called after acaddoc.lsp
;;; has been loaded
;
;;(if (= nil acad_helpdlg)
;; (progn
;; (load "acadr15.lsp")
;; (load (strcat (getvar "menuname") ".mnl"))
;; )
;;)
(if (= nil genlade)
(progn
(princ (load "gen/acadm.lsp" "\nError: acadm.lsp not loaded!"))
(if acadmappend (setq s::startup (acadmappend s::startup)))
)
)

This is the line that I dont understand:

(if acadmappend (setq s::startup (acadmappend s::startup)))

I tried putting the s::startup code after the if statement, which worked, but then some of the mechanical functions stopped working and I would get error messages like this:


amconsthor ; error: no function definition: GENLADEThe code for the acadm.lsp file is formated in a way that makes it difficult for me to decipher.

Here is the code for the acadm.lsp file mentioned in the acaddoc.lsp lisp routine:

(defun AcadMappend(startup / )(if (cond ((/= T(load"gen/genbas0.lsp"T))T)((/= T(load"gen/genbas0.ll"T))T)((/= T (if ge0geniusdir (load(strcat ge0geniusdir"gen/genbas0.lsp")T) T )) T )((/= T (if geniuspd (load(strcat(geniuspd)"gen/genbas0.lsp")T) T )) T )(T nil) )(append (list (if startup (car startup) nil )(list (quote acadmstartup)))(cdr startup))(progn (prompt"\nAcadM Error: file genbas0.lsp not loaded.") startup ))) (defun genneuzeich()(redraw))(if(=(type *error*)'SUBR)(setq *error* nil))(if(not special)(defun special(a)a)) (defun c:amlayer_con1()(command"_amlayer""_o""con1")(princ))(defun c:amlayer_con2()(command"_amlayer""_o""con2")(princ))(defun c:amlayer_con3()(command"_amlayer""_o""con3")(princ))(defun c:amlayer_hidw()(command"_amlayer""_o""hidw")(princ))(defun c:amlayer_hidn()(command"_amlayer""_o""hidn")(princ))(defun c:amlayer_hlin()(command"_amlayer""_o""hlin")(princ))(defun c:amlayer_dili()(command"_amlayer""_o""dili")(princ))(defun c:amlayer_txt3()(command"_amlayer""_o""txt3")(princ))(defun c:amlayer_cenw()(command"_amlayer""_o""cenw")(princ))(defun c:amlayer_cenn()(command"_amlayer""_o""cenn")(princ))(defun c:amlayer_hatch()(command"_amlayer""_o""hatc")(princ))(defun c:amlayer_vpli()(command"_amlayer""_o""vpli")(princ))(defun c:amlayer_phan()(command"_amlayer""_o""phan")(princ)) (defun c:amunit_0()(gensv)(gendimsetdecimals 0)(command"_UNITS"2 0 1 0 0"_N")(genprompt"xx.")(genun)(princ))(defun c:amunit_1()(gensv)(gendimsetdecimals 1)(command"_UNITS"2 1 1 1 0"_N")(genprompt"xx.x")(genun)(princ))(defun c:amunit_2()(gensv)(gendimsetdecimals 2)(command"_UNITS"2 2 1 2 0"_N")(genprompt"xx.xx")(genun)(princ))(defun c:amunit_3()(gensv)(gendimsetdecimals 3)(command"_UNITS"2 3 1 3 0"_N")(genprompt"xx.xxx")(genun)(princ))(defun c:amunit_4()(gensv)(gendimsetdecimals 4)(command"_UNITS"2 4 1 4 0"_N")(genprompt"xx.xxxx")(genun)(princ)) (princ)
Can anyone help me get both my startup routine and the mechanical to work together?

Thanks in advance for your help!

jwanstaett
2005-10-04, 01:47 PM
Note:
next time just click the Format Code in Editor on the tool menu to make the code more readable


The code for the acadm.lsp file is formated in a way that makes it difficult for me to decipher.

Here is the code for the acadm.lsp file mentioned in the acaddoc.lsp lisp routine:


(defun AcadMappend (startup /)
(if
(cond ((/= T (load "gen/genbas0.lsp" T)) T)
((/= T (load "gen/genbas0.ll" T)) T)
((/= T
(if ge0geniusdir
(load (strcat ge0geniusdir "gen/genbas0.lsp") T)
T))
T)
((/= T
(if geniuspd
(load (strcat (geniuspd) "gen/genbas0.lsp") T)
T))
T)
(T nil))
(append (list (if startup
(car startup)
nil)
(list (quote acadmstartup)))
(cdr startup))
(progn (prompt "nAcadM Error: file genbas0.lsp not loaded.")
startup)))
(defun genneuzeich () (redraw))
(if (= (type *error*) 'SUBR)
(setq *error* nil))
(if (not special)
(defun special (a) a))
(defun c:amlayer_con1 ()
(command "_amlayer" "_o" "con1")
(princ))
(defun c:amlayer_con2 ()
(command "_amlayer" "_o" "con2")
(princ))
(defun c:amlayer_con3 ()
(command "_amlayer" "_o" "con3")
(princ))
(defun c:amlayer_hidw ()
(command "_amlayer" "_o" "hidw")
(princ))
(defun c:amlayer_hidn ()
(command "_amlayer" "_o" "hidn")
(princ))
(defun c:amlayer_hlin ()
(command "_amlayer" "_o" "hlin")
(princ))
(defun c:amlayer_dili ()
(command "_amlayer" "_o" "dili")
(princ))
(defun c:amlayer_txt3 ()
(command "_amlayer" "_o" "txt3")
(princ))
(defun c:amlayer_cenw ()
(command "_amlayer" "_o" "cenw")
(princ))
(defun c:amlayer_cenn ()
(command "_amlayer" "_o" "cenn")
(princ))
(defun c:amlayer_hatch ()
(command "_amlayer" "_o" "hatc")
(princ))
(defun c:amlayer_vpli ()
(command "_amlayer" "_o" "vpli")
(princ))
(defun c:amlayer_phan ()
(command "_amlayer" "_o" "phan")
(princ))
(defun c:amunit_0 ()
(gensv)
(gendimsetdecimals 0)
(command "_UNITS" 2 0 1 0 0 "_N")
(genprompt "xx.")
(genun)
(princ))
(defun c:amunit_1 ()
(gensv)
(gendimsetdecimals 1)
(command "_UNITS" 2 1 1 1 0 "_N")
(genprompt "xx.x")
(genun)
(princ))
(defun c:amunit_2 ()
(gensv)
(gendimsetdecimals 2)
(command "_UNITS" 2 2 1 2 0 "_N")
(genprompt "xx.xx")
(genun)
(princ))
(defun c:amunit_3 ()
(gensv)
(gendimsetdecimals 3)
(command "_UNITS" 2 3 1 3 0 "_N")
(genprompt "xx.xxx")
(genun)
(princ))
(defun c:amunit_4 ()
(gensv)
(gendimsetdecimals 4)
(command "_UNITS" 2 4 1 4 0 "_N")
(genprompt "xx.xxxx")
(genun)
(princ))
(princ)

jwanstaett
2005-10-04, 02:10 PM
if you are loading lisp file just add a line as show to the end of the acaddoc.lsp file for each lisp file you need to load replace the xxxx with the name of the list.

if You need to run other startup programs.
You need to check Autocad help file Index = "S::Startup AutoLISP function" for more info.



(princ (load "xxxx.lsp" "nError: xxxx.lsp not loaded!"))

rmoore
2005-10-04, 02:32 PM
jwanstaett,

Thanks for the responses. Actually I am both loading routines and have to run a couple routines at startup as well. The S::Startup part is what is giving me trouble.

Opie
2005-10-04, 02:37 PM
jwanstaett,

Thanks for the responses. Actually I am both loading routines and have to run a couple routines at startup as well. The S::Startup part is what is giving me trouble.
Are the routines you need to run a command that you can run from the command line (a command that does not require a parens around it to run)? If so, in place of the load statement jwanstaett suggests you could put the commands in your acad.lsp as well


(c:xxx) ;;; replace the xxx with the name of your routine

or for commands that are not run from the command line


(xxx) ;;; replace the xxx with the name of the routine, add any variables afterwards but before the closing parens


HTH

jwanstaett
2005-10-04, 02:44 PM
then you need to look that Autocad help and append the startup function to the S::Startup as showed in the help.

jwanstaett,

Thanks for the responses. Actually I am both loading routines and have to run a couple routines at startup as well. The S::Startup part is what is giving me trouble.

rmoore
2005-10-05, 01:36 PM
Thanks guys!

I got it working with your help!

I just had to define my startup function with a defun-q statement as shown here:


(defun-q mystartup ()
...
..
..
);enddefun
and add this line to the end of the acaddoc.lsp file

(setq S::STARTUP (append S::STARTUP mystartup))

Thanks again!