How to distinguish a "paper space" drawing from a "model space" drawing

How to distinguish a "paper space" drawing from a "model space" drawing

dmfrazier
Advisor Advisor
2,237 Views
19 Replies
Message 1 of 20

How to distinguish a "paper space" drawing from a "model space" drawing

dmfrazier
Advisor
Advisor

I would like to be able to automatically (via AutoLISP during document startup) distinguish between DWGs that are set up to plot from MS only and DWGs that are set up to plot from PS (or both). Is there a reliable "marker" (or set of markers) that exists in a DWG file that indicates it is set up one way or the other?  (I think the answer is no, but I hope to be proven wrong.)

0 Likes
Accepted solutions (1)
2,238 Views
19 Replies
Replies (19)
Message 2 of 20

Kent1Cooper
Consultant
Consultant
Accepted solution

@dmfrazier wrote:

I would like to be able to automatically (via AutoLISP during document startup) distinguish between DWGs that are set up to plot from MS only and DWGs that are set up to plot from PS (or both). Is there a reliable "marker" (or set of markers) that exists in a DWG file that indicates it is set up one way or the other?  ....


If  your Users always  give Paper Space Layouts meaningful names, and don't just leave them called "Layout1", "Layout2", etc., then you can do the AutoLisp (layoutlist) function, and test whether any of the names in the returned list do not start with "Layout".

 

For example, if this:

 

