Jump to content

Defining named page setups (in model space)


Three.One-Four

Recommended Posts

My company plots from model space. And each user has their drawing area in random places. While we work towards using a template with paper space, they would like a quick routine to set up and use named page setups.

 

I have the following to start, but it's adding the page setups to the first paper space layout instead of the current model space, and without the saved view.  Any help or guidance is appreciated.  Thanks

 

(defun c:pss ()

(command "undo" "begin")
(setvar "filedia" 0)

(if (tblsearch "view" "Main")
(princ "\nView \"Main\" already exists. ") ; then
(progn
(princ "\nView \"Main\" does not exist.....  ")
(princ "Creating \"Main\": Select opposite corners of window:  ")
(command "-view" "w" "Main" pause pause)
) ;progn
) ;if

(if (tblsearch "view" "Cab")
(princ "\nView \"Cab\" already exists. ") ; then
(progn
(princ "\nView \"Cab\" does not exist.....  ")
(princ "Creating \"Cab\": Select opposite corners of window:  ")
(command "-view" "w" "Cab" pause pause)
) ;progn
) ;if

(if (tblsearch "view" "EC1")
(princ "\nView \"EC1\" already exists. ") ; then
(progn
(princ "\nView \"EC1\" does not exist.....  ")
(princ "Creating \"EC1\": Select opposite corners of window:  ")
(command "-view" "w" "EC1" pause pause)
) ;progn
) ;if

(if (tblsearch "view" "KCE")
(princ "\nView \"KCE\" already exists. ") ; then
(progn
(princ "\nView \"KCE\" does not exist.....  ")
(princ "Creating \"KCE\": Select opposite corners of window:  ")
(command "-view" "w" "KCE" pause pause)
) ;progn
) ;if

(command "-PLOT" "y" "Model" "DWG To PDF.pc3" "ARCH full bleed D (36.00 x 24.00 Inches)" "Inches" "Landscape" "No" "View" "Main" "0.25=12" "Center" "Yes" "MFC-Full_Size.stb" "Yes" "W" "" "Yes" "No")
(vla-add (vla-get-PlotConfigurations (vla-get-ActiveDocument (vlax-get-acad-object))) "Main")

(command "-PLOT" "y" "Model" "DWG To PDF.pc3" "ARCH full bleed D (36.00 x 24.00 Inches)" "Inches" "Landscape" "No" "View" "Cab" "0.375=12" "Center" "Yes" "MFC-Full_Size.stb" "Yes" "W" "" "Yes" "No")
(vla-add (vla-get-PlotConfigurations (vla-get-ActiveDocument (vlax-get-acad-object))) "Cab")

(command "-PLOT" "y" "Model" "DWG To PDF.pc3" "ARCH full bleed D (36.00 x 24.00 Inches)" "Inches" "Landscape" "No" "View" "EC1" "0.25=12" "Center" "Yes" "MFC-Full_Size.stb" "Yes" "W" "" "Yes" "No")
(vla-add (vla-get-PlotConfigurations (vla-get-ActiveDocument (vlax-get-acad-object))) "EC1")

(command "-PLOT" "y" "Model" "DWG To PDF.pc3" "ARCH full bleed D (36.00 x 24.00 Inches)" "Inches" "Landscape" "No" "View" "KCE" "0.25=12" "Center" "Yes" "MFC-Full_Size.stb" "Yes" "W" "" "Yes" "No")
(vla-add (vla-get-PlotConfigurations (vla-get-ActiveDocument (vlax-get-acad-object))) "KCE")

(setvar "filedia" 1)

(command "undo" "end")

(princ)
)
(princ)

 

Link to comment
Share on other sites

  • Replies 22
  • Created
  • Last Reply

Top Posters In This Topic

  • Three.One-Four

    11

  • ronjonp

    10

  • BIGAL

    1

  • tombu

    1

Popular Days

The easiest way to plot is to use the program as designed and use paperspace 🤓

 

Have you tried importing a template with your pagesetups? Look into the command PSETUPIN.

 

You could also use Lee's Steal program to pull views AND pagesetups from a template.

  • Thanks 1
Link to comment
Share on other sites

Understood.  And agreed.  This is a very old school company, with a very old school mentality.  And printing from model space use to be the standard in my field 20 years ago.  I'm working on getting them up to speed.

 

