Author Topic: Set lisp to run every time a DWG is opened  (Read 8272 times)

0 Members and 1 Guest are viewing this topic.

hyposmurf

  • Guest
Set lisp to run every time a DWG is opened
« on: August 01, 2006, 07:45:47 AM »
How do I set a lisp to run everytime I open a new drawing?I realise you can set one to run everytime AutoCAD opens, but I mean everytime a new drawing is opened.What Im intending to do is have my own default variables set every time a new drawing is opened, just fed up of the MIRRTEXT varaible etc not set to my requirements.
Do I have to redefine the open command? :-o

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Set lisp to run every time a DWG is opened
« Reply #1 on: August 01, 2006, 08:47:53 AM »
drag&drop your lisp file to the suitecase...
in the appload dialog box..

OR

load your program from your ACAD.lsp file..
but be sure that in your profile to load ACAD.lsp on each dwg.

;-)
Keep smile...

CADmium

  • Newt
  • Posts: 33
Re: Set lisp to run every time a DWG is opened
« Reply #2 on: August 01, 2006, 09:29:23 AM »
IMHO not in the acad.lsp !!!

for this use the load and run command in acaddoc.lsp -File. It will call with every new document. If you don't have a acaddoc.lsp , you can create on in a acad-support-directory
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Set lisp to run every time a DWG is opened
« Reply #3 on: August 01, 2006, 09:55:54 AM »
Also, do a test on the drawing name.  If its Drawing?? then run your command,  if its already got a name, dont run it.  I have some example code if you need it
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

CADaver

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #4 on: August 01, 2006, 10:01:57 AM »
IMHO not in the acad.lsp !!!
?  Oh? Why not?

CADaver

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #5 on: August 01, 2006, 10:02:27 AM »
Also, do a test on the drawing name.  If its Drawing?? then run your command,  if its already got a name, dont run it.  I have some example code if you need it
cool, can you post it here??

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Set lisp to run every time a DWG is opened
« Reply #6 on: August 01, 2006, 10:11:36 AM »
Also, do a test on the drawing name.  If its Drawing?? then run your command,  if its already got a name, dont run it.  I have some example code if you need it
cool, can you post it here??

This is what I use:

