Export Layouts to DWGs with pop-up Dialog box -LISP

Export Layouts to DWGs with pop-up Dialog box -LISP

Millwood-k
Advocate Advocate
3,078 Views
17 Replies
Message 1 of 18

Export Layouts to DWGs with pop-up Dialog box -LISP

Millwood-k
Advocate
Advocate

Hi, Hope you guys doing well,

 

I am a beginner in Autolisp.

I found a handy simple lisp routine in the forum, about exporting Layouts to separate DWGs (to the model space) which I was looking for; however it send them (separate DWGs) automatically to the same location where the main drawing is located, 

 

My question:

Can someone show me how to include an option which allowed the dialog box pops up?

 

Appreciation

 

Here is the lisp routine as-is:

 

(defun c:test ( / BASE LST OLD_DIA)
     (setq old_dia (getvar 'FILEDIA)
base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)))
)
    (setvar 'FILEDIA 0)
    (setq lst (layoutlist))
    (foreach l lst
    (command "_.ctab"
       l
      "exportlayout"
      (strcat base "-" l)
)
)
     (setvar 'FILEDIA old_dia)
    (princ)
)

0 Likes
Accepted solutions (2)
3,079 Views
17 Replies
Replies (17)
Message 2 of 18

Moshe-A
Mentor
Mentor

@Millwood-k  hi,

 

here is my fix. it depends on Lee's Mac (LM:BrowseForFolder) function (thank you Lee)

download this lisp function >> from here <<  and save it under your lisp library folder under Support Files Search path.

 

untested 

 

enjoy 😀

moshe

 

(defun c:test ( / base old_dia)

 (if (null LM:browseforfolder)
  (load "BrowseForFolderV1-3")
 )

 (if (setq base (LM:browseforfolder "Select a folder" "C:\\" 0))
  (progn 
   (setq old_dia (getvar 'FILEDIA))
   (setvar 'FILEDIA 0)

  ; (setq base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))))
   (setq base (strcat base (vl-filename-base (getvar 'DWGNAME))))
  
   (foreach lay (layoutlist)
    (command "_.ctab" lay "exportlayout" (strcat base "-" lay))
   )
  
   (setvar 'FILEDIA old_dia)
  ); progn
 ); if
  
 (princ)
)

 

Message 3 of 18

Millwood-k
Advocate
Advocate

Thanks Moshe-A,

 

I copied it in my visual lisp window (by typing VLIDE in the command text, but I didn't work I got in return in the command line

; error: LOAD failed: "BrowseForFolderV1-3"

0 Likes
Message 4 of 18

Anonymous
Not applicable

@Millwood-k  "BrowseForFolderV1-3" Must be loaded on your drawing.

0 Likes
Message 5 of 18

Millwood-k
Advocate
Advocate

I uploaded the LM:browseforfolder support. but for some reason I am not permitted to use the C volume on my desktop, however I replaced it by the D volume, but it did not recognized it.

 

defun c:test ( / base old_dia)

(if (null LM:browseforfolder)
(load "BrowseForFolderV1-3")
)

(if (setq base (LM:browseforfolder "Select a folder" "D:\\" 1))
(progn
(setq old_dia (getvar 'FILEDIA))
(setvar 'FILEDIA 0)

; (setq base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))))
(setq base (strcat base (vl-filename-base (getvar 'DWGNAME))))

(foreach lay (layoutlist)
(command "_.ctab" lay "exportlayout" (strcat base "-" lay))
)

(setvar 'FILEDIA old_dia)
); progn
); if

(princ)
)

0 Likes
Message 6 of 18

Moshe-A
Mentor
Mentor

@Millwood-k ,

 

(setq base (LM:browseforfolder "Select a folder" "c:\\" 1))

 

how the last argument became 1,  when it should be 0?!

 

moshe

 

Message 7 of 18

dbhunia
Advisor
Advisor
Accepted solution

@Millwood-k  & @Moshe-A  I would like to replace the line ......

 

(setq base (strcat base (vl-filename-base (getvar 'DWGNAME))))

with

(setq base (strcat base "\\" (vl-filename-base (getvar 'DWGNAME))))

 

If user wanted to select any other folders also except root directory.....

 

 

 


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

Millwood-k
Advocate
Advocate

@Moshe-A@dbhunia

 

Wow, thanks guys

When replacing the zero value C:\\" 0 by one C:\\" 1  it export them beside the destination. But

When adding "\\" as @dbhunia showed it just worked perfect.

 

Appreciation😀

 

Here is the the final edition:

(defun c:ld ( / base old_dia)

(if (null LM:browseforfolder)
(load "BrowseForFolderV1-3")
)

(if (setq base (LM:browseforfolder "Select a folder" " C:\\" 1))
(progn
(setq old_dia (getvar 'FILEDIA))
(setvar 'FILEDIA 0)

; (setq base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))))
(setq base (strcat base "\\" (vl-filename-base (getvar 'DWGNAME))))

(foreach lay (layoutlist)
(command "_.ctab" lay "exportlayout" (strcat base "-" lay))
)
(setvar 'FILEDIA old_dia)
); progn
); if
(princ)
)

 

0 Likes
Message 9 of 18

Millwood-k
Advocate
Advocate

@dbhunia

I would like to have another option about the file name

in the actual routine it is like this : main drawing name -layer name.dwg

(command "_.ctab" lay "exportlayout" (strcat base "-" lay))

 

I would like to have it like : layer name_ACAD_2019.dwg

so I tried this below but it didn't work:

(command "_.ctab" lay "exportlayout" (strcat lay "_ACAD_2019"))

0 Likes
Message 10 of 18

dbhunia
Advisor
Advisor
Accepted solution

Try like this.......

 

If you need "layout name_ACAD_2019.dwg" 

(defun c:ld ( / base old_dia)

(if (null LM:browseforfolder)
	(load "BrowseForFolderV1-3")
)
(if (setq base (LM:browseforfolder "Select a folder" " C:\\" 1))
	(progn 
		(setq old_dia (getvar 'FILEDIA))
		(setvar 'FILEDIA 0)
		(foreach lay (layoutlist)
			(command "_.ctab" lay "exportlayout" (strcat base "\\" lay "_ACAD_2019"))
		)
		(setvar 'FILEDIA old_dia)
	); progn
); if
(princ)
)

But I prefer.......

(defun c:ld ( / base old_dia)

(if (null LM:browseforfolder)
	(load "BrowseForFolderV1-3")
)
(if (setq base (LM:browseforfolder "Select a folder" " C:\\" 1))
	(progn 
		(setq old_dia (getvar 'FILEDIA))
		(setvar 'FILEDIA 0)
		(setq base (strcat base "\\" (vl-filename-base (getvar 'DWGNAME))))
		(foreach lay (layoutlist)
			(command "_.ctab" lay "exportlayout" (strcat base "_" lay "_ACAD_2019"))
		)
		(setvar 'FILEDIA old_dia)
	); progn
); if
(princ)
)

 

 


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

Millwood-k
Advocate
Advocate

Thanks to ALL of you guys

Nice effort and

I appreciate giving your time to others

0 Likes
Message 12 of 18

Millwood-k
Advocate
Advocate

Hello @dbhunia, hope you and all doing well, 

I remember helping me with Layout-to-DWG, 

This is if we need "layout name_ACAD_2019.dwg" 

(defun c:ld ( / base old_dia)

(if (null LM:browseforfolder)
	(load "BrowseForFolderV1-3")
)
(if (setq base (LM:browseforfolder "Select a folder" " C:\\" 1))
	(progn 
		(setq old_dia (getvar 'FILEDIA))
		(setvar 'FILEDIA 0)
		(foreach lay (layoutlist)
			(command "_.ctab" lay "exportlayout" (strcat base "\\" lay "_ACAD_2019"))
		)
		(setvar 'FILEDIA old_dia)
	); progn
); if
(princ)
)

The question how to get rid of "_ACAD_2019" ?, which means we need only the layout name to be showed.

 

Thank you in advance.

 

0 Likes
Message 13 of 18

Millwood-k
Advocate
Advocate

Hi, 

I remember the lisp routine for export layouts to separate dwgs, 

Is it possible to adapt this script to publish (separate PDFs) with the same possibility to add extension.

 

thanks

0 Likes
Message 14 of 18

Sea-Haven
Mentor
Mentor

I have posted many times the plot Layout range lisp to here search for it, "plotA3Pdfrange.lsp"

 

Maratovich has a good extensive plot program as well again search.

Message 15 of 18

maratovich
Advisor
Advisor

@Millwood-k  написал (-а):


🙂

Try this - AutoRunLisp 

 

 

---------------------------------------------------------------------
Software development
Automatic creation layouts and viewport. Batch printing drawings from model.
www.kdmsoft.net
0 Likes
Message 16 of 18

Millwood-k
Advocate
Advocate

Yes I saw that it's very useful, however in my case I d like a simple script for some reason.

 

Thanks

 

 

0 Likes
Message 17 of 18

m.mazaz
Explorer
Explorer
Hi I I make a small change to the original code to make it show only the layout name only

and btw I think it is better to save the drawings in the same path 🙂

have fun


(defun c:test ( / base old_dia)
(setq old_dia (getvar 'FILEDIA)
base (strcat (getvar 'DWGPREFIX) )
)
(setvar 'FILEDIA 0)
(setq lst (layoutlist))


(foreach lst (layoutlist)
(command "_.ctab"
lst
"exportlayout"
(strcat base "" lst)
)
)
(setvar 'FILEDIA old_dia)
(princ)
)
0 Likes
Message 18 of 18

Sea-Haven
Mentor
Mentor

Early in your posts you refer to not finding code, you should make yourself a directory called say D:\Mylisps put all your lisps in there type Config select Files and add D:\mylisps to your search path and trusted paths, much easier than the desktop.

 

Here is plotpdfa3range.

0 Likes