Jump to content

For each layout, do something (plot)


Glen Smith

Recommended Posts

I'm trying to modify some code I found here: http://www.cadtutor.net/forum/showthread.php?62876-Can-you-change-multiple-sheet-plot-settings-at-the-same-time&highlight=plot+multiple+layouts

 

to my purposes, which is to plot all the layouts in the current drawing to my named printer. Without the setvar line, I get the right number of copies, but they are all of the same layout (whichever one I execute the lisp from). Adding the setvar line errors out the lisp.

 

(The actual plot command was commented out so I don't keep wasting paper while debugging this code.)

 

(defun c:qplotall (); Konica Bsize mostly mono all layouts.
   (vlax-for x
       (vla-get-Layouts
           (vla-get-ActiveDocument
               (vlax-get-acad-object)
           )
       )
       (command "setvar" "ctab" x)
;        (command "-plot" "y" "" "KONICA monochrome" "11x17" "Inches" "landscape" "no" "Extents" "Fit" "Center" "y" "MOSTLY MONO LIGHT" "y" "y" "No" "No" "No" "No" "y")
   )
)

Can anyone shed some light for me?

Thanks,

Glen

Link to comment
Share on other sites

I just started working on a similar task to print to PDF files. Have you setup a watch window to see what value 'x' is actually being set to as it iterates through the loop.

Link to comment
Share on other sites

There is the LAYOUTLIST function that return a list with the names of available layouts:

(setq layoutOld (getvar "CTAB"))
(foreach layoutCrt (layoutlist)
(setvar "CTAB" layoutCrt)
;your action here
)
(setvar "CTAB" layoutOld)

  • Like 1
Link to comment
Share on other sites

To fix your original code - you need to retrieve the name of the layout from the VLA object; check the VLA-GET-NAME for this. Don't miss the fact that VLA-GET-LAYOUTS function return a list that contains the Model tab, too; you may want to filter it out .

(vlax-for x
        (vla-get-Layouts
         (vla-get-ActiveDocument
          (vlax-get-acad-object)
         )
        )
[b] [color=red](setq x (vla-get-name x))[/color][/b]
[color=red](if (/= x "Model")
 (progn[/color]
  (command "setvar" "ctab" x)
  ;(command "-plot" "y" "" "KONICA monochrome" "11x17" "Inches" "landscape" "no" "Extents" "Fit" "Center" "y" "MOSTLY MONO LIGHT" "y" "y" "No" "No" "No" "No" "y")
 [color=red])
)[/color]
)

Link to comment
Share on other sites

And... that satisfies my needs! Many thanks Mircea.

 

I did have a watch set on x, I could see that it was not a clear text of the layout name, but I had no idea how to get from #

 

So many things to do, actually learning LISP always seems to take a back seat to getting THIS project done.

 

Glen

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