Code: [Select]
(if (not (wcmatch (getvar 'DWGNAME) "Drawing*.dwg"))
  (progn
   
  )
)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

LE

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #7 on: August 01, 2006, 10:17:25 AM »
Why not DWGTITLED ?

nivuahc

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #8 on: August 01, 2006, 10:24:26 AM »
Why not DWGTITLED ?

That's what I use. :)

ronjonp

  • Needs a day job
  • Posts: 7529
Re: Set lisp to run every time a DWG is opened
« Reply #9 on: August 01, 2006, 10:35:12 AM »
Why not DWGTITLED ?


I'm not sure?  :-D

I like that much better...

Code: [Select]
(if (= (getvar 'dwgtitled) 1)
  (progn

  )
)
« Last Edit: August 01, 2006, 10:37:08 AM by ronjonp »

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

CADaver

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #10 on: August 01, 2006, 10:48:01 AM »
I use the same as ronjonp's (getvar 'DWGNAME) phrase, I never really looked at dwgtitled until today.  Cool.   I'm still wondering what CmdrDuh uses, though.  

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Set lisp to run every time a DWG is opened
« Reply #11 on: August 01, 2006, 12:56:39 PM »
I use this on from ACAD.LSP located on network drive

Code: [Select]
(setq cprofile (strcase (getvar "cprofile")))
..
..
..

(if (vl-string-search "Section of profile name" cprofile)
(do this....))

(if (vl-string-search "Section of another one" cprofile)
(do that....))


and some othe loading utilities..

why ??
because to many department here loading to many diffrent programs and utilities that why.   :wink:
« Last Edit: August 01, 2006, 12:58:12 PM by Andrea »
Keep smile...

CADmium

  • Newt
  • Posts: 33
Re: Set lisp to run every time a DWG is opened
« Reply #12 on: August 02, 2006, 02:30:51 AM »
acad.lsp ist the file for make something when acad starts
acaddoc.lsp ist the file for make something when new document starts

i think, both files are not only for fun
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

vladimirzm

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #13 on: August 02, 2006, 03:05:31 AM »
from CUI you can load any lisp when new drawig starts: right clic on LISP Archives node > Load Lisp.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Set lisp to run every time a DWG is opened
« Reply #14 on: August 02, 2006, 03:11:35 AM »
I agree with CADnium.

Another option is the .mnl file: That's is also loaded in every drawing.
Vault Professional 2023     +     AEC Collection

CADaver

  • Guest
Re: Set lisp to run every time a DWG is opened
« Reply #15 on: August 02, 2006, 10:45:41 AM »
acad.lsp ist the file for make something when acad starts
acaddoc.lsp ist the file for make something when new document starts
ACADLSPASDOC=1

i think, both files are not only for fun
??

CADmium

  • Newt
  • Posts: 33
Re: Set lisp to run every time a DWG is opened
« Reply #16 on: August 02, 2006, 03:57:52 PM »
ACADLSPASDOC=1

I know this Sysvar, but somethings i want only start when acad started and other things i want to do in each  document. if you don't have such differences , is ok with acad.lsp

I want only  tell about the both files ...
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

GDF

  • Water Moccasin
  • Posts: 2081
Re: Set lisp to run every time a DWG is opened
« Reply #17 on: August 02, 2006, 04:01:36 PM »
ACADLSPASDOC=1

I know this Sysvar, but somethings i want only start when acad started and other things i want to do in each  document. if you don't have such differences , is ok with acad.lsp

I want only  tell about the both files ...

This may help...

Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

GDF

  • Water Moccasin
  • Posts: 2081
Re: Set lisp to run every time a DWG is opened
« Reply #18 on: August 02, 2006, 04:07:05 PM »
And this...

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;
;;; Following is a list of AutoCAD, Express Tools, and user-defined files in
;;; the order they are loaded when you first start the program. Go to AutoCAD
;;; Help and search for "support file loading" (including quotes) and the
;;; top result is "Order of support file loading" which nets the following:
;;;      <File For:>       <Use By:>
;;;      acad2000.lsp    AutoCAD
;;;      acad.rx       User
;;;      acad.lsp       User
;;;      acad2000doc.lsp    AutoCAD
;;;      acetutil.fas       Express Tools
;;;      acaddoc.lsp       User
;;;      mymenu.mnc    User
;;;      mymenu.mnl    User
;;;      acad.mnc       AutoCAD
;;;      acad.mnl       AutoCAD
;;;      acetmain.mnc    Express Tools
;;;      acetmain.mnl    Express Tools
;;;      s::startup       User
;;; Note: If the user-defined function S::STARTUP is included in the acad.lsp or
;;; acaddoc.lsp file or a MNL file, the function is called when you enter a new
;;; drawing or open an existing drawing. Thus, you can include a definition of
;;; S::STARTUP in the LISP startup file to perform any setup operations. For more
;;; information about the s::startup function, refer to the Customization Guide.


Gary
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Set lisp to run every time a DWG is opened
« Reply #19 on: August 02, 2006, 04:14:24 PM »
I use the same as ronjonp's (getvar 'DWGNAME) phrase, I never really looked at dwgtitled until today.  Cool.   I'm still wondering what CmdrDuh uses, though.   
Not been here at desk for a few days.  Let me go grab that code
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Set lisp to run every time a DWG is opened
« Reply #20 on: August 02, 2006, 04:31:30 PM »
I use dwgname
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Set lisp to run every time a DWG is opened
« Reply #21 on: August 02, 2006, 04:32:49 PM »
I never thought about using dwgtitled
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Set lisp to run every time a DWG is opened
« Reply #22 on: August 02, 2006, 04:34:13 PM »
That is much easier to check than my method.  I was striping off the first 7 characters and matching it against "Drawing", and going from there. 0 and 1 is much easier to use.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Set lisp to run every time a DWG is opened
« Reply #23 on: August 03, 2006, 05:10:13 PM »
acad.lsp ist the file for make something when acad starts
acaddoc.lsp ist the file for make something when new document starts

Thanks....this confirm that I've done the right thing.    ^-^
Keep smile...