Jump to content

Lisp to set plot up


Baber62
 Share

Recommended Posts

Hi Guys I came across the following routine, from https://forums.autodesk.com/t5/forums/forumtopicprintpage/board-id/130/message-id/336228/print-single-message/false/page/2

 

However, when I tried it it gives me an error message ; error: no function definition: LM:ODBX

 

How can I get this to work and also change the default size to A1 rather than A2.

 

(defun c:RV ( / )
   (LM:ODBX
       (function
           (lambda ( doc )
	(princ (strcat "\nOpening file : "(vla-get-name doc)))
	(vlax-for lay (vla-get-layouts doc)

		; (if ( = "Model" (vla-get-name lay))
			; (progn
			(setq PaperSize "ISO_A2_(594.00_x_420.00_MM)");-----default paper size
			
			(princ "\nSearching for Title Block")
			(vlax-for blk (vla-get-blocks doc)
			(cond
				(( = (vla-get-name blk) "Title_A4") (setq PaperSize "ISO_A4_(297.00_x_210.00_MM)"))
				(( = (vla-get-name blk) "A3 Drawing Sheet") (setq PaperSize "ISO_A3_(420.00_x_297.00_MM)"))
				(( = (vla-get-name blk) "Title_A2") (setq PaperSize "ISO_A2_(594.00_x_420.00_MM)"))
				(( = (vla-get-name blk) "Title_A1") (setq PaperSize "ISO_A1_(841.00_x_594.00_MM)"))
			);cond
			);vlax-for blocks
			(princ (strcat "\nPaper Size Assigned : " PaperSize))
			; );progn
		; );if model space


		(vla-put-ConfigName lay "DWG To PDF.pc3")	;set the plotter
		(vla-put-CanonicalMediaName lay PaperSize)		;set the paper size--->
		(vla-put-PlotType lay "1")			;plot area extens
		(vla-put-CenterPlot lay "1")			;center plot
		(vla-put-PaperUnits lay "1")			;set units to mm
		(vla-put-PlotWithLineweights lay "0")		;turn off lineweights
		(vla-put-PlotWithPlotStyles lay "1")		;turn on plot styles
		(vla-put-StandardScale lay "0")			;fit to paper
		(vla-put-stylesheet lay "Grayscale.ctb")	;set  the CTB
		(princ (strcat "\nPlot settings done for : "(vla-get-name lay)))
	);vlax-for
	(princ "\n--------------------------------------------------")
           )
       )
       nil t
   )
   (princ)
);defun

  • Like 1
Link to comment
Share on other sites

Re: change default paper size. Wouldn't you just substitute "ISO_A1_(841.00_x_594.00_MM)") for "ISO_A2_(594.00_x_420.00_MM)") where it says (setq PaperSize...default paper size? Can't help you with the first question. Sorry.

Link to comment
Share on other sites

In general, if you see a function that starts with LM: it will have been created by Lee Mac because that is his signature he puts on nearly all functions (you can also bet that it will be an awesome function because he is the master of all things LISP haha). That function can be found on his website http://www.lee-mac.com/odbxbase.html.

Link to comment
Share on other sites

In general, if you see a function that starts with LM: it will have been created by Lee Mac because that is his signature he puts on nearly all functions (you can also bet that it will be an awesome function because he is the master of all things LISP haha).

 

Haha! Thanks broncos :thumbsup:

Link to comment
Share on other sites

My $0.05 went a slightly different way just have a pull down menu with the various plot sizes and destination printer hard coded rather than select. Pick option 20 sheets come out etc.

Screen Shot 05-27-16 at 01.19 PM.PNG

Link to comment
Share on other sites

  • 5 years later...
On 5/26/2016 at 1:15 AM, Lee Mac said:

 

Haha! Thanks broncos :thumbsup:

@Lee Mac

@BIGAL

 

I'm using this great code.

I wonder if it is possible to change all DWG files including subfolders.

 

Best regards,

 

 

 

(defun c:RV ( / )
    (LM:ODBX
        (function
            (lambda ( doc )
        (princ (strcat "\nOpening file : "(vla-get-name doc)))
        (vlax-for lay (vla-get-layouts doc)
            
                (setq PaperSize "ISO_A3_(297.00_x_420.00_MM)");-----default paper size for Modelspace
                (princ "\nSearching in Model space for Title Block")
                (vlax-for blk (vla-get-blocks doc)
                (cond
                    (( = (vla-get-name blk) "A4 Drawing Sheet") (setq PaperSize "ISO_A4_(210.00_x_297.00_MM)")(vla-put-PlotRotation lay "1"))
                    (( = (vla-get-name blk) "A3 Drawing Sheet") (setq PaperSize "ISO_A3_(420.00_x_297.00_MM)")(vla-put-PlotRotation lay "0"))
                    (( = (vla-get-name blk) "A3P Drawing Sheet") (setq PaperSize "ISO_A3_(297.00_x_420.00_MM)")(vla-put-PlotRotation lay "1"))
                    (( = (vla-get-name blk) "A2 Drawing Sheet") (setq PaperSize "ISO_A2_(594.00_x_420.00_MM)")(vla-put-PlotRotation lay "0"))
                    (( = (vla-get-name blk) "A1 Drawing Sheet") (setq PaperSize "ISO_A1_(841.00_x_594.00_MM)")(vla-put-PlotRotation lay "0"))
                );cond
                );vlax-for blocks
                (princ (strcat "\nPaper Size for Model Space : " PaperSize))

            (vla-put-ConfigName lay "DWG To PDF.pc3")    ;set the plotter
            (vla-put-CanonicalMediaName lay PaperSize)    ;set the paper size
            (vla-put-PlotType lay "1")            ;plot area extens
            (vla-put-CenterPlot lay "1")            ;center plot
            (vla-put-PaperUnits lay "1")            ;set units to mm
            (vla-put-PlotWithLineweights lay "0")        ;turn off lineweights
            (vla-put-PlotWithPlotStyles lay "1")        ;turn on plot styles
            (vla-put-StandardScale lay "0")            ;fit to paper
            (vla-put-PlotRotation lay "1")            ;Drawing orientation 1=portrait 0=landscape
            (vla-put-stylesheet lay "acad.ctb")    ;set  the CTB
            (princ (strcat "\nPlot settings done for : "(vla-get-name lay)))
        );vlax-for
        (princ "\n--------------------------------------------------")
            )
        )
        nil t
    )
    (princ)
);defun

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...