Turn Off Display paper background / printable area, set PS Limits, turn on again

Turn Off Display paper background / printable area, set PS Limits, turn on again

RockyBrown4134
Collaborator Collaborator
2,013 Views
7 Replies
Message 1 of 8

Turn Off Display paper background / printable area, set PS Limits, turn on again

RockyBrown4134
Collaborator
Collaborator

Here is the task I would like to do:

Set Paper Space Limits while Display Paper Background and Printable Area is selected in the options dialog box. I would like to do this in lisp. I think this is the protocol below

  •    Turn "display paper background" and "display printable area" "OFF" (in paper space)
  •    Reset the limits by changing LIMMIN and LIMMAX values, or by "limits" command.
  •    Turn "display paper background" and "display printable area" "ON" (in paper space)

 

Is there a way to do it in LISP? I have tried what I know and I can't think of any way. All suggestions are welcome.

 

Thanks.

Using AutoCAD 2020

 

 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Accepted solutions (2)
2,014 Views
7 Replies
Replies (7)
Message 2 of 8

dlanorh
Advisor
Advisor
Accepted solution

@RockyBrown4134 wrote:

Here is the task I would like to do:

Set Paper Space Limits while Display Paper Background and Printable Area is selected in the options dialog box. I would like to do this in lisp. I think this is the protocol below

  •    Turn "display paper background" and "display printable area" "OFF" (in paper space)
  •    Reset the limits by changing LIMMIN and LIMMAX values, or by "limits" command.
  •    Turn "display paper background" and "display printable area" "ON" (in paper space)

 

Is there a way to do it in LISP? I have tried what I know and I can't think of any way. All suggestions are welcome.

 

Thanks.

Using AutoCAD 2020

 

 


Yes. But its works on all layout tabs. Reset the LIMMIN and LIMMAX to what?

 

Try the below. The (getpoint) is to pause the lisp, and will continue when you select a point on the screen.

 

(defun c:tpsp ( / disp)
  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (vlax-put-property disp 'layoutdisplaypaper :vlax-false)
  (vlax-put-property disp 'layoutdisplaymargins :vlax-false)
  (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
  (getpoint)
  (vlax-put-property disp 'layoutdisplaymargins :vlax-true)
  (vlax-put-property disp 'layoutdisplaypaper :vlax-true)
  (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)

  (princ)
)

 

I am not one of the robots you're looking for

Message 3 of 8

RockyBrown4134
Collaborator
Collaborator

I'm trying to reset the limits of a layout tab, from a page setup, to adjust my custom borders. If the "Display paper background" and "Display printable area" are "ON", AutoCAD will not allow you to set the limits, nor change the LIMMAX and LIMMIN variables. My current templates have correct page layout in them, based on ANSI sheet sizes. It's when I get an older drawing created years ago and I need to update it to the new drawing format. I may be over thinking this. There may be a better way to achieve the same result.

 

I will try the code in my cleanup routine. So far, it's great. It appears to work the way I requested. Thank you for the help. I'll let you know if it works. All credit to dianorh!

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 4 of 8

dlanorh
Advisor
Advisor

It doesn't do anything other than turn off the paper & margin then turn them on again.

I am not one of the robots you're looking for

Message 5 of 8

RockyBrown4134
Collaborator
Collaborator

I am aware. I will most likely make it  two commands, and Place it accordingly in my routine.  Otherwise, I will add my code to reset the limits where you have the (getpoint) statement. Still giving credit to you.

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 6 of 8

dlanorh
Advisor
Advisor

OK 👍

I am not one of the robots you're looking for

0 Likes
Message 7 of 8

RockyBrown4134
Collaborator
Collaborator
Accepted solution

After checking several things, I learn something new by mistake.  To make a long story short, I didn't need to reset the limits. Instead, when I checked the paper size in my page setup, there was a border setting of 0.12 on three sides and 0.13 on the forth. I did not allow for that when I was programming because it didn't register. 

 

So to cure my issue, I set all borders to 0.12 and made the numerical changes in the code. What I learned was that you can set borders to pages in page layouts. Also, be aware of them when working in paper space. 

If this response answers your question, Please mark this response as "Accept as Solution"

Rocky Brown
AutoCAD 2020 / Inventor 2020 / Plant 3D
0 Likes
Message 8 of 8

Baker_ADG
Advocate
Advocate

I replaced

(getpoint)

with 

(Command "LIMITS" "0,0" "36,24")

 so i dont have to pick it. Added to an existing lisp that inserts a defined page setup from a template and boom.. it does it all for me. 

(defun C:pntplt ()

  (setq disp (vla-get-display (vla-get-preferences (vlax-get-acad-object))))
  (vlax-put-property disp 'layoutdisplaypaper :vlax-false)
  (vlax-put-property disp 'layoutdisplaymargins :vlax-false)
  (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)

(Command "LIMITS" "0,0" "36,24")


  (vlax-put-property disp 'layoutdisplaymargins :vlax-true)
  (vlax-put-property disp 'layoutdisplaypaper :vlax-true)
  (vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)

  (princ)




;===========================================================================================
(setvar "tilemode" 0)
(vl-load-com) 

;(DelPgSetups) 


(setq pl (vla-get-PlotConfigurations
(vla-get-activedocument
(vlax-get-acad-object))))
(vlax-for item pl
(vlax-invoke-method item 'delete)
)

(command "._-PSETUPIN" "C:/enter path to your drawing.dwt" "ARCH_D_PDF")


(defun SetCurrentPageSetup (doc pcname / layout PlotConfig)
  (setq	doc (vla-get-activedocument (vlax-get-acad-object)))
  (setq layout (vla-get-activelayout doc))
  (setq PlotConfig (vl-catch-all-apply
		     'vla-item
		     (list
		       (vla-get-PlotConfigurations
			 doc
		       )
		       pcname
		     )
		   )
  )
  (if (not (vl-catch-all-error-p PlotConfig))
    (vla-copyfrom layout PlotConfig)
  )
)

(SetCurrentPageSetup <AcadDocument> <PageSetupName>)
(SetCurrentPageSetup (vla-get-activedocument (vlax-get-acad-object)) "ARCH_D_PDF")

;==

  (setq	aDoc  (vla-get-activedocument (vlax-get-acad-object))
	Layts (vla-get-layouts aDoc)
	clyt  (vla-get-activelayout aDoc)
  )
  (foreach
	    itm
	       (vl-remove (vla-get-name clyt) (layoutlist))
    (vla-copyfrom (vla-item Layts itm) clyt)
  )

;==



)
Jon Baker | Land Development & Infrastructure Design Manager
Alignment Design Group | Denver | Colorado
Civil 3D 2025 | Windows 11