(member T (mapcar '(lambda (x) (not (wcmatch x "Layout*"))) (layoutlist)))

 

returns nil, then the names of all Layouts start with "Layout", and presumably [if all Users are disciplined about naming them] the drawing is set up for Model-space-only operation.  If it doesn't  return nil [a list starting with T, that may have additional T's and/or nils in it], then there is at least one meaningfully-named Layout, and presumably the drawing is set up for Paper-space operation.

Kent Cooper, AIA
Message 3 of 20

dmfrazier
Advisor
Advisor

Thank you, Kent.  I need a little time to test it out, but this looks promising. 

0 Likes
Message 4 of 20

paullimapa
Mentor
Mentor

Since AutoCAD provides users with the ability to plot both in Modelspace as well as in Paperspace, there really is no full proof way to determine if a particular drawing is setup only to plot one way vs another.  Even if standards were set so that users are told to only setup plotting procedures in Layouts vs Modelspace, unfortunately, there's no function AutoCAD offers to turn off plotting commands in Modelspace. Perhaps this could be a wishlist for Autodesk to add this as an option in future releases?

 

 

Area Object Link | Attribute Modifier | Dwg Setup | Feet-Inch Calculator
Layer Apps | List on Steroids | VP Zoom Scales | Exchange App Store


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 5 of 20

dmfrazier
Advisor
Advisor

Thanks for your comments.

 

I have no interest in turning off plotting commands in either space.

 

This is all to exert better control over the running of a very simple bit of startup automation which is intended to ensure that the linetype scale is set correctly in a DWG before plotting. When we set up certain DWGs with a border in MS (in which case one DWG generally represents one "sheet"), it's not difficult to figure out what the intended scale factor is and then set LTScale accordingly.  But now we have certain scenarios where we find it helpful to use PS. In these cases we want LTScale set to 1/4 so that PSLTScale set to 1 works correctly when plotting PS layouts. The trick is in figuring out when to set it one way versus the other.

 

I agree (and lament) that there is no "foolproof" way. I think Kent's suggestion to look for non-generic PS tab name(s) may be the best bet.

0 Likes
Message 6 of 20

dgorsman
Consultant
Consultant

Maybe you could stream in some automation during normal operation that loads named page set-ups to model or paper space.  That way when iterating for printing you could just find the layout(s) with the named page set-ups (and use them, too).

 

In-house we add some data to the drawing, such as a "drawing type", to handle such things.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


Message 7 of 20

dmfrazier
Advisor
Advisor

Thank you, David.  Good suggestions, but for this particular purpose (and moment) looking for a non-generic layout tab name in the DWG will do the trick (until it doesn't).

0 Likes
Message 8 of 20

john.uhden
Mentor
Mentor

I was just thinking that one would not have a PS layout without a viewport, right?

 

(ssget "X" '((0 . "VIEWPORT")))

John F. Uhden

0 Likes
Message 9 of 20

dmfrazier
Advisor
Advisor

Not necessarily.

 

I assume your suggestion is that the existence of a viewport on any layout tab can be taken as evidence that the layout is intended for plotting. Not a bad thought. (How could it be bad if I had it, too?)

 

Unfortunately, the existence of a viewport on a layout tab doesn't necessarily mean that the layout will be used to plot from.  For example, the default template used to create a new drawing might have a "default" Layout1 tab with a "default" viewport, which may simply be ignored in cases where the user produces a DWG that is set up to plot from the model tab.

 

The converse of this, that lack of a viewport can be taken as evidence that a layout is not intended for plotting, is also unreliable because it's conceivable that a layout tab could be set up with only objects in PS (such as notes, tables, and images) but no viewport.

 

Thanks for the thought.

0 Likes
Message 10 of 20

john.uhden
Mentor
Mentor

How about if there is nothing in paperspace except a viewport?

 

(ssget "x" '((0 . "~VIEWPORT")(410 . "~Model")))

John F. Uhden

0 Likes
Message 11 of 20

dmfrazier
Advisor
Advisor

What would I be able to reliably infer from that condition?

0 Likes
Message 12 of 20

john.uhden
Mentor
Mentor

You could reliably infer that "there is nothing in paperspace except (maybe) a viewport."

 

But that can't be reliable because maybe the user puts everything including title blocks, notes, and details in modelspace but plots it through a paperspace viewport.

 

What would be 100% reliable is if there is nothing in paperspace.  Well actually that's not 100% reliable in Land Desktop which kept its ADCADD_ZZ block in paperspace with xdata for all the drawing setup data (base point, north rotation, elevation precision, etc.).  But we could exclude that in the filter.

John F. Uhden

0 Likes
Message 13 of 20

dmfrazier
Advisor
Advisor

Agreed.

 

A nut not as easy to crack as at first it may seem.

 

Thus my acceptance of Kent's intuitively insightful (again!) response as a workable solution and my decision to move on (until I have reason to re-consider it).

 

Thanks, again.

0 Likes
Message 14 of 20

john.uhden
Mentor
Mentor

220, 221.

 

You agree that your users plot a PS layout that has nothing in it except a viewport?

John F. Uhden

0 Likes
Message 15 of 20

dbroad
Mentor
Mentor

"intuitively insightful" maybe but a relatively low bar of testing in my opinion. For a lazy drafter, it is quite possible that they wouldn't bother changing the name of the layout.  It's also unclear whether or not the model tab is actually initialized or how many layouts are initialized for plotting. If you want a slightly higher bar for testing, consider the following.

;;return a list of layouts that are probably initialized for plotting
;;D.C. Broad, Jr. 9/28/2017
(defun initializedlayouts (/ lays lay)
  (vlax-for n (vla-get-blocks
		(vla-get-ActiveDocument
		  (vlax-get-acad-object)
		)
	      )
    (if	(and
	  (= :vlax-true (vla-get-islayout n))
	  (setq lay (vla-get-layout n))
	  (/= "" (vla-get-CanonicalMediaName lay))
	  (/= "" (vla-get-StyleSheet lay))
	)
      (setq lays (cons (vla-get-name lay) lays))
    )
  )
  (reverse lays)
)

 In addition, consider

  1. It's possible that an initialized layout, complete with title block and viewports was never actually plotted, nor will it ever be plotted if the template predefines all sorts of optional layouts.
  2. It's possible to have a plottable paper space layout without a viewport if everything was intended to be paper space objects.
  3. The plot log file contains a record of plots done for a particular computer.  It is worth parsing if valid plotting information is desired.
  4. If, as I do, all plots are sent to pdf's, it's worth looking at the folder containing the PDF or DWF plots.
  5. A more complex test would test to see if a layout was part of a sheet set.
Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 16 of 20

dmfrazier
Advisor
Advisor

"You agree that your users plot a PS layout that has nothing in it except a viewport?"

 

Yes, I do. It's not a common occurrence, but it does happen in my environment.

0 Likes
Message 17 of 20

john.uhden
Mentor
Mentor

There ya go.  I was thinking of plot setups, but had no decent idea of how to access them or use them.

But to continue the Debbie Downer theme, the template file from which they start may have empty layouts already set up for plotting. 😕

John F. Uhden

0 Likes
Message 18 of 20

dmfrazier
Advisor
Advisor

I referred to Kent's suggestion in this way because he seemed to "magically" know what I was after without having to ask for any more information than I had already provided. Perhaps it was just luck, but based on (relatively few, but worthwhile) previous encounters with him here, I have reason to think otherwise.

 

"...a relatively low bar of testing in my opinion."

 

And I value your opinion (especially when it matches mine!).

 

I had initially thought that "a solution" might involve looking at/for page setups, but I could not envision how to do it in LISP (hopeless hack that I am), and even if I could I'm still not sure how reliable the test might be.  I won't have time immediately to see how your code works for me, but eventually I will try it out and let you know.

 

In my environment, the layout name test will probably turn out to be very reliable.

 

I appreciate your list of other considerations.  Some of these have already been considered (in my mind and in other posts here).  Also, note that my concern is not whether a layout "has been plotted"; it's whether a layout "will be plotted."

 

Thanks.

0 Likes
Message 19 of 20

john.uhden
Mentor
Mentor

You could instruct everyone that plotting is allowed only in a PS layout.  In fact you could create a reactor that prevents them from plotting in MS.  Then it doesn't matter what they name their layouts.

John F. Uhden

0 Likes
Message 20 of 20

dmfrazier
Advisor
Advisor

Indeed, these are things that could be done.  Fortunately, I have simpler alternatives that will probably work better under the circumstances.

 

Thanks.

0 Likes