Jump to content

Appload - Startup suite Problems.


jtk07

Recommended Posts

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?

 

 

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")

Edited by jtk07
Link to comment
Share on other sites

  • Replies 30
  • Created
  • Last Reply

Top Posters In This Topic

  • jtk07

    12

  • tzframpton

    7

  • BlackBox

    5

  • irneb

    5

Top Posters In This Topic

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.

Link to comment
Share on other sites

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?

Edited by jtk07
Link to comment
Share on other sites

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

 

After I add the code you sent me do I then run my lsp in the startup suite?

 

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 ()[/color] [color=slategray]
 ;; 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.

Edited by jtk07
Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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:

 

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Wow everyone Thank YOU!!!! - what has happened is the guy who was in-charge of the cad here has set everything up to the server which in essence 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 and learn for us and we are all trying to incorporate good ideas. So I challange you ALL :D to help me get some practices that will help not hinder as stated above. What we want is not that difficult just remember some things i do not understand yet but willing to learn anything! As of now we have all the acad.lsp, acad2011doc.lsp, ect. files pathed to the server. I think that is wrong as these things should be able to be modified by each cad person (correct?).

 

What we need/want - Here goes :D

 

we would like to incorporate the following code into the start up.. where should it go?

 

[color=slategray][color=slategray](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)
)[/color][/color][/Code]
[color=slategray][color=slategray]
 
