Author Topic: load acaddoc and acad lsp faster?  (Read 18972 times)

0 Members and 1 Guest are viewing this topic.

butzers09silverado

  • Guest
Re: load acaddoc and acad lsp faster?
« Reply #15 on: July 12, 2011, 01:22:03 PM »
this is what i did for acad.lsp variables i had set, i'll take all the variables being set in acaddoc.lsp and put them in this code also....

that will leave acaddoc.lsp with the complex stuff i guess?...
here's what i've got
Code: [Select]
(defun setvars (/ lst x ds)
  (and (zerop (setq ds (getvar 'dimscale))) (setq ds 1))
  (setq lst '((acadlspasdoc . 1)
      (blipmode . 0)
      (cecolor . "bylayer")
      (celtype . "bylayer")
      (cmddia . 1)
      (startup . 1)
      (isavepercent . 0)
              (tooltips . 0)
              (xrefnotify . 2)
              (xloadctl . 2)
              (visretain . 1)
              (regenmode . 1)
      (attmode . 1)
      (attreq . 1)
              (backgroundplot . 0)
              (cmljust . 1)
              (demandload . 3)
              (draworderctl . 3)
              (elevation . 0)
              (fielddisplay . 1)
              (fieldeval . 31)
              (gridmode . 0)
              (ucsvp . 0)
              (xreftype . 1)
              (geomarkervisibility . 0)
              (tooltips . 1)
              (indexctl . 3)
              (expert . 5)
              (rollovertips . 0)
              (publishcollate . 0)
              (ssmautoopen . 0)
              (osnapz . 1)
     )
  )
  (foreach x lst (vl-catch-all-apply 'setvar (list (car x) (eval (cdr x)))))
  (princ)

ronjonp

  • Needs a day job
  • Posts: 7526
Re: load acaddoc and acad lsp faster?
« Reply #16 on: July 12, 2011, 01:25:07 PM »
One simple example to remove layer command calls:

Code: [Select]
(vl-load-com)
(if (and (setq l (tblobjname "LAYER" "defpoints")) (setq l (vlax-ename->vla-object l)))
  (progn (vla-put-layeron l :vlax-true) (vla-put-freeze l :vlax-false) (vla-put-color l 63))
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

butzers09silverado

  • Guest
Re: load acaddoc and acad lsp faster?
« Reply #17 on: July 12, 2011, 01:31:56 PM »
One simple example to remove layer command calls:

Code: [Select]
(vl-load-com)
(if (and (setq l (tblobjname "LAYER" "defpoints")) (setq l (vlax-ename->vla-object l)))
  (progn (vla-put-layeron l :vlax-true) (vla-put-freeze l :vlax-false) (vla-put-color l 63))
)

so vla-put-freeze l is looking back to the tblobjname for it's reference right.... arghhh i wish i could speak lisp, lol.  i can read it but i can't write it.

if you've seen days of thunder this is where cole trickle says to harry a bit of wedge here, track bar there... idiot, i don't get it.  they told me to drive, so i drove.

alanjt

  • Needs a day job
  • Posts: 5352
  • Standby for witty remark...
Re: load acaddoc and acad lsp faster?
« Reply #18 on: July 12, 2011, 01:38:05 PM »
Wouldn't this still work?

Code: [Select]
(foreach item (list '("cmdecho" 0) (list "dimscale" (+ 1. 25.))) (vl-catch-all-apply 'setvar item))
Civil 3D 2019 ~ Windohz 7 64bit
Dropbox

butzers09silverado

  • Guest
Re: load acaddoc and acad lsp faster?
« Reply #19 on: July 12, 2011, 03:16:14 PM »
Wouldn't this still work?

Code: [Select]
(foreach item (list '("cmdecho" 0) (list "dimscale" (+ 1. 25.))) (vl-catch-all-apply 'setvar item))

I don't know... thats half the problem  :ugly:

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: load acaddoc and acad lsp faster?
« Reply #20 on: July 12, 2011, 05:34:55 PM »
Watch what you put, where, and how it may affect user operations.  For system variables, this mostly involves checking which are are stored in the registry and which are stored in drawings.  For those that are stored in the registry (like FILEDIA) you can set most of those just once for the session in acad.lsp.  For those saved in the drawing (like LTSCALE) keep in the acadDOC.lsp file.  If all you are doing is system variable settings, you might be better off simplifying it all down to a single acaddoc.lsp file.

Since command calls can take longer than simple system variable settings, you can look at wrapping them in some simple logic instead of invoking the command every time e.g. if setting X is good, don't do anything; otherwise call the function to fix it.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: load acaddoc and acad lsp faster?
« Reply #21 on: July 12, 2011, 06:14:57 PM »
An aside following dgorsman's post, (I'm sure you knew this already):



ACAD.lsp
ACADLSPASDOC = 0
Loads acad.lsp into just the first drawing opened in an AutoCAD session, and will not load for each subsequently opened drawing.

ACADLSPASDOC = 1
Loads acad.lsp into every drawing opened.



ACADDOC.lsp
Loads for every drawing opened.



Order of Loading
  • ACAD.lsp
  • <Menu Files>
  • ACADDOC.lsp


Notes
AutoCAD will search for the above files in the working directory (DWGPREFIX), then all listed Support Directories and will load the first file found.
« Last Edit: July 12, 2011, 06:19:05 PM by Lee Mac »

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: load acaddoc and acad lsp faster?
« Reply #22 on: July 12, 2011, 06:43:02 PM »
And to further Lee's points, SDI mode completely buggers that concept, loading acad.lsp in *everything* regardless of settings.  I know, I know... SDI belongs in the land of our computing forbearers but it still crops up here and there with third-party applications.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

Krushert

  • Seagull
  • Posts: 13679
  • FREE BEER Tomorrow!!
Re: load acaddoc and acad lsp faster?
« Reply #23 on: July 13, 2011, 07:20:13 AM »
I see that you are setting up a function (defun setvars  ... <damm alien language again> ... ) but what is calling it? 
Or you just assuming that the OP will put (setvars) somewhere in his code?
I + XI = X is true ...  ... if you change your perspective.

I no longer CAD or Model, I just hang out here picking up the empties beer cans

BlackBox

  • King Gator
  • Posts: 3770
Re: load acaddoc and acad lsp faster?
« Reply #24 on: July 13, 2011, 10:06:35 AM »
And to further Lee's points, SDI mode completely buggers that concept, loading acad.lsp in *everything* regardless of settings.  I know, I know... SDI belongs in the land of our computing forbearers but it still crops up here and there with third-party applications.

I don't follow... what does SDI=1 have to do with this?

I use SDI=1 for my Land Desktop projects, and have no issues with acad.lsp (ACADLSPASDOC = 0), or acaddoc.lsp loading. Both function exactly as Lee has clarified above.
"How we think determines what we do, and what we do determines what we get."

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: load acaddoc and acad lsp faster?
« Reply #25 on: July 13, 2011, 11:24:21 AM »
Thats odd.  I have a third-party application that enforces SDI mode, and acad.lsp is loaded every time a document is opened.  Even the AutoCAD LSP documentation notes this.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

BlackBox

  • King Gator
  • Posts: 3770
Re: load acaddoc and acad lsp faster?
« Reply #26 on: July 13, 2011, 11:32:58 AM »
Thats odd.  I have a third-party application that enforces SDI mode, and acad.lsp is loaded every time a document is opened.  Even the AutoCAD LSP documentation notes this.

Lee's post (above) acurately notes what is listed in the System Variable Editor for ACADLSPASDOC. Additionally this sysvar is saved to the registry, so if you normally use ACADLSPASDOC=0 (acad.lsp loaded once per session), then perhaps your 3rd-party app is setting SDI=1, and ACADLSPASDOC=1?  :?

Just a thought, as the only 3rd-party (non-Autodesk) app I use is AutoTURN.
"How we think determines what we do, and what we do determines what we get."

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: load acaddoc and acad lsp faster?
« Reply #27 on: July 13, 2011, 12:53:38 PM »
Can't find the original AutoCAD reference, but SDI mode causes the ACADLSPASDOC setting to be ignored and effectively treat it as being set.  *shrug*  I've already verified this behavior experimentally.

Aha! http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=2897258&linkID=9240617  Check the section marked "ACADLSPASDOC and SDI mode".
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

butzers09silverado

  • Guest
Re: load acaddoc and acad lsp faster?
« Reply #28 on: July 13, 2011, 03:17:14 PM »
well, everything i am setting should apply to every drawing, therefore I'd like to set as much as possible PER SESSION, as long as that won't get overwritten by a template setting or something subsequent to initial open.

here is my code... for acad.lsp and it didn't work grid mode is still 1, osnapz is still 0, etc.... no errors though
Code: [Select]
; load system settings, vba, arx files

;(arxload "arxfile.arx")

(defun setvars (/ lst x ds)
  (and (zerop (setq ds (getvar 'dimscale))) (setq ds 1))
  (setq lst '((acadlspasdoc . 1)
      (blipmode . 0)
      (cecolor . "bylayer")
      (celtype . "bylayer")
      (cmddia . 1)
      (startup . 1)
      (isavepercent . 0)
              (tooltips . 0)
              (xrefnotify . 2)
              (xloadctl . 2)
              (visretain . 1)
              (regenmode . 1)
      (attmode . 1)
      (attreq . 1)
              (backgroundplot . 0)
              (cmljust . 1)
              (demandload . 3)
              (draworderctl . 3)
              (elevation . 0)
              (fielddisplay . 1)
              (fieldeval . 31)
              (gridmode . 0)
              (ucsvp . 0)
              (xreftype . 1)
              (geomarkervisibility . 0)
              (tooltips . 1)
              (indexctl . 3)
              (expert . 5)
              (rollovertips . 0)
              (publishcollate . 0)
              (ssmautoopen . 0)
              (osnapz . 1)
              (mirrtext . 0)
              (proxygraphics . 0)
              (insunitsdefsource . 2)
              (insunitsdeftarget . 2)
              (maxsort . 10000)
              (isavebak . 1)
              (isavepercent . 1)
              (offsetgaptype . 0)
              (savefidelity . 0)
              (plinegen . 0)
              (plinewid . 0)
              (polysides . 3)
              (ucsfollow . 0)
              (rasterthreshold . 100)
              (rasterpercent . 90)
              (elevation . 0)
              (imageframe . 2)
              (geomarkervisibility . 0)
              (navvcubedisplay . 0)
              (navbardisplay . 0)
              (lwdisplay . off)
              (gridmode . 0)
              (lwunites . 0)
              (orthomode . 0)
              (layoutregenctl . 0)
              (hpglmode . 1)
              (layerdlgmode . 0)           
     )
  )
  (foreach x lst (vl-catch-all-apply 'setvar (list (car x) (eval (cdr x)))))
  (princ) /[code]
« Last Edit: July 14, 2011, 08:10:11 AM by butzers09silverado »

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: load acaddoc and acad lsp faster?
« Reply #29 on: July 14, 2011, 08:37:12 AM »
Hi butzers09silverado,

Include the following in your ACADDOC.lsp:

Code: [Select]
(
  (lambda ( / err )
    (foreach x
     '(
        (acadlspasdoc 1)
        (blipmode 0)
        (cecolor "bylayer")
        (celtype "bylayer")
        (cmddia 1)
        (startup 1)
        (isavepercent 0)
        (tooltips 0)
        (xrefnotify 2)
        (xloadctl 2)
        (visretain 1)
        (regenmode 1)
        (attmode 1)
        (attreq 1)
        (backgroundplot 0)
        (cmljust 1)
        (demandload 3)
        (draworderctl 3)
        (elevation 0)
        (fielddisplay 1)
        (fieldeval 31)
        (gridmode 0)
        (ucsvp 0)
        (xreftype 1)
        (geomarkervisibility 0)
        (tooltips 1)
        (indexctl 3)
        (expert 5)
        (rollovertips 0)
        (publishcollate 0)
        (ssmautoopen 0)
        (osnapz 1)
        (mirrtext 0)
        (proxygraphics 0)
        (insunitsdefsource 2)
        (insunitsdeftarget 2)
        (maxsort 10000)
        (isavebak 1)
        (isavepercent 1)
        (offsetgaptype 0)
        (savefidelity 0)
        (plinegen 0)
        (plinewid 0)
        (polysides 3)
        (ucsfollow 0)
        (rasterthreshold 100)
        (rasterpercent 90)
        (elevation 0)
        (imageframe 2)
        (geomarkervisibility 0)
        (navvcubedisplay 0)
        (navbardisplay 0)
        (lwdisplay 0)
        (gridmode 0)
        (lwunits 0)
        (orthomode 0)
        (layoutregenctl 0)
        (hpglmode 1)
        (layerdlgmode 0)
      )
      (if (vl-catch-all-error-p (setq err (vl-catch-all-apply 'setvar x)))
        (princ (strcat "\n--> Error: " (vl-catch-all-error-message err)))
      )
    )
    (princ)
  )
)