Message 1 of 23

Not applicable
09-23-2020
09:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
So with the help of this forum and lots of searching and many failures, this works like it should.
If you have several layout tabs this will delete any layout that is empty and make one PDF with all the layouts, if a layout is named COLOR (must be caps) only this page will be in color all others will be black and white.
Attached is a screen shot of layout tabs and the resulting PDF.
Could the code be made more simple? Or cleaned up a little?
Thanks for any advice.
(defun c:pdf2 ( /)
(vl-load-com)
; removes any empty sheets
(vlax-for objLayout (setq colLayouts (vla-get-layouts(vla-get-activedocument(vlax-get-acad-object))))
(if (and (< (vla-get-count (vla-get-block objLayout)) 2) (> (vla-get-count colLayouts) 2))
(if (/= (vla-get-name objLayout) "Model")
(vla-delete objLayout)
);if
); if
);vlax-for end
;check each layout named COLOR run color program
(foreach l (layoutlist)
(if (wcmatch (strcase l) (strcat "*COLOR*"))
(clrpdf)
);if
);foreach
;Check each layout is not named COLOR run monochrome program
(foreach l (layoutlist)
(if (not (wcmatch (strcase l) (strcat "*COLOR*")))
(bwpdf)
);if
)
;refresh all the sheets before export to set proper scale
(vla-Regen (vla-get-ActiveDocument (vlax-get-acad-object)) acAllViewports)
;sets PDF name to SHEET
; Gets drawing base name
(setq dwgnms (vl-filename-base (getvar 'dwgname)))
(setq prefs (getvar 'dwgprefix))
; exports PDF as batchplot-model.pdf
(command "_.-export" "_PDF" "_A" (strcat prefs dwgnms))
(prompt "\nComplete...")
(princ)
);defun
**********************************************
;program for color layout set up
(defun clrpdf ()
(setvar "CTAB" l)
;cycle all sheets, skip model
(vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
;if not model sheet
(if (/= "Model" (vla-get-name lay))
(if (wcmatch (strcat (vla-get-name lay)) (strcat "*COLOR*"))
(progn
(vla-put-ConfigName lay "None") ; set ploter name to none
(vla-put-CanonicalMediaName lay "ANSI_E_(34.00_x_44.00_Inches)") ;Paper ANSI E
(vla-put-PlotRotation lay 1) ;landscape
(vla-put-stylesheet lay "acad.ctb") ;set to acad
(vla-put-plottype lay 1) ;plot area extents
(vla-put-CenterPlot lay T) ;center plot
(vla-put-UseStandardScale lay T) ;use standard scale
(vla-put-PlotViewportsFirst lay T) ;plot viewports first check
(vla-put-PlotWithPlotStyles lay T) ;plot with styles check
(vla-put-PlotWithLineweights lay T) ;Check Lineweights
(vla-put-StandardScale lay acScaleToFit) ;Fit to paper
);progn
);if color
);if model
);vlax
);defun end
**********************************************
;program for monochrome layout set up
(defun bwpdf ()
;cycle all sheets, skip model
(vlax-for lay (vla-get-layouts (vla-get-ActiveDocument (vlax-get-acad-object)))
;if not model sheet
(if (/= "Model" (vla-get-name lay))
(if (not (wcmatch (strcat (vla-get-name lay)) (strcat "*COLOR*")))
(progn
(vla-put-ConfigName lay "None") ; set ploter name to none
(vla-put-CanonicalMediaName lay "ANSI_E_(34.00_x_44.00_Inches)") ;Paper ANSI E
(vla-put-PlotRotation lay 1) ;landscape
(vla-put-stylesheet lay "monochrome.ctb") ;set to monochrome
(vla-put-plottype lay 1) ;plot area extents
(vla-put-CenterPlot lay T) ;center plot
(vla-put-UseStandardScale lay T) ;use standard scale
(vla-put-PlotViewportsFirst lay T) ;plot viewports first check
(vla-put-PlotWithPlotStyles lay T) ;plot with styles check
(vla-put-PlotWithLineweights lay T) ;Check Lineweights
(vla-put-StandardScale lay acScaleToFit) ;Fit to paper
);progn
);if color
);if model
);vlax
);defun end
Solved! Go to Solution.