Jump to content

One Click Printing


BrianTFC
 Share

Recommended Posts

Hi All,

 

i was wondering if i could get some help with this routine. i'm trying to create a view by using a boundary. what i'm trying to do is make a one click print lisp by picking inside of a rectangle around my title block and creating a boundary thus the view to use for printing.

 

thanks,

Brian

 

 
;;;--- Printpage.lsp 
(defun C:prp()
 ;;;--- Turn the command echo off
 (setvar "cmdecho" 0)
 ;;;--- Get the inside selection point
 (setq pt(getpoint "\n Select Inside of Rectangle : "))
 ;;;--- Create a Boundary  (command "-boundary" "Advanced" "Island" "No" "Nearest" "" pt "")
 (command "view" "entlast" "pt" )
 (command "-view" "r" "pt" "plot" "yes" "model" "Laserjet 5.pc3" "ANSI A (8.50 x 11.00 INCHES)" "inches" "portrait" "no"
     "v" "pt" "fit" "0.00,0.25" "yes" "tfc.ctb" "yes" "no" "no" "yes"
     "yes")
 ;;;--- Turn the command echo back on
 (setvar "cmdecho" 1)
 ;;;--- Suppress the last echo for a clean exit
 (princ)
)

Link to comment
Share on other sites

What about "one select" print.

 

Untested

(defun c:test (/ ss mn mx)
     (vl-load-com)
     (if (setq ss  (ssget "_:S:E" '((0 . "INSERT,LWPOLYLINE"))))
         (progn
 [color=blue](vla-getboundingbox (vlax-ename->vla-object (ssname ss 0)) 'mn'mx)[/color]
   (command "plot" "yes" "model" "Laserjet 5.pc3" "ANSI A (8.50 x 11.00 INCHES)"
         "inches" "portrait" "no" [color=blue]"Window"[/color]
[color=blue]         (trans (vlax-safearray->list mn) 0 1)[/color]
[color=blue]         (trans (vlax-safearray->list mx) 0 1)[/color]
         "fit" "0.00,0.25" "yes" "tfc.ctb"  "yes" "no" "no" "yes" "yes")
               )
         )
     )

 

You can either select a rectangle or the TitbleBlock (Block Entity)

 

HTH

Edited by pBe
Link to comment
Share on other sites

That works great thank you for the help. By reading all of the routines I'm slowly but surely learning how to write simple ones...baby steps

Link to comment
Share on other sites

What do we need to do to keep the routine running for multiple pages. like select one rectangle print, another rectangle print, and so on.

Link to comment
Share on other sites

This will plot all title blocks in model space use the title block to work out where it is in model space

 

 (PROMPT ".....PRINTING DRAWING TO plotter....")
(setq oldsnap (getvar "osmode"))
(setvar "osmode" 0)

(setq ss2 (ssget "x" '((0 . "INSERT")(2 . "Yourtitelblockname")(410 . "Model"))))
(setq n (sslength ss2))
(setq index 0)
(repeat n
   (setq en (ssname ss2 index))
   (setq el (entget en))
   (setq inspt (assoc 10 el)) ; insertion pt
  (setq xmin (- (cadr inspt) 6.0))
  (setq ymin (- (caddr inspt) 6.0))
  (setq xymin (strcat (rtos xmin 2 1) "," (rtos ymin 2 1)))
  (setq xmax (+ xmin 813.0)) ; hard coded for 813 wide 6mm offset
  (setq ymax (+ ymin 566.0)) ;hard code for 566 high
  (setq xymax (strcat (rtos xmax 2 1) "," (rtos ymax 2 1)))

 (COMMAND "-PLOT"  "Y"     "" "Design-5100"
       "A3" "M"     "LANDSCAPE"   "N"
       "W"   xymin   xymax "1=2"  "C"
       "y"   "Designlaser.ctb"      "Y"   "" "n"   "n"
       "y" 
   )
  
 (setq index (+ index 1))
)
(setvar "osmode" oldsnap)
(princ)

Edited by BIGAL
Link to comment
Share on other sites

What do we need to do to keep the routine running for multiple pages. like select one rectangle print, another rectangle print, and so on.

 

It depends if you are using a rectange or a block for the "window" selection. we can modify the code to worked on either one or both and make it generic.

 

You may also have a look/see at Bigals sample code. you will notice that the block name and window size is hard coded. Need to chagne those to whatever you had on your drawing and plot settings.

 

(defun c:PlotM (/ ob ss bn mn mx)
     (vl-load-com)
           (if (and (progn
                (initget "B")
          (setq ob (entsel "\nSelect Block/B for blockname: "))
               (cond 
               ((eq ob "B")
                   (setq bn (getstring "\nEtner Block Name: "))
                   )
               ((and (eq (type ob) 'LIST)
              (vlax-method-applicable-p (vlax-ename->vla-object (car ob)) 'getboundingbox))
                     (setq bn (cdr (assoc 2 (entget (car ob))))))))
 (tblsearch "BLOCK" bn)
               bn     
               (setq ss  (ssget "_X" (list '(0 . "INSERT")'(410 . "Model")(cons 2 bn))))
                     )
                   
               
(progn 
         (vla-zoomextents (vlax-get-acad-object))
       (repeat (setq i (sslength ss))
  (vla-getboundingbox (vlax-ename->vla-object (ssname ss (setq i (1- i)))) 'mn'mx)
     (command "plot" "yes" "model" "Laserjet 5.pc3" "ANSI A (8.50 x 11.00 INCHES)"
           "inches" "portrait" "no" "Window"
          (trans (vlax-safearray->list mn) 0 1)
          (trans (vlax-safearray->list mx) 0 1)
           "fit" "0.00,0.25" "yes" "tfc.ctb"  "yes" "no" "no" "yes" "yes")
                )
         )
         (princ "\nNo Blocks Selected: ")
         )(princ)
     )

 

HTH

Edited by pBe
Add code
Link to comment
Share on other sites

Just my 2 cents...

I use for window selected plot area:

 

*^C^C-plot;Y;;;SHARP MX-2600N PCL6;;;;;W;\\;;;Fit;Center;Yes;monochrome.ctb;Yes;No;No;No;Yes;

 

work with button, only you need to setup print once (paper size) and change hardcoded printer name, select two point (window) and plot start and it is ready for next selection (*) till you press escape

Link to comment
Share on other sites

I like the first routine that you wrote pBe becuase it uses rectanlge, i just want to be able to pick and print more than one sheet while stiil in the routine and right click to finish when i've printed all of my sheets.

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

 Share

×
×
  • Create New...