Problem with psetupin is that the plot areas are different in each drawing.  We'd have to redefine windows in each drawing, thus defeating the purpose of importing page setups.

 

So is this not possible?

Link to comment
Share on other sites

If there isn't consistency in your drawings for the plot areas I don't see how it can be automated other than using borders or something. Can you post a sample drawing?

 

FWIW, you could also use foreach like so to minimize duplicated code:

(defun c:pss (/ views)
  (command "_.undo" "begin")
  (setvar 'filedia 0)
  (foreach view	(setq views '("Main" "Cab" "EC1" "KCE"))
    (if	(tblsearch "view" view)
      (princ (strcat "\nView " view " already exists. ")) ; then
      (progn (princ (strcat "\nView "			      view
			    " does not exist.....\nCreating " view
			    ": Select opposite corners of window:"
			   )
	     )
	     (command "-view" "w" view "\\" "\\")
      )					;progn
    )
  )
  (foreach view	views
    (vla-add (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))) view)
    (command "-PLOT"
	     "y"
	     "Model"
	     "DWG To PDF.pc3"
	     "ARCH full bleed D (36.00 x 24.00 Inches)"
	     "Inches"
	     "Landscape"
	     "No"
	     "View"
	     view
	     (if (= "Cab" view)
	       "0.375=12"
	       "0.25=12"
	     )
	     "Center"
	     "Yes"
	     "MFC-Full_Size.stb"
	     "Yes"
	     "W"
	     ""
	     "Yes"
	     "No"
    )
  )
  (setvar 'filedia 1)
  (command "_.undo" "end")
  (princ)
)

 

Edited by ronjonp
Link to comment
Share on other sites

Oh, nice.  Thanks

 

Yeah, this wouldn't be so much an automated function.  More of a productivity routine.  Run the function once for each drawing and it'll make printing sheets for that plan a lot faster going forward.  Doing it manually with the PAGESTUP dialog won't go over well.  It's several keystrokes and mouse clicks.  This routine just prompts for picking the windows.

 

Sample dwg attached

7060.18.10AC.dwg

Link to comment
Share on other sites

@Three.One-Four

Do those titleblocks really have the text "KCE" etc in them or did you add that as the example?

 

Here's a version that save a pick per window: Apparently you can't pass the points to the view command...
 

(defun c:pss (/ e ll ur views)
  (command "_.undo" "begin")
  (setvar 'filedia 0)
  (foreach view	(setq views '("Main" "Cab" "EC1" "KCE"))
    (if	(tblsearch "view" view)
      (princ (strcat "\nView '" view "' already exists. ")) ; then
      (progn (princ (strcat "\nView '" view "' does not exist....."))
	     (if (setq e (car (entsel (strcat "\nPick '" view "' frame: "))))
	       (progn (vla-getboundingbox (vlax-ename->vla-object e) 'll 'ur)
		      (setq ll (mapcar 'vlax-safearray->list (list ll ur)))
		      (command "-_.view" "w" view (car ll) (cadr ll))
	       )
	     )
      )
    )
  )
  (foreach view	views
    (vla-add (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))) view)
    (command "-PLOT"
	     "y"
	     "Model"
	     "DWG To PDF.pc3"
	     "ARCH full bleed D (36.00 x 24.00 Inches)"
	     "Inches"
	     "Landscape"
	     "No"
	     "View"
	     view
	     (if (= "Cab" view)
	       "0.375=12"
	       "0.25=12"
	     )
	     "Center"
	     "Yes"
	     "MFC-Full_Size.stb"
	     "Yes"
	     "W"
	     ""
	     "Yes"
	     "No"
    )
  )
  (setvar 'filedia 1)
  (command "_.undo" "end")
  (princ)
)

 

Edited by ronjonp
Link to comment
Share on other sites

No, I just added those as an example to the typical layout.  The different views are typically in a similar configuration in each drawing, but always in a different location relative to the 0,0.

 

We are a production home builder.  Each drawing is a different plan with multiple elevations.  Floors are stacked, and visibility controlled using layers.

 

Titleblocks are xref'd (for now)

Edited by Three.One-Four
Link to comment
Share on other sites

3 minutes ago, Three.One-Four said:

The different views are typically in a similar configuration in each drawing, but always in a different location relative to the 0,0.

IMO, I'd standardize the location of the views. Simple enough task .. create a template to start with :)

Edited by ronjonp
Link to comment
Share on other sites

Yeah, unfortunately it ain't that easy here.  Not only are the views in different spots, dimstyles and text styles are not standardized.  So if I create a template, and we copy and paste plans into the template, it'll screw up dim and text objects that'll need to be readjusted.  It's a mess.

 

We are working towards standardizing via a template, but not until the new code cycle.  Legacy plans are an issue and will continue to be used.

 

Thanks anyway for the help.  You guys should be getting paid for this :)

Link to comment
Share on other sites

3 minutes ago, Three.One-Four said:

...

Thanks anyway for the help.  You guys should be getting paid for this :)

Glad to help 🍻

 

If I got paid a dollar for every line of code I've written, I'd own a small island by now. 😂

Link to comment
Share on other sites

I just saw the revised code above.  I tried it out.  It's still creating the named page setups in the paper space layouts instead of the model space.  The newly created page setups are not showing in the model space dialog, but when I switch to a PS tab, they're there.  But they don't have the correct parameters, pstyle table, plot area, paper, plotter, etc.  Is it me?

 

Start a patreon.  I'd donate.  But you probably couldn't link to it in these forums, unfortunately.

Link to comment
Share on other sites

It makes model views for me..

image.png.6e84c2dbcd43db02573c35739ffe65d2.png

 

Are you referring to the pagesetups?

(vla-add (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))) "Main")

 

