AutoLisp

AutoLisp

abel_henok
Contributor Contributor
3,586 Views
16 Replies
Message 1 of 17

AutoLisp

abel_henok
Contributor
Contributor

I have two lisp files.

 

1) layfrzdwgdir

- This Lisp freezes specified layers throughout an entire set of drawings.

 

Can someone please take a look at the layfrzdwgdir lisp file and create a separate lisp file that can UNfreeze specified layers throughout an entire set of drawings?

 

2) zoome

- This Lisp performs zoom extent within multiple viewports on a single drawing.

 

Can someone please take a look at the zoome lisp and create a separate lisp that can perform the function throughout an entire set of drawings?

 

I hope you someone is able to help me reach a resolution.

 

Thank you!

0 Likes
3,587 Views
16 Replies
Replies (16)
Message 2 of 17

becca_chesmore
Community Visitor
Community Visitor

(defun zoomedwgdir ()
(foreach dwgname (dir "*.dwg") ; Loop through drawing files
(command "open" dwgname) ; Open the current drawing
(c:zeavp) ; Call the existing zoom extents function
(command "save" "yes") ; Save the drawing
(command "quit")) ; Close the drawing
(princ "\nZoom extents completed for all drawings."))

(defun c:zeavp ( / c) ; Existing function from zoome.lsp (unchanged)
(setq c (getvar "CTAB"))
(foreach l (layoutlist)
(setvar "CTAB" l)
(c:zoome))
(setvar "CTAB" c)
(princ))

(princ "\nType zoomedwgdir or (zoomedwgdir) to run")

0 Likes
Message 3 of 17

paullimapa
Mentor
Mentor

for your layfrzdwgdir.lsp to change to unfreeze then change this line:

:vlax-true ;; the value you want each listed layer to be set to

to this line:

:vlax-false ;; the value you want each listed layer to be set to

Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 4 of 17

abel_henok
Contributor
Contributor

This solution did not work. Please view the attached code per your recommendations and let me know if we can come up with a different solution. Thank you!

0 Likes
Message 5 of 17

paullimapa
Mentor
Mentor

There was actually another location where :vlax-true had to be replaced with :vlax-false

Also you don't need to replace 'freeze with 'unfreeze

Use the attached revised code.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 6 of 17

abel_henok
Contributor
Contributor

Paul, that worked! Thank you so much sir! Now, do you think we can customize the zoome lisp so that it applies to the entire set of drawings in a directory? (similar to the layunfrzdwgdir lisp) Please let me know. Thanks!

0 Likes
Message 7 of 17

paullimapa
Mentor
Mentor

Does @becca_chesmore solution not work for you?


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 8 of 17

abel_henok
Contributor
Contributor

Below is the error I received when entering "zoomedwgdir: or "(zoomedwgdir)" in the command line:

 

; error: no function definition: DIR

0 Likes
Message 9 of 17

abel_henok
Contributor
Contributor
Below is the error I received when entering "zoomedwgdir: or "(zoomedwgdir)" in the command line:

; error: no function definition: DIR
0 Likes
Message 10 of 17

paullimapa
Mentor
Mentor

let's see if @becca_chesmore can reply to that


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 11 of 17

becca_chesmore
Community Visitor
Community Visitor

@paullimapa I'm pretty new to Lisp and I thought that would work. Sorry, I couldn't be more help 😞

0 Likes
Message 12 of 17

abel_henok
Contributor
Contributor
No worries. Thank you for your effort.
0 Likes
Message 13 of 17

paullimapa
Mentor
Mentor

Here's one method to run Zoome.lsp on a set of dwgs in a folder:

Script Writer | Lee Mac Programming (lee-mac.com)

Download & install and then fill out the Script Line on Lee Mac's program like this (assume your Zoome.lsp is in a AutoCAD's File Support Search Path location):

_.Open *file* (load"zoome") ZoomE _.Qsave _.Close

paullimapa_0-1727151732161.png

 

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 14 of 17

paullimapa
Mentor
Mentor

Here's another method to apply zoome.lsp to all dwgs in a selected folder.

Save attached DwgAccPikScr.lsp , Zoome.lsp & unzip Zoome.scr in a folder under one of AutoCAD> Options> Support File Search Path & Trusted Locations

paullimapa_0-1727160265788.png

Then at AutoCAD command prompt load DwgAccPikScr.lsp by typing following:

(load"DwgAccPikScr")

Then run by entering at command prompt:

DwgAccPikScr

Select the folder where the dwgs are and then select Zoome.scr

 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 15 of 17

abel_henok
Contributor
Contributor
Hey Paul, I like your thought process.

During testing, I realized there's an IT restriction on running script files in batch. Though, we have more flexibility with lisp files.

The DWGACCPIKSCR is a lisp file but only allows the user to select a script file to run in a directory. Is there a way we can modify DWGACCPIKSCR to allow the user to select a script file?

Please let me know.

Thank you!
0 Likes
Message 16 of 17

paullimapa
Mentor
Mentor

I’m surprised script files in a batch file is not allowed at your office. This is a major advantage that allows for automation without a need to open drawings in AutoCAD. Since DWGACCPIKSCR lisp is purposely designed to take advantage of batch processing dwgs without opening them, then this method cannot be used in your office. 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 17 of 17

paullimapa
Mentor
Mentor

Here's a modified version I call DwgAccPikScrA.lsp

This version does NOT create a batch file to apply the selected script file to all the dwgs in the selected folder.

But instead it runs the entire process within AutoCAD.

Let me know if this version bypasses the batch Script restrictions in your office.


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes