Jump to content

Recommended Posts

Posted

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

Posted (edited)

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
Posted

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

Posted

Good for you BrianTFC

 

Glad i could help :)

Holler if you need more assistance

 

Cheers

Posted

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.

Posted (edited)

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
Posted (edited)
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
Posted

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

Posted

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.

  • 11 years later...
Posted (edited)
On 2/25/2012 at 7:03 AM, pBe said:

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

I have tried to use the plot code and I've received the following message, how I can treat that::

 

Command: test
Select objects:
plot
error: AutoCAD variable setting rejected: "xclipframe" 0AutoCAD command rejected: "ERASE"Detailed plot configuration? [Yes/No] <No>: yes
Enter a layout name or [?] <Model>: model Enter an output device name or [?] <DWG To PDF.pc3>: DWG To PDF.pc3 Enter paper size or [?] <ANSI A (8.50 x 11.00 Inches)>: ANSI A (8.50 x 11.00 INCHES) Enter paper units [Inches/Millimeters] <Millimeters>: inches Enter drawing orientation [Portrait/Landscape] <Landscape>: portrait Plot upside down? [Yes/No] <No>: no Enter plot area [Display/Extents/Limits/View/Window] <Window>:
Command: Window Unknown command "WINDOW".  Press F1 for help.
Command:
Command:
Command:

 

 

thanks in advance for any helping

 

 

 

Edited by hosyn
Posted

Looking at this, the plot command gets to this line: (Sunday, CAD is off so no checking done, just a guess)

 

(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")
                )
         )

 

This gets as far as 'Window' then doesn't like what is happening - I am guessing it doesn't like the (trans (vlax-safearray.....) part ? try putting in some coordinates there instead just to check, perhaps make a note of your print area and type those in? Maybe try the version BigAl suggested too

 

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