Jump to content
hosannabizarre

Plot current layout without entering name is lisp plot string

Recommended Posts

hosannabizarre

I want to plot one particular layout in a drawing with multiple layouts.

 

I want to set up a string of commands, using lisp, to print out the current/ open layout.

 

Here is the current string I'm using:

 

 
(defun c:plot40_B1 nil
(vl-load-com)
(command "_.-plot" "yes" "" "\\\\Kwifs1\\KWIN_40" "B1" "Millimeters" "LANDSCAPE" "NO" "Extents" "FIT" "CENTER" "YES" "KWIN39_BW.ctb" "YES" "W" "NO" "NO" "yes" )
(princ)
)

 

 

This does not work - here is the F2 echo of the commands as they are processed by AutoCAD:

 

plot40_KWIN39_BW _.-plot Detailed plot configuration? [Yes/No] <No>: 
yes
Enter a layout name or [?] <K-17831>: Enter an output device name or [?] 
[url="file://kwifs1/KWIN_40"]\\KWIFS1\KWIN_40[/url]>: [url="file://kwifs1/KWIN_40"]\\Kwifs1\KWIN_40[/url] Enter paper size or [?] <A3>: A3 Enter 
paper units [inches/Millimeters] <Millimeters>: Millimeters Enter drawing 
orientation [Portrait/Landscape] <Landscape>: LANDSCAPE Plot upside down? 
[Yes/No] <No>: NO Enter plot area [Display/Extents/Layout/View/Window] 
<Extents>: Extents Enter plot scale (Plotted Millimeters=Drawing Units) or 
[Fit] <Fit>: FIT Enter plot offset (x,y) or [Center] <Center>: CENTER Plot with 
plot styles? [Yes/No] <Yes>: YES Enter plot style table name or [?] (enter . 
for none) <KWIN39_BW.ctb>: KWIN39_BW.ctb Plot with lineweights? [Yes/No] <Yes>: 
YES Scale lineweights with plot scale? [Yes/No] <Yes>: W

 

 

The problem is this question: Enter a layout name or [?] :

 

Currently the bit of the lisp that goes against that question is "".

 

I have tried "Current" and "Layout", as I just want it to print the layout I have open, without entering a particular layout name, as this is obviously a print routine I want to use over and over again.

 

Not sure what the > part of "Enter a layout name or [?] :" is.

 

I am not sure what a valid answer is to "print current layout".

 

I tried to turn off dialog boxes so I could find out what my options are at the command prompt, but can't figure this out. The old CmdDia = 0 doesn't work.

 

Would greatly appreciate some advice!!!

Share this post


Link to post
Share on other sites
Lt Dan's legs

Whatever space you're in will automatically be selected so you can just use "".

 

If you were in model space it should show "Enter a layout name or [?] :"

 

If you type in ? it will produce a list of the selections available.

 

No need for (vl-load-com)

This is only needed if you are using Visual LISP

 

If you're trying to print and not plot to file you missed a question

