Author Topic: how can I get the directory of the lsp file I dragged into Autocad?  (Read 2269 times)

0 Members and 1 Guest are viewing this topic.

litss

  • Guest
I know that I can load a lsp routine by dragging it into the Autocad window. But by this way, I can only load it once. Next time, I still need to drag it into the cad again. Is there a way I can catch the directory of the lsp routine I dragged ? If that is possible, I wish I could make a self-run routine to catch this path, add this path into the cad support path and automatically write a line-(load "*.lsp") into the "acad.mnl" file to keep it autoloading everytime I run the cad.

BTW, I would like to keep the lsp routines in the folders I want. So I did not try to copy the lsp into the real support path, which I know how to realize.

thx



 

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #1 on: December 24, 2008, 08:52:46 AM »
Here is a start.
http://www.theswamp.org/index.php?topic=1883.msg24450#msg24450

What you need to do is add your lisp folder to the acad support folders.

Then create a lisp to select lisp files & append them to your autoload file if they don't already exist in the file.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

litss

  • Guest
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #2 on: December 24, 2008, 10:43:01 AM »
thx, CAB!

It's a good way to realize autoloading. But it is still not the one I want.

Actually, I am wishing to create a "setup.lsp", which could do every thing for me automatically, including adding the folder that "setup.lsp" exists to the support path, appending a line-"(load "*.lsp")" into the acad.mnl, copying some fonts from the "setup" folder to the CAD's fonts folder, copying some "*.ctb" files from the "setup" folder to the CAD's folder,ect. Just by dragging the "setup.lsp" into the CAD once, then everything is done.

I just want to save some time when I am using a new computer. Maybe that's not good and hard to realize.


GDF

  • Water Moccasin
  • Posts: 2081
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #3 on: December 24, 2008, 04:14:52 PM »
If you create a mnl file it is loaded automatically everyting the menu file is loaded with the same name.
I have an ARCH.cui file and an ARCH.mnl file (the mnl file is automatically loaded withe the menu file)

Also look into AutoCAD's startup function...

Here is how I load lisp files and create settings...(see enclosed files)


Hope this helps...

Code: [Select]

(defun ARCH:ALERT-I  (messagebox / applic)
  (vl-load-com)
  (setq applic (vlax-get-acad-object))
  (vla-eval
    applic
    (strcat messagebox ", " "vbInformation" ", " "\"" ARCH#LOGO
            " : Information                    \""))
  (vlax-release-object applic)
  (princ))
;;;(ARCH:ALERT-I "MsgBox \"Hello Everybody\"")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;; Find Lisp Routine for Loader Function ;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun ARCH:LOAD  (FIND)
  (cond
    ((findfile FIND) (load FIND))
    (t
     (progn
       (menucmd "GARCH.ID_ARCH=~")
       (ARCH:ALERT-I
         "MsgBox \"
     File could not be Found.
--------------------------------------------------------------------------------------------
     This Routine could not be found on the network...
     Please notify Gary D. Fowler to correct the problem.\"")
       (princ "\n*** ///////// Program  CANCELLED ///////// ***")))))
;;;
;;;usage (ARCH:LOAD (strcat ARCH#CUSF "LAYS/" "ARCH_LockDown.lsp"))
« Last Edit: December 24, 2008, 04:20:04 PM by GDF »
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

litss

  • Guest
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #4 on: December 24, 2008, 11:43:42 PM »
Thx, Gary!

I need to do some homework about your routines. It must be helpful.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #5 on: December 25, 2008, 11:32:07 AM »
I know that I can load a lsp routine by dragging it into the Autocad window. But by this way, I can only load it once. Next time, I still need to drag it into the cad again. Is there a way I can catch the directory of the lsp routine I dragged ? If that is possible, I wish I could make a self-run routine to catch this path, add this path into the cad support path and automatically write a line-(load "*.lsp") into the "acad.mnl" file to keep it autoloading everytime I run the cad.

BTW, I would like to keep the lsp routines in the folders I want. So I did not try to copy the lsp into the real support path, which I know how to realize.

thx

Do-able and interesting as a technical challenge, but I can't help thinking that the effort would be better spent solving a problem that has no solution as appload / startup suite has this one reasonably covered.

Am I missing something? :)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

VovKa

  • Water Moccasin
  • Posts: 1632
  • Ukraine
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #6 on: December 25, 2008, 05:17:07 PM »
litss, look at the attached file, it can be used as the self-install package

there is another way - you can use "Additional Resource Files -> Text files" when creating you .vlx file, then with the help of MP's _WriteStream  and vl-get-resource you will be able to write all needed files to the desired locations.

litss

  • Guest
Re: how can I get the directory of the lsp file I dragged into Autocad?
« Reply #7 on: December 26, 2008, 10:55:09 AM »
Thx, MP!  You r right, maybe I am doing some time-wasting job:). Actually, I have an alternative.  I just want to make the setup much "fooler", like saving the codes:"while.......". When I drag this routine into the CAD, the job is done. No more need to select the folder and the files..... That is what I want.

Code: [Select]
(DEFUN SETUP ( / flnm fn obj setup-path support)
  (IF (NOT SETUP-PATH)
    (SETQ SETUP-PATH "C:\\")
  );IF
  (WHILE (NOT (FINDFILE (SETQ FN (STRCAT SETUP-PATH "SETUP.LSP"))))
    (SETQ FLNM (GETFILED "PLEASE FIND AND SELECT THE \"SETUP.LSP\" FILE" "SETUP" "LSP" 4))
    (SETQ SETUP-PATH (STRCAT (VL-FILENAME-DIRECTORY FLNM) "\\"))
  );WHILE
  (SETQ OBJ (VLA-GET-FILES (VLA-GET-PREFERENCES (VLAX-GET-ACAD-OBJECT))))
  (SETQ SUPPORT (STRCAT (VLA-GET-SUPPORTPATH OBJ) ";" SETUP-PATH))
  (VLAX-PUT-PROPERTY OBJ "SupportPath" SUPPORT)
)
;SETUP
(SETUP)

Thx, Vovka! Your first way is fresh to me. Is the "acaddoc.lsp" a self-running routine, while we open a dwg file of the same folder? You get the current folder by getting the dwg file's system variable. It is a nice try. But I am afraid that some people might take this file as a virus. They will not accept my setup programs. You know, some have made bad use of this file to make fun. Your second way can solve the problem of copying and writing, but can't do the same things as your first way do.

:) thx all u guys!