Jump to content
ILoveMadoka

Load Page Setup Question..

Recommended Posts

ILoveMadoka

I've been reading through this detailed thread

 

http://www.cadtutor.net/forum/showpost.php?p=271362&postcount=8

 

Well...

I grabbed one of the snippets of code from the thread referenced above.

It works perfectly.

I deleted this..

 ;; (vl-cmdf "_.pasteclip" "0,0")

Since Lee Mac didn't know why it was in there in the first place.

It does a very bad thing if anything is on your clipboard!! :-\

 

My question is how do I assign the "model space" setup to model space?

It is called "11x17 Model Space"

 

I'm one step away... :-|

 

 

(defun c:PJM (/ *error* AT:PageSetups SetPSAllLayouts vl ov)
 (vl-load-com)
 
 (defun *error* (msg)
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))
 
 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *doc*  (cond (*doc)   ((vla-get-ActiveDocument *acad*))))
  
 ;;; Insert all Page Setups into drawing (will overwrite if exists)
 ;;; #DrawingFile - name of DWG file from which to import
 ;;; Alan J. Thompson, 07.29.09
 (defun AT:PageSetups (#layout1)
   (if (findfile #layout1)
     (progn
       (command "_.psetupin" (findfile #layout1) "*")
       (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
         (command "_yes")) T)))
 
 (defun SetPSAllLayouts (setup / doc)
   
   (if (not (vl-catch-all-error-p
              (setq setup
                     (vl-catch-all-apply (function vla-item)
                       (list (vla-get-PlotConfigurations
                               (setq doc
                                      (vla-get-ActiveDocument
                                        (vlax-get-acad-object)))) setup)))))
     (vlax-map-collection
       (vla-get-layouts doc)
       (function
         (lambda (x)
           (if (eq :vlax-false (vla-get-Modeltype x))
             (vla-CopyFrom x setup)))))))
 
 (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
 (mapcar 'setvar vl '(0 0))
 
 ;; ------------ Start Here -----------------------------
 

 (AT:PageSetups "H:\\Publish Setups.dwg") ;; Change this if necessary
 
 (repeat 3 (vla-purgeall *doc*))
 
 (setPSAllLayouts "RP BORDER")
 
 (vla-ZoomExtents *acad*)
 
 (if (eq "" (vla-get-FullName *doc*))
   (vla-saveas *doc*
     (strcat
       (vla-get-Path *doc*) "\\"
         (vla-get-name *doc*)))
   
   (vla-save *doc*))
 
 ;; ------------ End Here -----------------------------
 
 (mapcar 'setvar vl ov)
 (princ))

PLEASE HELP!!

Edited by ILoveMadoka
rev

Share this post


Link to post
Share on other sites
ILoveMadoka

Any chance of someone helping?

 

:-\

Edited by ILoveMadoka

Share this post


Link to post
Share on other sites
cwake

If I understand you correctly, you want to manage page setups for both paper space and model space?

 

The line

(if (eq :vlax-false (vla-get-Modeltype x))

is testing whether it is dealing with a modelspace or paperspace layout. Currently it only changes the page setup if it is a paperspace layout.

 

Try replacing the SetPSAllLayouts function with this one

  (defun SetPSAllLayouts ( setups / setupobjs )
   (setq setupobjs (mapcar
                     (function
                       (lambda ( x / setup)
                         (if (not (vl-catch-all-error-p
                                    (setq setup
                                           (vl-catch-all-apply 'vla-item
                                             (list (vla-get-plotconfigurations *doc*) x))
                                          )
                                    )
                                  )
                           setup
                           )
                         )
                       )
                     setups
                     )
         )
   (vlax-map-collection
     (vla-get-layouts *doc*)
     (function
       (lambda (x)
         (cond
           ((and (eq :vlax-false (vla-get-modeltype x)) (car setupobjs))
            (vla-copyfrom x (car setupobjs))
            )
           ((and (eq :vlax-true (vla-get-modeltype x)) (cadr setupobjs))
            (vla-copyfrom x (cadr setupobjs))
            )
           )
         )
       )
     )
   )

 

And the line in the main function

(setPSAllLayouts "RP BORDER")

with

(setPSAllLayouts '("RP BORDER" "11x17 Model Space"))

 

and keeping everything else the same. The first page setup name (if present in the drawing) will be applied to paper space and the second to model space.

Edited by cwake

Share this post


Link to post
Share on other sites
ILoveMadoka

I often encounter drawings that for some reason have BOTH paperspace and modelspace. :-\

They should only use paperspace but sometimes there is just not time to correct the problem.

For those drawings, I have both spaces that I need to publish/print/plot.

 

Is it possible to have the modelspace assigned one setup (11x17 Model Space)

and all the layouts assigned the paperspace layout (11x17 Paper Space)?

 

The RP BORDER is a carryover from the original thread... (sorry)

 

I was trying to create a routine that automated the import (which is working)

If I can assign everything in the same routine it would be a great timesaver.

If I don't use the modelspace in a particular drawing, no issue but if I do, it's nice to have it already done...

 

I just couldn't figure out how to add the (11x17 Model Space) to the code I posted.

That alone will solve my issue...

 

Thanks!

Share this post


Link to post
Share on other sites
cwake

In which case I think what I posted should help you. To simplify things, I'll post the whole function and highlight the things you need to change to get it to work.

 

(defun c:PJM ( / *error* *acad* *doc* AT:PageSetups SetPSAllLayouts vl ov )
 (vl-load-com)

 (defun *error* (msg)
   (and ov (mapcar 'setvar vl ov))
   (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
       (princ (strcat "\n** Error: " msg " **")))
   (princ))

 (setq *acad* (cond (*acad*) ((vlax-get-acad-object)))
       *doc*  (cond (*doc)   ((vla-get-activedocument *acad*))))

 ;;; Insert all Page Setups into drawing (will overwrite if exists)
 ;;; #DrawingFile - name of DWG file from which to import
 ;;; Alan J. Thompson, 07.29.09
 (defun AT:PageSetups ( #layout1 )
   (if (findfile #layout1)
     (progn
       (command "_.psetupin" (findfile #layout1) "*")
       (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
         (command "_yes")) T)))

 (defun SetPSAllLayouts ( setups / setupobjs )
   (setq setupobjs (mapcar
                     (function
                       (lambda ( x / setup )
                         (if (not (vl-catch-all-error-p
                                    (setq setup
                                           (vl-catch-all-apply 'vla-item
                                             (list (vla-get-plotconfigurations *doc*) x))
                                          )
                                    )
                                  )
                           setup
                           )
                         )
                       )
                     setups
                     )
         )
   (vlax-map-collection
     (vla-get-layouts *doc*)
     (function
       (lambda (x)
         (cond
           ((and (eq :vlax-false (vla-get-modeltype x)) (car setupobjs))
            (vla-copyfrom x (car setupobjs))
            )
           ((and (eq :vlax-true (vla-get-modeltype x)) (cadr setupobjs))
            (vla-copyfrom x (cadr setupobjs))
            )
           )
         )
       )
     )
   )

 (setq vl '("CMDECHO" "OSMODE") ov (mapcar 'getvar vl))
 (mapcar 'setvar vl '(0 0))

 ;; ------------ Start Here -----------------------------


 (AT:PageSetups [color=red][b]"H:\\Publish Setups.dwg"[/b][/color]) ;; Change this if necessary
 (repeat 3 (vla-purgeall *doc*))

 (setPSAllLayouts '([b][color=lime]"11x17 Paper Space"[/color] [color=blue]"11x17 Model Space"[/color][/b]))

 (vla-zoomextents *acad*)

 (if (eq "" (vla-get-fullname *doc*))
   (vla-saveas *doc*
     (strcat
       (vla-get-Path *doc*) "\\"
       (vla-get-name *doc*)))
   (vla-save *doc*)
   )

 ;; ------------ End Here -----------------------------

 (mapcar 'setvar vl ov)
 (princ)
 )

 

So the text highlighted red is the drawing (or template) file where the page setups are stored. Green is the name of the page setup you want applied to paperspace, and blue the name of the page setup you want applied to modelspace. If the page setup given doesn't exist in the drawing then nothing will get applied. So theoretically if you only wanted to make changes to paperspace you could put

(setPSAllLayouts '([b][color=lime]"11x17 Paper Space"[/color] [color=blue]""[/color][/b]))

Hope that helps.

Share this post


Link to post
Share on other sites
ILoveMadoka

Perfection!

 

Thanks so very much!

 

 

What anime is your avi from?

I don't recognize the character...

Share this post


Link to post
Share on other sites
cwake

Nice. Good to hear.

What anime is your avi from?

I'm not sure actually. I've been encouraged to be more active on the forums, so when I made my first post a couple of weeks ago, I figured I should pick an avatar. So I went through what was available on this site, and I chose one that is called "Ghibli 06". The only reason for the choice was that it was one of the more "humanoid" avatars to choose from.

 

Since one of my female colleagues politely pointed out that the avatar is the complete opposite of what I look like I'm now feeling obliged to change it. But I'm averse to choosing Bart Simpson or a Futurama character. :lol: So we'll see. LOL

Share this post


Link to post
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.   Paste as plain text instead

  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...