[color=black]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[/color] 
[color=black]
I.E.(will make it easier for me to learn what I am doing)[/color]
[code](princ (command "_imageframe" [color=red]2[/color])(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 to  ENGINEERS")

(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)

[/color][/color]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 of it and i will tweak from there. Currently i have a acad2011.lsp and a acad2011doc.lsp that is untouched and from reading above this should be the one that is not touched.

 

Also I do not have a acaddoc.lsp file created if anyone can add or advise on what should go in it or what it should look like that would also help. (maybe copy and paste yours?) I think this is where things like the following code would go

 

(load "mydocumentapp1")
(load "build")
(load "counter")
Link to comment
Share on other sites

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

 

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.

Link to comment
Share on other sites

I agree with bringing unity by the server but what about this problem.

 

What if i me alone want to run a lsp file on a bunch of files and only my files need affected and have others working on other projects by calling to autoload a lsp file in one place it presents the problem that it affects everyone? make sense? We do have templates created in our office however by each project they are different. and the guy before got around that by making different profiles per project (not sure if that's good or bad.) meaning each project has a different autocad icon that maps to a specific profile loads templates per job.

 

what is in the acad.lsp that you do not like (meaning what should not be in there that should be in the template?) also i can rename it to acaddoc.lsp

 

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

 

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.

Link to comment
Share on other sites

My two cents...

 

Here's our setup in a nutshell:

 

Desktop Icons incorporate startup switches, which load our profile off the network, and a script that force-loads our workspace (from our personal space also on the network). The latter is user customizable, but has some enterprise defaults which can be commented out.

 

Example Desktop Icon 'Target' Value:

 

"C:\Program Files\adsk_ldc_2009\acad.exe" /ld "C:\Program Files\adsk_ldc_2009\AecBase.dbx" [color=red]/p "R:\cad\ARG\LDC09\LDC09.arg"[/color] [color=blue]/b "Z:\Custom-09\SCR-Custom\Set-LDC-WRKSP-01.scr"[/color] /c "R:\cad\ARG\LDC09\LDC2009.cfg"

 

 

ACADDOC.lsp is also stored on our personal space on the server, and is user customizable.

 

We chose this method (keeping many items in personal server space), so that no matter what machine a user logged in on, or what office they traveled to, all personal settings/preferences would load accordingly. We have a really good server river-bed, so more often than not, travel is not data-speed prohibitive with application licensing, etc.

 

Hope this helps!

Link to comment
Share on other sites

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 of it and i will tweak from there. Currently i have a acad2011.lsp and a acad2011doc.lsp that is untouched and from reading above this should be the one that is not touched.
You're allowed to edit the ACAD.LSP file as you are allowed to edit the ACADDOC.LSP file. It's the ACAD2011.LSP and ACADDOC2011.LSP files you shouldn't touch - those are ACad's files. The ones without the version numbers are yours.

 

The ACADDOC.LSP file will load of its own accord. ACad searches through each folder in the support paths and if it finds either (ACAD.LSP or ACADDOC.LSP) it loads them. However ACad only does so for the ACAD.LSP when ACad starts, while it does so for the ACADDOC.LSP every time you open a drawing. In most cases you can simply place all the stuff you already have in your ACAD.LSP directly as-is into your ACADDOC.LSP. Though the other way round doesn't always work. E.g. the load statements in your post I'd place in ACADDOC.LSP, otherwise you'll need some other way of ensuring each is loaded for all drawings (maybe using the vl-load-all instead).

 

There are other ways of loading your files, some more convoluted, some "easier" in the short term, some more portable between different systems, some using less ram, others taking less time, etc. But usually you're talking about minuscule differences when referring to RAM / speed so it's not much of a pain there.

Link to comment
Share on other sites

RenderMan,

Here is our target

"C:\Program Files\Autodesk\AutoCAD MEP 2011\acad.exe" /ld "C:\Program Files\Autodesk\AutoCAD MEP 2011\AecBase.dbx" /p "S:\MEP 2011\Profiles\FIRM NAME MEP2011.arg"

Would i do this in the support menu?

i could do the enterprise cui (located on the sdrive) then map it to a place like "C:\acad custom" make the folder "acad custom" on everyone's machine and put the acaddoc.lsp file in it? i think i understand the idea just how do i get it to work. do i just add it to the target or do i do it in support and it handles the target?

Link to comment
Share on other sites

I agree with bringing unity by the server but what about this problem.

 

What if i me alone want to run a lsp file on a bunch of files and only my files need affected and have others working on other projects by calling to autoload a lsp file in one place it presents the problem that it affects everyone? make sense?

Easy. Create two Profiles on your computer. One will be for "CAD Management" and the other will be for "Your tools and commands". That way you have the best of both worlds. You still keep all your things the way you want them, and when there needs to be testing and deploying of a office-wide fix, update, program, etcetera, then you do everything under the "CAD Management" profile.

 

We do have templates created in our office however by each project they are different. and the guy before got around that by making different profiles per project (not sure if that's good or bad.) meaning each project has a different autocad icon that maps to a specific profile loads templates per job.
This can be good or bad. Depends on the way y'all have things set up now. I personally do not like users having multiple profiles unless it's a huge design firm that really has tons of tools, catalogs, custom programs, etc. I would need to assess your company more to answer this question, personally.

 

 

what is in the acad.lsp that you do not like (meaning what should not be in there that should be in the template?) also i can rename it to acaddoc.lsp
No.... no need to do this. (Sorry, I just want to be VERY clear on this. :oops:) Just create an ACADDOC.LSP file and that's it. Don't use or touch anything else. It's not needed, and not recommended. ACAD.LSP only loads on the launch of the application, ACADDOC.LSP loads when on the launch of any and all drawings and templates. You can execute everything via ACADDOC.LSP file. Here are some resources from one of the smartest CAD management guys around....

 

http://cadpanacea.com/node/159

 

http://cadpanacea.com/node/34

 

This will give you a better understanding. :)

Link to comment
Share on other sites

anyone know how to fix -

AutoCAD menu utilities loaded.; error: malformed list on input

 

Well all in all its working like a charm!!!! I added c:\caddstuff and put my acaddoc.lsp in there and did a load command to another lsp in the same folder the drawing opened and it ran and everything is WORKING!!!!! just getting the error above.. thanks for all the help! Great resource pages!!!

Link to comment
Share on other sites

All Is working Great Now!!! Thanks guys!

 

renderman got it to work with Vlide

 

I cant ever get it to work... think its because I just dont know how to use it. Can anyone tell me what file this is, and where would it be located?

"AutoCAD menu utilities"

Edited by jtk07
Link to comment
Share on other sites

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