Appload - Startup suite Proble
Okthe problem with app load does not appear to be a problem except forwith 2 files. Any idea why 2 files may not be working? is there asetting that can turn off app load from working on a per sheet basis?Currently I have a lsp (see code below) loaded into the startup suit. I am under the impression for every drawing opened it should load what ever is in the startup suit into every drawing. However, every other drawing is working (I load 4 drawings at a time per the code it should run save and close, and has worked many times in the past). I need this lsp to load for every drawing I open. Any fixes or workarounds for this problem or a better way to accomplish this? Also under options - system - I have "LOAD acad.lsp with every drawing" checked.
(command "-layer" "S" "G-XREF" "")(command "erase" "W" "-4',3'10" "1.625,-0.875" "")(command "erase" "W" "3'6,-0.28125" "6'2,3'2.125" "")(command "zoom" "E")(command "snapmode" "0")(command "qsave")(command "close") Firstly, the Startup Suite is not always the "best" place to have code run automatically. I prefer using an MNL file with my CUI menu, others tend to rather go with an ACADDOC.LSP file. Both the later methods are easier to transfer between PC's & upgrades. Although It's up to you what you prefer using, you could still use the Suite if you're willing to do some registry hacking to transfer your settings.
Secondly, your lisp is calling commands. It's not recommended to call commands directly from some startup lisps. The reason is that the command line may not be ready yet. The official way of getting round this is to append your code to the S::STARTUP defun-q. This defun is guaranteed to only be called once the command line is available. The "general" way of using this is as follows:
(defun-q MyStartup () ;; Some codes I want to run for each DWG, including command calls)(if (and S::Startup (= (type S::Startup) 'LIST)) (setq S::Startup (append S::Startup MyStartup)) (setq S::Startup MyStartup))The trick is that your defun (as well as the S::Startup) MUST be a defun-q ... so it can be appended to because it's actually a list, not an optimized "normal" defun. How can I tell if the acad2011doc.lsp is even loading every drawing? and how do i tell if its using the one on the server or local? Ok the problem with app load does not appear to be a problem except for with 2 files. Any idea why 2 files may not be working? is there a setting that can turn off app load from working on a per sheet basis?
It is not located in the acad2011doc,lsp any more it is located in acad.lsp but still need some clarification please.
acad.lsp Startup shown in red - and FYI Imageframe not working either.
(VMON);;;--------------------------------------(defun *ERROR* (MSG)(setvar "blipmode" 0)(setvar "menuecho" 0)(setvar "highlight" 1)(setvar "imageframe" 2)(setvar "pdmode" 0)(princ "Error: ") (princ MSG)(terpri))(Defun AH ()(setq #cmdecho (getvar "cmdecho"))(setq #osmode (getvar "osmode"))(setvar "cmdecho" 0)(setq p1 (Getpoint "\nEnter first point: "))(setq p2 (getpoint "\nEnter second point: "))(setvar "osmode" 0);;;(setq p3 (polar p1 (angle p1 p2) (/ (Distance p1 p2) 2)));;;(command P3)(setvar "cmdecho" #cmdecho)(setvar "osmode" #osmode)(princ))(defun C:DT () (command "DTEXT" pause pause "" ""))(defun C:ZA () (command "ZOOM" "A")(princ))(defun C:ZE () (command "ZOOM" "E")(princ))(defun C:ZW () (command "ZOOM" "W")(princ))(defun C:ZP () (command "ZOOM" "P")(princ));Undefine Commands Section - Use this section to undefine a command.;=========================================================================================================;(command "undefine" "close");User Functions Section - Use this section to redefine a command.;=========================================================================================================;(defun c:close () ;(command "-purge" "a" "*" "n" ".save");(command "ZE");(command "close");(princ);=========================================================================================================(DEFUN S::STARTUP ()(setvar "cmdecho" 1)(setvar "pdmode" 0)(setvar "blipmode" 0)(setvar "visretain" 1)(setvar "mirrtext" 0);rem (setvar "osmode" 103);(setvar "xloadctl" 1)(if (> (getvar "savetime") 15) (setvar "savetime" 20));(command "zoom" "e" "");------------------------------------dimscale check(setq #DWGSC (getvar "DIMSCALE"))(setq #DWGSC (getvar "cannoscale"))(princ "\nHello ")(princ (getvar "LOGINNAME"))(princ ", Welcome to Firm name appears here")(princ)(princ (strcat "\nThe Current PLOT SCALE FACTOR is " (rtos (getvar "dimscale") 2 0)))(princ))(princ (command "_imageframe" 2)(princ))could you please expand on this -"S::STARTUP defun-q"? where is it located? i have searced my acad2011doc.lsp and see no reference to it.
"Secondly, your lisp is calling commands. It's not recommended to callcommands directly from some startup lisps. The reason is that thecommand line may not be ready yet. The official way of getting roundthis is to append your code to the S::STARTUP defun-q. This defun isguaranteed to only be called once the command line is available. The"general" way of using this is as follows"
After I add the code you sent me do I then run my lsp in the startup suite?
Don't modify the acad20XXdoc.lsp files - they are reserved for AutoCAD
This might offer some clarification:
http://lee-mac.com/autoloading.html Also note, it's not a good practice to set system variables the way you are wanting (ie: SNAPMODE). Preset these variables in a drawing and save as a template instead. You can even incorporate this into a Command Line Switch for the default startup template so you're getting everything you want & need upon application launch. If you want all these variables to be set in a foreign drawing then create a Lisp routine to call on desired variables all at once when needed. Just my $0.02 is all. =o) Firstly (as Lee's stated), never, ever, ever even consider touching any acad####.lsp or acaddoc####.lsp files. Those are from ADesk and could change at any update / upgrade, effectively erasing all your customization. You are allowed to create your own ACAD.LSP and ACADDOC.LSP files, as long as they are in a support folder, they'll get loaded. The ACAD.LSP is (usually depending on ACADLSPASDOC's setting) only loaded once per session, the ACADDOC.LSP is loaded for each DWG opened (always, no matter any other setting). Any MNL file named the same and in the same folder as the CUI / CUIx (even if that folder's not on the support list) will also get loaded for each DWG - always. That's why I like this method more - it allows for the least amount of setup: i.e. I simply need to load the CUI, no registry edits, no changes to the support paths, no modifying any other files.
If you want to make sure that your code runs, you can always add a princ call with a message like "My code's just completed successfully". That way you can see it on the command line.
The startup suite also loads for each DWG, but as stated some of the code may fail in any method of auto loading the LSP file(s) if you're using command calls. It won't "always" fail, it depends on how long it takes for the DWG's command line to become ready to accept commands. E.g. in a rather small 2D drawing there might not be a problem, but due to some extra libraries being loaded on a 3D drawing the command line takes longer to become ready - thus the same code which worked for the 1st DWG will not work for the 2nd. Note this is only if you use command or vl-cmdf, doing stuff with setvar and such won't be affected. So if you don't need to call command / vl-cmdf you also don't need to worry about S::Startup.
About S::Startup ... there usually isn't one at all. It's just a name that gets checked, and if it exists it's called as soon as the command line is ready. You can create it the usual way, but it's highly frowned upon if you make it a normal defun. The reason is it's used to settings for all addons. Thus each addon needs to be able to append to it without needing to modify existing files. E.g. if you install an addon, you don't want it to screw up your other addon's workings now would you?
For that reason you define it thus:
(defun-q S::Startup () ;; any normal lispcodes, but usually only command calls)Although that way of defining it would overwrite any previous definitions. That's why you define a temporary defun-q and then append it to the S::Startup. That way any other addon's codes are still in the S::Startup as well as your own ... without you needing to modify the other addon's files at all. See my previous post.
You could place this code into any LSP file which gets loaded automatically. It will append to the S::Startup function and be called when the command line is ready - not before. The way your code shows is wrong for 2 reasons:
[*]It simply redefines the S::Startup, so any other addons also using it might break if their codes were added to the function before yours.
[*]You're using the normal defun which makes a "compiled" function instead of a defun-q list. Thus later calls to append to it would then fail ... i.e. other addons loading after yours will fail.
You can see on my previous post I'm trying to circumvent the 2nd problem: I check if S::Startup has been defined already AND if so that it is also a list. If both conditions are met I append my defun-q to the S::Startup. Otherwise it was either not defined yet, or some erroneous addon has defined it wrong ... therefore I overwrite it. Unfortunately there's no way of fixing the 1st problem without editing the erroneous code (which is sometimes inside an uneditable FAS / VLX file) or stopping it from loading. I'd agree with this as well ... since this would make all DWGs edited, even if you've done nothing to them. I.e. you'd find that "Save changes" dialog posps up when you're closing the DWG in every single instance (note there is a way of circumventing this - see later in this post).
Check in the normal acad help (Command Reference > System Variables) on each of the sysvars you want to change. It lists which are saved in the registry, which are not saved, and which are saved within the DWG file. For the later, it's best to use the template method described by StykFacE. For the 1st you can ensure it's set as you want through your methods, but you could also simply run a windows login script to fix the registry values. For the 2nd, they're usually read-only (e.g. AREA).
To avoid the Save Changes dialog you can trick ACad into believing that nothing has changed in the DWG. To do this you call (acad-push-dbmod) just before making any changes, then call (acad-pop-dbmod) just thereafter. Although it's not the best way of doing these things ... as stated earlier. Simply because it's possible isn't always the same as it must be done. Wow everyone Thank YOU!!!! - what has happened is the guy who wasin-charge of the cad here has set everything up to the server which inessence seemed like a great idea bringing unity to all in the office,just not might the best way of doing it. it has been a bit of live andlearn for us and we are all trying to incorporate good ideas. So Ichallange you ALL to help me get some practices that will help not hinder as statedabove. What we want is not that difficult just remember some things i donot understand yet but willing to learn anything! As of now we have allthe acad.lsp, acad2011doc.lsp, ect. files pathed to the server. I thinkthat is wrong as these things should be able to be modified by each cadperson (correct?).
What we need/want - Here goes
we would like to incorporate the following code into the start up.. where should it go?
(princ "\nHello ")(princ (getvar "LOGINNAME"))(princ ", Welcome to Firm name appears here")(princ)(princ (strcat "\nThe Current PLOT SCALE FACTOR is " (rtos (getvar "dimscale") 2 0)))(princ))(princ (command "_imageframe" 2)(princ)) currently this is the standard acad.lsp anything wrong with it? should it be written different, or are there errors in it anyone can fix?Please paste full line of code I.E.(will make it easier for me to learn what I am doing)(princ (command "_imageframe" 2)(princ))
Our acad.lsp
; THIS IS THE STANDARD ACAD.LSP(VMON);;;--------------------------------------(defun *ERROR* (MSG)(setvar "blipmode" 0)(setvar "menuecho" 0)(setvar "highlight" 1)(setvar "imageframe" 2)(setvar "pdmode" 0)(princ "Error: ") (princ MSG)(terpri))(Defun AH ()(setq #cmdecho (getvar "cmdecho"))(setq #osmode (getvar "osmode"))(setvar "cmdecho" 0)(setq p1 (Getpoint "\nEnter first point: "))(setq p2 (getpoint "\nEnter second point: "))(setvar "osmode" 0);;;(setq p3 (polar p1 (angle p1 p2) (/ (Distance p1 p2) 2)));;;(command P3)(setvar "cmdecho" #cmdecho)(setvar "osmode" #osmode)(princ))(defun C:DT () (command "DTEXT" pause pause "" ""))(defun C:ZA () (command "ZOOM" "A")(princ))(defun C:ZE () (command "ZOOM" "E")(princ))(defun C:ZW () (command "ZOOM" "W")(princ))(defun C:ZP () (command "ZOOM" "P")(princ));Undefine Commands Section - Use this section to undefine a command.;=========================================================================================================;(command "undefine" "close");User Functions Section - Use this section to redefine a command.;=========================================================================================================;(defun c:close () ;(command "-purge" "a" "*" "n" ".save");(command "ZE");(command "close");(princ);=========================================================================================================(DEFUN S::STARTUP ()(setvar "cmdecho" 1)(setvar "pdmode" 0)(setvar "blipmode" 0)(setvar "visretain" 1)(setvar "mirrtext" 0);rem (setvar "osmode" 103);(setvar "xloadctl" 1)(if (> (getvar "savetime") 15) (setvar "savetime" 20));(command "zoom" "e" "");------------------------------------dimscale check(setq #DWGSC (getvar "DIMSCALE"))(setq #DWGSC (getvar "cannoscale"))(princ "\nHello ")(princ (getvar "LOGINNAME"))(princ ", Welcome toENGINEERS")(princ)(princ (strcat "\nThe Current PLOT SCALE FACTOR is " (rtos (getvar "dimscale") 2 0)))(princ))(princ (command "_imageframe" 2)(princ));; Some codes I want to run for each DWG, including command calls)Does the acad.lsp need to have a command to tell it to run acaddoc.lsp?if i should not modify the acad.lsp please send me a clean version ofit and i will tweak from there. Currently i have a acad2011.lsp and aacad2011doc.lsp that is untouched and from reading above this should bethe one that is not touched.
Also I do not have a acaddoc.lsp file created ifanyone can add or advise on what should go in it or what it should looklike that would also help. (maybe copy and paste yours?) I think this iswhere things like the following code would go
(load "mydocumentapp1")(load "build")(load "counter") Just create a *.TXT file and name it ACADDOC.TXT, then rename the file extension from .TXT to .LSP. The only file you should be using in the scenario is the ACADDOC.LSP file and nothing else. It's explained in the AutoCAD help file, I believe in the Developer's Section.
And you do in fact want to utilize a server. It's the best way. Just have your I.T. department create a folder on the server, and map a drive to that folder on each workstation that has AutoCAD installed. Place the ACADDOC.LSP file there. One person should have read/write access to this directory (probably you in this case), and everyone else should be read only. Now place that directory in the Support Path in AutoCAD on each workstation, and move it to the top line. Restart AutoCAD. Done.
PS: I still stand by my Template post above. Create and use Templates. Use them on the server as well. In the Support Paths there is a path for your templates, just point that directory to a Template directory you create on the server so all workstations using AutoCAD have the Templates available as well. This way if you ever make a change to a Template, the changes are effected immediately to all users, just as the ACADDOC.LSP file will be.
页:
[1]
2