Only having this line will not populate your settings.

Edited by ronjonp
Link to comment
Share on other sites

6 minutes ago, Three.One-Four said:

I'm getting the named views, but not the named page setups

You need to fill in the values for the named page setup properties:

image.png.cfb0d025e2cf385c4046736ad4608654.png

 

IMO it's easier to pull these pagesetups in from a template using PSETUPIN. If you define the views prior to importing then it should point to the correct window.

Edited by ronjonp
Link to comment
Share on other sites

2 hours ago, Three.One-Four said:

Understood.  And agreed.  This is a very old school company, with a very old school mentality.  And printing from model space use to be the standard in my field 20 years ago.  I'm working on getting them up to speed.

 

Problem with psetupin is that the plot areas are different in each drawing.  We'd have to redefine windows in each drawing, thus defeating the purpose of importing page setups.

 

So is this not possible?

Actually Paper Space was added to AutoCAD release 11 to make plotting easier in October of 1999 https://autodesk.blogs.com/between_the_lines/ACAD_R11.html

It's been the standard ever since. 

 

Funny how 95% of those who have trouble with one of the simplest tasks in AutoCAD are still using the 1998 standard for plotting.

Link to comment
Share on other sites

9 minutes ago, ronjonp said:

IMO it's easier to pull these pagesetups in from a template using PSETUPIN. If you define the views prior to importing then it should point to the correct window.

Ah!  Yes.  Got it.  Define the views per drawing with this routine, and psetupin the pagesetup referencing the named views.

 

Thanks!

Link to comment
Share on other sites

25 minutes ago, ronjonp said:

(vla-add (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object))) "Main")

 

Only having this line will not populate your settings.

Gotcha.  I thought this was taking the current plot settings and assigning them to the pagesetup.  Vlisp is foreign to me.  Thanks again for the help.

Link to comment
Share on other sites

It might if you call it after the plot command

1 minute ago, Three.One-Four said:

Gotcha.  I thought this was taking the current plot settings and assigning them to the pagesetup.  Vlisp is foreign to me.  Thanks again for the help.

image.thumb.png.e86831b138269032d10ee5db2150e5e5.png

Link to comment
Share on other sites

Just now, ronjonp said:

It might if you call it after the plot command

That's how I had it in the original code, but it didn't work.  But there could've been something else in there causing an issue.

 

Defining the views, then importing pagesetups is a cleaner approach anyway.  Hopefully that works.

Link to comment
Share on other sites

I think you have to do it that way ( import pagesetups ). The plot configuration when using vla-add defaults to paperspace and that property is readonly.

 

Here's some code to help out with the import:

(defun c:page (/ f)
  (vlax-for x (vla-get-plotconfigurations (vla-get-activedocument (vlax-get-acad-object)))
    (vla-delete x)
  )
  (cond	((findfile (setq f "Z:/Path/To/sht_manager_overrides.dwt"))
	 (setvar 'filedia 0)
	 (vl-cmdf ".-psetupin" f "*")
	 (setvar 'filedia 1)
	)
  )
  (princ)
)

 

 

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...