defun function but i should load everytime

defun function but i should load everytime

razie.electric
Enthusiast Enthusiast
1,259 Views
5 Replies
Message 1 of 6

defun function but i should load everytime

razie.electric
Enthusiast
Enthusiast

dears

 

i have codes to print all sheets whit one function which has been name "plotpr". the problem is that i want to make it as a autocad function and dont load it every time i want to use .

the codes are: 

; plot all title blocks in model space
; by Alan H
(DEFUN C:PLOTPR()
(PROMPT ".....PRINTING DRAWING TO plotter....")
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)

(setq ss2 (ssget "x" '((0 . "INSERT")(2 . "BORDER")(410 . "Model"))))
(SETQ A (GETREAL "\GIVE THE WIDTH OF THE CADR:"))
(SETQ B (GETREAL "\GIVE THE HEIGHT OF THE CADR:"))
(SETQ DD (GETSTRING "\GIVE THE NAME OF PLOTER:"))
(setq n (sslength ss2))

(setq index 0)
(repeat n
(setq en (ssname ss2 index))
(setq el (entget en))
(setq inspt (assoc 10 el)) ; insertion pt

(setq xmin (cadr inspt))
(setq ymin (caddr inspt))
(setq xymin (strcat (rtos xmin 2 1) "," (rtos ymin 2 1)))

(setq xmax (+ xmin A))
(setq ymax (+ ymin B))
(setq xymax (strcat (rtos xmax 2 1) "," (rtos ymax 2 1)))


(COMMAND "-PLOT" "Y" "" DD
"A4" "M" "LANDSCAPE" "N"
"W" xymin xymax "fit" "C"
"y" "monochrome.ctb" "Y" "" "n" "n"
"y"
)

(setq index (+ index 1))


(setvar "osmode" oldsnap))

)
(princ)

 

thank you for attention

0 Likes
Accepted solutions (1)
1,260 Views
5 Replies
Replies (5)
Message 2 of 6

Satish_Rajdev
Advocate
Advocate

You can just add that lisp file in startup suite so it will get loaded in AutoCAD everytime it starts, you don't need to "applaod" it everytime.

 

Procedure to add it to startup suite - https://www.rey-techs.com/loadprogram

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes
Message 3 of 6

dbhunia
Advisor
Advisor
Accepted solution

Hi,

 

For your particular requirements......

 

 


@razie.electric wrote:

dears

 

i have codes to print all sheets whit one function which has been name "plotpr". the problem is that i want to make it as a autocad function and dont load it every time i want to use .

 


 

It can be done two different way-

 

FIRST

 

If you have Admin right then 

 

Find "acad.lsp" or "acad2017.lsp (this is for Autocad 2017)" file in your system & pest your entire code into it ....... By doing this whenever you open AutoCAD the file "acad.lsp" or "acad2017.lsp" will load automatically & you can use "plotpr" as a normal command....

 

If you do not have Admin right then 

 

Find "acad.lsp" or "acad2017.lsp (this is for Autocad 2017)" file in your system & copy it in any place (say desktop) then pest your entire code into it and save it with the same name. After saving the file replace the original file "acad.lsp" or "acad2017.lsp" with the newly saved file..... 

 

....... By doing this whenever you open AutoCAD the file "acad.lsp" or "acad2017.lsp" will load automatically & you can use "plotpr" as a normal command....

 

SECOND (It do not need Admin right)

 

1.   First enter "APPLOAD" command...

2.   After opening "Load/Unload Applications" window, click on "Startup Suite Contents.." .....

 

1.png

 

3.   It will open a "Startup Suite" window, click on "Add..." button.....

 

2.png

 

4.   It will open a "Add File to Startup Suite" window, Here you chose your file & press open...

 

5.png

 

4.   By doing this your file & its path will be added in the below location......

 

3.png

 

5.   Now close this window & AutoCAD also.

 

6.   Now open AutoCAD, it May ask you for "Security.... permission", if it asked press "Always Load". once you get approval it never ask you for "Security.... permission".

 

 

4.png

 

Now you can use "plotpr" as a normal command....


Debashis Bhunia
Co-Founder of Geometrifying Trigonometry(C)
________________________________________________
Walking is the First step of Running, Technique comes Next....
0 Likes
Message 4 of 6

razie.electric
Enthusiast
Enthusiast

how i add the file at startup suite?

0 Likes
Message 5 of 6

_gile
Consultant
Consultant

@dbhunia,

Do not modify the reserved acad<release>.lsp  and acad<release>doc.lsp files, instead, create your own acad.lsp or acaddoc.lsp file.

By default, acad.lsp and acaddoc.lsp have different behaviors: acad.lsp is loaded only once when AutoCAD starts acaddoc.lsp is loaded for each new document.

IMO, you should create an acaddoc.lsp file in a search path and trusted folder to load LISP filfes which have to be load in every drawing and, if needed an acad.lsp file to set application context system variables and/or NETLOAD .NET plugins.

For more details, attentively read About Auto-Loading and Runnig AutoLISP Routines from the help.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 6 of 6

razie.electric
Enthusiast
Enthusiast

perfect

thank you man!

0 Likes