Jump to content

Plot: Set number of copies from dialog


woodman78

Recommended Posts

Hi all,

I found a piece of code for setting the number of plots in a plot routine. I have tried to incorporate it into a function I have for plotting all the layouts but it doesn't set the number of copies. Am I going down the wrong track altogether?

 

AP3
: dialog
{
label = "Plot All A3";
: edit_box
{
label = "Enter Number of Plots :";
mnemonic = "N";
key = "noc";
alignment = centered;
edit_limit = 3;
edit_width = 3;
value = "";
}
: button	
{
key = "accept";
label = "OK";
is_default = true;
fixed_width = true;
alignment = centered;
}
: errtile
{
width = 34;
}
}

 

 

 

(defun C:AP3 (/ CURRENTTAB noc dcl_id)
[color="red"][color="red"](setq dcl_id (load_dialog "AP3.dcl"))
    (if (not (new_dialog "AP3" dcl_id))
 (exit)
    );if

(set_tile "noc" "1")
(mode_tile "noc" 2)
(action_tile "noc" "(setq noc (atof $value))")


(start_dialog)
(unload_dialog dcl_id)
[/color][/color]
(setq CURRENTTAB (getvar "ctab"))
(PlotReactorOFF)
(command "_.-layer" "_LW" "0.13" "CCC_LAYOUT_Dimensions" "")
 (if (findfile "T:/Drawing Tools/Templates/CCC2009.dwt")
   (progn
     (command "_.psetupin" (findfile "T:/Drawing Tools/Templates/CCC2009.dwt") "A3")
     (while (wcmatch (getvar "cmdnames") "*PSETUPIN*")
       (command "_yes")
     ) ;_ while
     T
   ) ;_ progn
 ) ;_ if

(command "_-purge" "a" "*" "N")
(setq CCC_Sheet "A3")
(foreach LAYOUT (layoutlist)
(setvar "ctab" LAYOUT)
;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "-plot" "n" "" "A3" "" "n" "y" "n")
(command "_zoom" "e")
(command "updatefield" "all" "")
(command "regenall")
(vlax-put-property (vla-get-Plot (vla-get-ActiveDocument
(vlax-get-acad-object))) "NumberOfCopies" noc)
(command "-plot" "n" "" "A3" "" "n" "y" "y")
;;;;;;;;;;;;;;;;;;;;;;;;;;

(setvar "ctab" CURRENTTAB)
(PlotReactorON)
(princ)
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun PlotReactorON nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (not (vlr-added-p react))
          (vlr-add react)
        )
        (setq react
          (vlr-command-reactor data
            (list
              (cons :vlr-commandwillstart foo)
            )
          )
        )
      )
      (if (vlr-added-p react)
        (princ "\n** Reactor Activated **")
        (princ "\n** Reactor Failed to Activate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )

 (princ)
)

(defun PlotReactorOFF nil
 (vl-load-com)
 ;; © Lee Mac 2010

 (  (lambda ( data foo / react )
      (if (setq react
            (vl-some
              (function
                (lambda ( reactor )
                  (if (eq data (vlr-data reactor)) reactor)
                )
              )
              (cdar
                (vlr-reactors :vlr-command-reactor)
              )
            )
          )
        (if (vlr-added-p react)
          (vlr-remove react)
        )
      )
      (if (or (not react) (not (vlr-added-p react)))
        (princ "\n** Reactor Deactivated **")
        (princ "\n** Reactor Failed to Deactivate **")
      )
      react
    )
   "Plot-Reactor"
   'Plot-Callback
 )
 
 (princ)
)

(defun Plot-Callback ( reactor arguments )
 (vl-load-com)

 (if (eq (strcase (car arguments)) "PLOT")
   (LM:Popup "Warning" 64 "Gotcha!!!   Please use the NNRDO Plot tools when plotting standard layouts!!")
 )

 (princ)
)

(defun LM:Popup ( title flags msg / WSHShell result )
 ;; © Lee Mac 2010
 (setq WSHShell (vlax-create-object "WScript.Shell"))
 (setq result   (vlax-invoke WSHShell 'Popup msg 0 title flags))
 (vlax-release-object WSHShell)
 
 result
)

Link to comment
Share on other sites

Not sure why the plot part of the code is twice 1st is for a single copy second 2nd is do it again but with noc not sure why these two options are not in a IF do 1 or more.

 

Woodman go back to your other post add the bit of code for the dialouge at start and add the NOC code at start also I think this code is over complicating what you want to do.

 

this may be usefull also you can use it for any program rather than hard coding a DCL

 

to use (load "getval")(load "your plot")
;code for getval 
(setq title "Please enter dwg number")
(setq width "   edit_width = 12;")
(setq limit "     edit_limit = 9;")
(ah:getval title width limit)
(setq dwgname item)


;; Input  Dialog box with variable title
;; By Ah June 2012
;; code (ah:getval title)
(defun AH:Getval (title width limit / fo)
(setq fname "C://acadtemp//getval.dcl")
(setq fo (open fname "w"))
(write-line "ddgetval : dialog {" fo)
(write-line " : row {" fo)
(write-line ": edit_box {" fo)
(write-line (strcat "    key = "  (chr 34) "sizze" (chr 34) ";") fo)
(write-line  (strcat " label = "  (chr 34) title (chr 34) ";"  )   fo)
; these can be replaced with shorter value etc
;(write-line "     edit_width = 18;" fo) 
;(write-line "     edit_limit = 15;" fo)
(write-line width fo) 
(write-line limit fo)
(write-line "   is_enabled = true;" fo)        
(write-line "    }" fo)
(write-line "  }" fo)
(write-line "ok_cancel;}" fo)
(close fo)
(setq dcl_id (load_dialog  "c:\\acadtemp\\getval"))
(if (not (new_dialog "ddgetval" dcl_id))
(exit))
(action_tile "sizze" "(setq item  $value)(done_dialog)")
(mode_tile "sizze" 3)
(start_dialog)
; returns the value of item
)

Link to comment
Share on other sites

BIGAL,

I run the plot command twice because the first time it sets the page setup and I need to set that first so that I can update all the fields as my title block contains a field for the sheet size. The second running of the command does the actual plotting when everything is set.

Link to comment
Share on other sites

Why use a dialog box and not the command line? here's a routine that will ask you "How Many Copies" at the command line.

Give this a try.

;;; LAYOUT PRINT 18x24
(defun c:Tab ( / CURRENTTAB)
(pltnum)
 (setq CURRENTTAB (getvar "ctab"))
 (repeat xplta (foreach LAYOUT (layoutlist)
   (setvar "ctab" LAYOUT)
   (command "-plot" 
"yes" 
""
"TFC-ENGXER6204.pc3" 
"Arch C (18x24 in.)" 
"Inches"
"LANDSCAPE" 
"NO" ;PLOT UPSIDE DOWN
"EXTENTS" 
"FIT" 
"0.076012,0.00" 
"YES" ;PLOT WITH PLOTSYTLES
"MONOCHROME.CTB" 
"NO" ;PLOT WITH LINEWEIGHTS
"NO" ;SCALE LINEWEIGHTS WITH PLOT SCALE
"YES" ;PLOT PAPER SPACE LAST
"NO" ;REMOVE HIDDEN LINES
"NO" ;WRITE THE PLOT TO A FILE
"NO" ;SAVE CHANGES TO LAYOUT
"YES");PROCEED WITH PLOT
 )
)
(defun pltnum ()
(setq numplt (getint "\nEnter Number of Plots <1>: "))
(if (= numplt nil) (setq xplt 1) (setq xplt numplt))
(if (<= xplt 15) (setq xplta xplt) (setq xplta 15))
) 
(setvar "ctab" CURRENTTAB)
 (princ)
)

Link to comment
Share on other sites

I think using the vl-put for NOC would be better than repeat because your actually running the plot command by the number of plots

10 tabs

NOC =4 plot =10 times

repeat 4 plot = 40 times

 

The advantage is wether you want sets to be printed v's just produce the sheets and I will sort. A end user question.

 

For small numbers I would just run my do 1 set multiple times.

Link to comment
Share on other sites

2 things always load your defuns 1st, code at end, lisp steps through code top to bottom so if you call a defun that has not been loaded as it steps through it will error even if it exists somewhere in your code (Plotreactor off)

 

foreach LAYOUT (layoutlist) where is layoutlist code this is a defun

 

Also debugging use VLide have "break on error" on you can do stuff like "inspect" variables when it stops Lee-mac has a good tutorial about this.

 

Simple debugging put (princ "wow1") in code (princ "wow2") further down helps sometimes.

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