(defun c:plot40_B1 nil
[color=#ff0000](setvar "cmdecho" 0)[/color]
(command "_.-plot" "yes" "" "\\\\Kwifs1\\KWIN_40" "B1" "Millimeters" "LANDSCAPE" "NO" "Extents" "FIT" "CENTER" "YES" "KWIN39_BW.ctb" "YES" "W" "NO" "NO" "NO" "yes" )
[color=#ff0000](setvar "cmdecho" 1)[/color]
(princ)
)

Share this post


Link to post
Share on other sites
ahmed_proff
Whatever space you're in will automatically be selected so you can just use "".

 

If you were in model space it should show "Enter a layout name or [?] :"

 

If you type in ? it will produce a list of the selections available.

 

No need for (vl-load-com)

This is only needed if you are using Visual LISP

 

If you're trying to print and not plot to file you missed a question

(defun c:plot40_B1 nil
[color=#ff0000](setvar "cmdecho" 0)[/color]
(command "_.-plot" "yes" "" "\\\\Kwifs1\\KWIN_40" "B1" "Millimeters" "LANDSCAPE" "NO" "Extents" "FIT" "CENTER" "YES" "KWIN39_BW.ctb" "YES" "W" "NO" "NO" "NO" "yes" )
[color=#ff0000](setvar "cmdecho" 1)[/color]
(princ)
)

 

;lisp for plot 
;you can change your device and paper size
;Created by Ahmed Abdel Ghany "[email="Ahmed_proff@yahoo.com"]Ahmed_proff@yahoo.com[/email]"
;With my best regards
(defun
ERR (X)
(if (= "Function Cancelled" X)
(setq X "Ctrl+C or Esc key pressed.")
) ;_ end of if
(setq *ERROR* OLDERR)
(princ (strcat "\nError: " X))
(princ)
) ;_ end of defun
;;ERR
;;;********** Main Program **********
(defun c:B1 ()
(setq oecho (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setvar "filedia" 0)
(vl-load-com)
(command "zoom" "e")
(initget "YES NO")
(setq pl (getkword "\nDo you want to plot? (Y)es/(N)o <Y>:"))
(if (= nil pl)(setq pl "Y")) 
(cond
((= pl "Y")
;;;;Paper space;
(if (/= (getvar "tilemode") 1)
(progn
(command
"-PLOT"
"y" ;Detailed plot configuration? [Yes/No] <No>:; 
"" ;Enter a layout name or [?] <Layout1>:
"\\\\Kwifs1\\KWIN_40" ;Enter an output device name or [?] <None>: 
"B1" ;Enter paper size or [?] <A3>:
"m" ;Enter paper units [inches/Millimeters] <Inches>: m
"l" ;Enter drawing orientation [Portrait/Landscape] <Landscape>:
"no" ;Plot upside down? [Yes/No] <No>:
"e" ;Enter plot area [Display/Extents/Limits/View/Window] <Layout>: e
"f" ;Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: f
"0,0" ;Enter plot offset (x,y) or [Center] <0.00,0.00>:
"yes" ;Plot with plot styles? [Yes/No] <Yes>:
"KWIN39_BW.ctb" ;Enter plot style table name or [?] (enter . for none) <>: 
"yes" ;Plot with lineweights? [Yes/No] <Yes>:
"" ;Scale lineweights with plot scale? [Yes/No] <No>:
"" ;Plot paper space first? [Yes/No] <No>:
"" ;Hide paperspace objects? [Yes/No] <No>:
"" ;Write the plot to a file [Yes/No] <N>:
"" ;Save changes to page setup [Yes/No]? <N>
"y" ;Proceed with plot [Yes/No] <Y>:
);command
(prompt "\nSuccessfully Plot.....")
(princ)
);progn
;model space
(progn
(command
"-plot"
"y" ;Detailed plot configuration? [Yes/No] <No>:; 
"" ;Enter a layout name or [?] <Model>:
"\\\\Kwifs1\\KWIN_40" ;Enter an output device name or [?] <None>: 
"B1" ;Enter paper size or [?] <A3>:
"m" ;Enter paper units [inches/Millimeters] <Inches>: m
"l" ;Enter drawing orientation [Portrait/Landscape] <Landscape>:
"no" ;Plot upside down? [Yes/No] <No>:
"e" ;Enter plot area [Display/Extents/Limits/View/Window] <Layout>: e
"f" ;Enter plot scale (Plotted Millimeters=Drawing Units) or [Fit] <1:1>: f
"0,0" ;Enter plot offset (x,y) or [Center] <0.00,0.00>:
"yes" ;Plot with plot styles? [Yes/No] <Yes>:
"KWIN39_BW.ctb" ;Enter plot style table name or [?] (enter . for none) <>:
"" ;Plot with lineweights? [Yes/No] <Yes>:
"" ;Enter shade plot setting [As displayed/Wireframe/Hidden/Visual styles/Rendered] <As displayed>:
"" ;Write the plot to a file [Yes/No] <N>:
"" ;Save changes to page setup [Yes/No]? <N>
"y" ;Proceed with plot [Yes/No] <Y>:
);command
(prompt "\nSuccessfully Plot.....")
(princ)
);progn
);if
);Yes
((= pl "N")(prompt "\nYou canceled plotting"));No
);cond
(terpri)
(setvar "filedia" 1)
(setvar "cmdecho" oecho)
);DEFUN
;;;;***********End of program*************

Edited by Tiger
added codetags

Share this post


Link to post
Share on other sites
BIGAL

if you want to plot another tab v's the one your in check setvar "Ctab" this will jump tabs for you.

 

Eg in layout3 (setq newtab "layout1") (setq oldtab (getvar "ctab")(setvar "ctab" newtab) plot then (setvar "ctab" oldtab) jumps back to layout3

Share this post


Link to post
Share on other sites
Ohnoto

Ultimately, the issue appears to be in the code that it you put a value of "W" for where it wants "Yes / No".

 

Here is an option for trying to do what you want to also in that you could use a DCL code to generate a list of the page tabs and let you select what you want from those. Here is what I use is:

 

(defun EXPLO_db1_Main (/ myListLength myLayoutList)
   (setq myListLength (length (setq myLayoutList (layoutlist))))
   
   (defun EXPLO_db1_CreateDialog (/ nu l fn nuMax nuMin) ;create a temp DCL file        
           
       (setq filename (vl-filename-mktemp "dcl.dcl"))
       (setq fn (open filename "w"))
       (setq nu 0)    ;reset counter
           
       ;write the dialog header coding
       (write-line "temp : dialog { label = \"Express Plotting\";" fn)

       (write-line ": list_box {" fn)
       (write-line     "label =\"Select Layouts\";" fn)
       (write-line     "key = \"mylist\";" fn)
       (write-line     "height = 50;" fn)
;;;        (write-line     "width = 50;" fn)
       (write-line     "multiple_select = true;" fn)
;;;        (write-line     "fixed_width_font = false;" fn)
       (write-line     "value = \"0\";" fn)
       (write-line     "}" fn)
       
       (write-line ":column{" fn)
           (write-line ":row {"  fn)
               (write-line     ":button{" fn)
                   (write-line     "label = \"Select All\";" fn)
                   (write-line     "width = 30;" fn)
                   (write-line     "key = \"selall\";" fn)
                   (write-line     "}" fn)
               (write-line     ":button{" fn)
                   (write-line     "label = \"Select None\";" fn)
                   (write-line     "width = 30;" fn)
                   (write-line     "key = \"selnone\";" fn)
                   (write-line     "}" fn)
           (write-line "}" fn);row
       (write-line "}" fn);column
       
       ;ok and cancel button
       (write-line "ok_cancel; }" fn) ;close the temp DCL file
       (close fn)
       );defun EXPLO_CreateDialog    

   (defun EXPLO_db1_SaveVars (/ readlist count item)
     ;;;--- Setup a list to hold the selected items
;;;      (setq retList(list))
     ;;;--- Save the list setting
     (setq readlist (get_tile "mylist"))
     ;;;--- Setup a variable to run through the list
     (setq count 1)
     ;;;--- cycle through the list getting all of the selected items
     (while (setq item (read readlist))
;;;        (setq retlist (append retList (list (nth item myLayoutList))))
           (setq myPLOLayoutList (cons (nth item myLayoutList) myPLOLayoutList))
       (while
         (and
           (/= " " (substr readlist count 1))
           (/= ""   (substr readlist count 1))
         )
               (setq count (1+ count))
               )
           (setq readlist (substr readlist count))
           )
       );defun EXPLO_db1_SaveVars


   (defun EXPLO_db1_Selall (Key Count / StartCount Value Count)
       (setq StartCount 0)
       (setq Value "0")
       (repeat (1- Count)
           (setq Value (strcat Value (itoa (setq StartCount (1+ StartCount))) " "))
           )
       (set_tile Key Value)
       )
   
   (defun EXPLO_db1_Selnone (/ )
       (set_tile "mylist" "")
       (setq myPLOLayoutList nil)
       )

   (defun EXPLO_db1_RunDialog (/ dcl_id )
       ;load the dialog file and definition
       (setq dcl_id (load_dialog filename))
       (if (not (new_dialog "temp" dcl_id))
           (exit ) );if
       (mode_tile "eb0" 2)
       ;;;--- Here, I add the data to the list_box control
     ;;;    I do this after the new_dialog call and before the action_tiles.
     (start_list "mylist" 3)
     (mapcar 'add_list myLayoutList)
     (end_list)
       
       ;if the OK button is selected
       (action_tile "accept" "(EXPLO_db1_SaveVars) (done_dialog)")
       (action_tile "selall" "(EXPLO_db1_Selall \"mylist\" (length myLayoutList))")
       (action_tile "selnone" "(EXPLO_db1_Selnone)")
       ;start the dialog
       (start_dialog)
       ;unload the dialog
       (unload_dialog dcl_id)
       ;delete the temp DCL file
       (vl-file-delete filename)
       );defun EXPLO_db1_RunDialog

   
   (EXPLO_db1_CreateDialog)
   (EXPLO_db1_RunDialog)
   (princ)
   );defun EXPLO_Dialog1Main

and then for the function:

 

(setq PLOVerNum "0012")

(defun c:plot40 (/ myPLOLayoutList mylayout)
     (EXPLO_db1_Main)
     (setvar "cmdecho" 0)
     (setq imagef (getvar "imageframe"))
     (setvar "imageframe" 2)
     (command "wipeout" "frames" "off")
   (setq mylayout (length myPLOLayoutList))
     (if myPLOLayoutList                        
       (progn                            
       (setq                            ; Begin setq for myLayout
           myLayout (getvar "CTAB"))            ; End setq for myLayout
       (foreach myLayout (reverse myPLOLayoutList)
         (command "-plot"                    ; Command: -plot
           "Y"                         ; Detailed plot configuration? [Yes/No]
           mylayout                    ; Layout Name
           "\\\\Kwifs1\\KWIN_40"                ; Output Device Name
           "B1"                        ; Paper Size
           "Millimeters"                    ; Paper Units
           "Landscape"                    ; Drawing Orientation [Portrait/Landscape]
           "No"                        ; Plot Upside Down? [Yes/No]
           "Extents"                    ; Plot Area [Display/Extents/Limits/View/Window]
           "FIT"                        ; Plot Scale (Plotted Inches=Drawing Units) or [Fit]
           "Center"                    ; Plot Offset (x,y) or [Center] <Center>
           "Yes"                        ; Plot Styles? [Yes/No]
           "[font=monospace]KWIN39_BW[/font].ctb"                ; Plot Style Table Name or [?] (enter . for none)
           "Yes"                        ; Plot Lineweights [Yes/No]
           "No"                        ; Scale Lineweights [Yes/No]
           "No"                        ; Plot Paper Space First? [Yes/No]
           "No"                        ; Hide Paperspace Objects? [Yes/No]
           "No"                        ; Plot to a File [Yes/No]
           "No"                        ; Save Changes to Page Setup [Yes/No]
           "Yes")                        ; Proceed With Plot [Yes/No]
        )))
   (setvar "imageframe" imagef)
     (setvar "cmdecho" 1)
       (princ "\n ---------------------------------------------")
      (princ (strcat "\n ------ Express Plotting - Version " PLOVerNum " ------"))
     (princ "\n ---------------------------------------------")
     (princ)

Then you copy the function code and modify the Plot Style Table and Output Device for other printers or plot styles.

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