Layout to plot with different layer settings depending on content of layout name

Layout to plot with different layer settings depending on content of layout name

vporrash141089
Advocate Advocate
899 Views
4 Replies
Message 1 of 5

Layout to plot with different layer settings depending on content of layout name

vporrash141089
Advocate
Advocate

Hello I'm trying to work on some code I got a time back, BTW most of it was @CodeDing s, Here is what I need and all help is very much appreciated.

 

I want to plot a layout list which will always contain A_A_100 for arch A_AE_100 for ceiling and A_AI_100 for Furniture. However as it is on the code and the attached dwg the beginning is a portion that varies depending on the project we are working on.

 

As you can see I can't make Autocad understand that I need to plot each one of the layouts with a different layer visibility.

 

Is there a way to achieve what I am attempting? also when it plots it moves my page setup and it messes with the location of my title block which is in layer 0

 

The main reason we are doing this is so we can plot with one command  a set of layouts and and not having to manually freeze all layers.

 

Again thanks in advanced.

 

(defun c:PA ( / cmd layouts2Plot lyrs2TurnOff1 lyrs2TurnOff2 lyrs2TurnOff3 laylist cnt fname)
;Prep for plot
(setq cmd (getvar 'CMDECHO)) (setvar 'CMDECHO 0)
(setq layouts2Plot '("varies_A_A_100" "varies_A_AE_100" "varies_A_AI_100")
lyrs2TurnOff1 "A-FURN,A-CEIL";comma separated
lyrs2TurnOff2 "A-FURN";comma separated
lyrs2TurnOff3 "A-CLNG";comma separated
layouts2Plot (mapcar 'strcase layouts2Plot)
laylist (mapcar 'strcase (layoutlist))
cnt 1)
;loop through layouts2Plot (checking if the layout exists)
(foreach layout layouts2Plot
(prompt (strcat "\n" layout "... "))
(if (member (strcase layout) laylist)
(progn
(setvar 'CTAB layout)
(command "_.ZOOM" "e")

(if (eq "varies_A_A_100" layout) (command "-LAYER" "OFF" lyrs2TurnOff1 ""))
(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))

(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")


(if (eq "varies_A_AE_100" layout) (command "-LAYER" "ON" lyrs2TurnOff2""))
(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))

(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")


(if (eq "varies_A_AI_100" layout) (command "-LAYER" "ON" lyrs2TurnOff3""))
(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))

(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")

(prompt "Complete.")
);progn
;else
(prompt "Could not find layout.")
);if
);foreach
;Finish & clean up
(setvar 'CMDECHO cmd)
(prompt "\plotting Complete.")
(princ)
);defun

0 Likes
900 Views
4 Replies
Replies (4)
Message 2 of 5

dbhunia
Advisor
Advisor

Check with this Modifications....... I just re-arranged your existing code....... 

 

(defun c:PA ( / cmd C_Tab layouts2Plot lyrs2TurnOff1 lyrs2TurnOff2 lyrs2TurnOff3 laylist fname)
;Prep for plot
(setq cmd (getvar 'CMDECHO) C_Tab (getvar 'CTAB)) (setvar 'CMDECHO 0)
(setq layouts2Plot '("varies_A_A_100" "varies_A_AE_100" "varies_A_AI_100")
	lyrs2TurnOff1 "A-FURN,A-CEIL";comma separated
	lyrs2TurnOff2 "A-FURN";comma separated
	lyrs2TurnOff3 "A-CLNG";comma separated
	laylist (layoutlist);I removed "strcat" as your input "layouts2Plot" list & Layout Tab Names are same in sample Drawing
)
;loop through layouts2Plot (checking if the layout exists)
(foreach layout layouts2Plot
	(prompt (strcat "\n" layout "... "))
	(if (member layout laylist)
		(progn
			(setvar 'CTAB layout)
			(command "_.ZOOM" "e")
			(if (eq "varies_A_A_100" layout)
				(progn
					(command "-LAYER" "OFF" lyrs2TurnOff1 "")
					(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
						  fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))
					(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")
				)
			)
			(if (eq "varies_A_AE_100" layout) 
				(progn
					(command "-LAYER" "ON" lyrs2TurnOff2 "")
					(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
						  fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))
					(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")
				)
			)
			(if (eq "varies_A_AI_100" layout)
				(progn
					(command "-LAYER" "ON" lyrs2TurnOff3 "")
					(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
						  fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout))
					(command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y")
				)
			)
			(prompt "Complete.")
		);progn
		;else
		(prompt "Could not find layout.")
	);if
);foreach
;Finish & clean up
(setvar 'CTAB C_Tab)
(setvar 'CMDECHO cmd)
(prompt "\plotting Complete.")
(princ)
);defun

Or like this.......

 

(defun c:PA ( / cmd C_Tab layouts2Plot lyrs2TurnOff1 lyrs2TurnOff2 lyrs2TurnOff3 laylist fname)
;Prep for plot
(setq cmd (getvar 'CMDECHO) C_Tab (getvar 'CTAB)) (setvar 'CMDECHO 0)
(setq layouts2Plot '("varies_A_A_100" "varies_A_AE_100" "varies_A_AI_100")
	lyrs2TurnOff1 "A-FURN,A-CEIL";comma separated
	lyrs2TurnOff2 "A-FURN";comma separated
	lyrs2TurnOff3 "A-CLNG";comma separated
	laylist (layoutlist)
) ;loop through layouts2Plot (checking if the layout exists) (foreach layout layouts2Plot (prompt (strcat "\n" layout "... ")) (if (member layout laylist) (progn (setvar 'CTAB layout) (command "_.ZOOM" "e") (cond ((eq "varies_A_A_100" layout) (command "-LAYER" "OFF" lyrs2TurnOff1 "") (setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME)) fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout)) (command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y") ) ((eq "varies_A_AE_100" layout) (command "-LAYER" "ON" lyrs2TurnOff2 "") (setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME)) fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout)) (command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y") ) ((eq "varies_A_AI_100" layout) (command "-LAYER" "ON" lyrs2TurnOff3 "") (setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME)) fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" layout)) (command "-plot" "y" "" "DWG To PDF.pc3" "ARCH expand E1 (30.00 x 42.00 Inches)" "i" "L" "no" "WINDOW" "1.25,0.75" "41.75,29.25" "1:1" "C" "y" "monochrome.ctb" "y" "n" "n" "n" fname "Y" "y") ) ) (prompt "Complete.") );progn ;else (prompt "Could not find layout.") );if );foreach ;Finish & clean up (setvar 'CTAB C_Tab) (setvar 'CMDECHO cmd) (prompt "\plotting Complete.") (princ) );defun

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

vporrash141089
Advocate
Advocate

Hi @dbhunia 

 

I really appreciate your help so thank you! I feel like I did not explain my self correctly maybe it's my English but also it's hard to explain so I tried to come up with something logical that makes sense but it's clearly not lisp coded.

 

here is what I wish to have: A lisp that will set my Viewport layers as needed, once this step is done then plot all.

 

Here is an example:

 

(defun c:Plotalllayouts (/) ; All layouts must have different layer visibilities

(if layout (wcmatch "A_AE_100"))
(vplayer "freeze *A-FURN*" ; if layout "A_AE_100" exists freeze all layers containing the preffix *A-FURN*

(if layout (wcmatch "A_AI_100"))
(vplayer "freeze *A-CEIL*" ; if layout "A_AI_100" exists freeze all layers containing the preffix *A-CEIL*

(if layout (wcmatch "A_A_100"))
(vplayer "freeze *A-CEIL*,*A-FURN*" ; if layout "A_A_100" exists freeze all layers containing the preffixES *A-CEIL* and also *A-FURN*

;If all the above is true plot all PDFs one folder back not in the same location but the folder before it make it so the name is the same as each
;layout no matter if the name is different than A_AE_100 A_AI_100 or A_A_100 because in the end this are suffixes.

;Basically the goal is to use this to set visibility for all my layouts and the just plot all.

(setvar 'CTab lay)
(COMMAND "-PLOT"
"Y"
""
"DWG To PDF.pc3"
"ARCH E1 (30.00 x 42.00 Inches)"
"Inches"
"Landscape"
"N"
"E"
"f"
"C"
"Y"
"monochrome.ctb"
"Y"
"N"
"N"
"N"
""; Name of file
"N"
"y"))
)

 

Thanks again!

Victor

0 Likes
Message 4 of 5

dbhunia
Advisor
Advisor

Hi @vporrash141089  ...... sorry for late, I was quite buesy today ........ so unable to answer you........

 

shall do it ...... need some time 🙂

 

 


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

dbhunia
Advisor
Advisor

As I get from your sample Drawing ....... there is only one View Port in each Layout......

 

If so then try this.......

 

Hopefully you can manage the rest....... 🙂

 

(defun c:PA ( / Lay Tab_Print fname)
	(setvar 'cmdecho 0)
	(foreach Lay_Out (layoutlist)
		(if (wcmatch Lay_Out "*A_AE_100,*A_AI_100,*A_A_100")
			(progn
				(cond ((wcmatch Lay_Out "*A_AE_100") (setq Lay "*A-FURN*"))
					  ((wcmatch Lay_Out "*A_AI_100") (setq Lay "*A-CEIL*"))
					  ((wcmatch Lay_Out "*A_A_100") (setq Lay "*A-CEIL*,*A-FURN*"))
				)
				(setvar 'ctab Lay_Out)
				(command "_.mspace")
				(command "_.vplayer" "_F" Lay "" "")
				(command "_.pspace")
				(setq Tab_Print (cons Lay_Out Tab_Print))
			)
		)
	)
	;(foreach Tab (layoutlist) ;;;Use this to print all Layouts
	(foreach Tab Tab_Print ;;;or this to print only *A_AE_100/*A_AI_100/*A_A_100 Layouts which are exists
		(setq fname (strcat (getvar 'DWGPREFIX) (getvar 'DWGNAME))
			  fname (strcat (substr fname 1 (- (strlen fname) 4)) "-" Tab)
		)
		(setvar 'ctab Tab)
		(COMMAND "-PLOT" "Y" "" "DWG To PDF.pc3" "ARCH E1 (30.00 x 42.00 Inches)" "Inches" "Landscape" "N" "E" "f" "C" "Y" "monochrome.ctb" "Y" "N" "N" "N" fname "N" "y")
	)
	(setvar 'cmdecho 1)
	(princ)
)

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