Jump to content

custom printing lisp (help please)


Recommended Posts

Posted

i need help with this if possible... i need it to loop where i have begin loop and end where it says end, with no continuous input from the user and any given amount of plots. would it be possible to break in the loop anywhere and continue past the loop to reset my snap?

 

ex. i have multiple pages to print off of one dwg.

i want it to continuosly ask me for a plot window and print until i break the loop and then i want it to reset my snap. i dont want to be prompted on whether i would like to continue ploting pages.

 

i hope that makes since...:?

;************************************************* ***********

(defun C:PPL ()

 

;;************************************************ *************

(setq PLD "Canon iC2300 PCL5e") ;

(setq PPS "(11x17)") ;

(setq PS "ARINC-BASE.ctb") ;

;************************************************* **************************************************

(setq orsnap (getvar "osmode"))

(setvar "OSMODE" 1)

 

;BEGIN LOOP

(initget 1)

(setq P1 (getpoint "\n Upper Left Endpoint: "))

(Initget 1)

(setq P2 (getpoint "\n Lower Right Endpoint: "))

;;************************************************ ************

 

(command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS "" "" "" "y" "" )

;ENDLOOP

 

(setvar "OSMODE" orsnap)

 

;************************************************* **************************************************

)

Posted

Maybe this:

Type CLP at the command line

(defun c:CPL ( / pld pps ps orsnap p1 p2)
 (setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
 (setq PPS "(11x17)") ; << Paper Size
 (setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table 

 (setq orsnap (getvar "osmode"))
 (setvar "OSMODE" 1)

 (while
   (and
     (null (initget 1))
     (setq P1 (getpoint "\n Upper Left Endpoint: "))
     (null (initget 1))
     (setq P2 (getcorner p1 "\n Lower Right Endpoint: "))
   )
    (command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
             "" "" "y" "")
 )

 (setvar "OSMODE" orsnap)
 (princ)
)

Posted

OK thanks i couldnt get the while loop to work when i did it. but im still left with a osmode value of 1 when i break the loop. i need it to reset back to the original value after the plots. i have a couple of questions... im new to lisp but im pretty programing literate...

 

 
(defun c:CPL [b]( / pld pps ps orsnap p1 p2); << whats this do?[/b]
 (setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
 (setq PPS "(11x17)") ; << Paper Size
 (setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table 

 (setq orsnap (getvar "osmode"))
 (setvar "OSMODE" 1)

 (while
   (and
     [b](null[/b] (initget 1)); [b]<< whats this null do?
[/b]      (setq P1 (getpoint "\n Upper Left Endpoint: "))
     (null (initget 1))
     (setq P2 (getcorner p1 "\n Lower Right Endpoint: "))
   )
    (command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
             "" "" "y" "")
 )

 (setvar "OSMODE" orsnap)
[b] (princ); << whats this do?[/b]
)

Posted

Some answers for you, I won't be in for the rest of the day.

Hope this helps.

(defun c:CPL ( / pld pps ps orsnap p1 p2); [color="Red"]make variables local to the lisp[/color]

(null (initget 1)); << whats this null do?
[color="Red"] because initget returns nil the null returns true and keeps you in the AND expression[/color]

 (princ); << whats this do?
[color="red"]in this case it prevents the routine from returning nil at the command line[/color]

You are breaking out of the loop with the Escape key which doesn't let the routine finish.

Prevent this with an error handler or trapping the Escape key press.

 

Here is the example of the error routine.

(defun c:CPL (/ *error* pld pps ps useror p1 p2) ; << whats this do?
 ;; error function & Routine Exit
 (defun *error* (msg)
   (if
     (not
       (member
         msg
         '("console break" "Function cancelled" "quit / exit abort" "")
       )
     )
      (princ (strcat "\nError: " msg))
   )               ; endif

   ;; reset all variables here
   (and useror (setvar "orthomode" useror))
   (and useros (setvar "osmode" useros))
   (if usercmd
     (setvar "CMDECHO" usercmd)
     (setvar "CMDECHO" 1) ; preferred default
   )
 )                 ; end error function


 ;;  Start routine here
 (setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
 (setq PPS "(11x17)") ; << Paper Size
 (setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table 

 (setq useror (getvar "osmode"))
 (setvar "OSMODE" 1)

 (while
   (and  ; all must be true to stay in loop
     (null (initget 1))
     (setq P1 (getpoint "\n Upper Left Endpoint: "))
     (null (initget 1))
     (setq P2 (getcorner p1 "\n Lower Right Endpoint: "))
   )
    (command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
             "" "" "y" "")
 )

 (*error* "") ; run the error routine with no message to restore vars
 
 (princ) ; exit quietly
)

 

This is an example of trapping the escape at each getpoint.

(defun c:CPL (/ pld pps ps useror p1 p2 err)

 ;;  Start routine here
 (setq PLD "Canon iC2300 PCL5e") ; << Ploting Device
 (setq PPS "(11x17)") ; << Paper Size
 (setq PS "ARINC-BASE.ctb") ; << Plot yStyle Table 

 (setq useror (getvar "osmode"))
 (setvar "OSMODE" 1)

 (while
   (and            ; all must be true to stay in loop
     (null (initget 1))
     (if
       (vl-catch-all-error-p
         (setq p1 (vl-catch-all-apply
                    'getpoint '("\n Upper Left Endpoint: ")))
       )
        (alert (vl-catch-all-error-message p1)) ; returns nil & exit AND
        t          ; stay in AND
     )
     (null (initget 1))
     (if
       (vl-catch-all-error-p
         (setq p2 (vl-catch-all-apply
                    'getcorner (list p1 "\n Lower Right Endpoint: ")))
       )
        (alert (vl-catch-all-error-message p2)) ; returns nil & exit AND
        t          ; stay in AND
     )
   )

    (command "-PLOT" "y" "" PLD "11x17" "in" "l" "n" "w" P1 P2 "f" "c" "" PS ""
             "" "" "y" "")
 )

 (setvar "OSMODE" useror)

 (princ)           ; exit quietly
)

Posted

Awesome perfect!! worked great for the 30 plots i needed.

Posted

sweet routine. if i could get our bosses to uses multi tabs rather than the 50 drawings on one tab that would be awesome. at least the keep layers seperate...mostly seperate.

Posted

nope no xrefs. seperate plots on one dwg, on one tab.

I. .Dwg

A. model tab

1. Sheet 1-50

2. Sheet 2-50

……and so on………

:oops:

only seperated by the lines i draw. multiple plots by window is what i needed. and im soooo happy i dont have to Use the * to repeat the command via CUI. that messed up all my snaps and a couple other things.

 

 

Whats that first link do.. generate routines by selecting commands on a graphical interface? if not.... get to work on that im sure you could figure it out in half the time i could. :wink:

Posted

The first link is to a Script Generator / Facilitator.

You load or create a script. In your case it could be simply this:

(C:cpl)
save

Not sure but you may not need the save as it may already be added.

 

You then select the Drawings to run the script on.

Run Script will then open each drawing, run the script, then close the drawing.

It repeats until all the drawings are done.

 

So if your CPL lisp did not require user input the process for the 50 drawings would be automatic.

Posted

Most times there is no lisp involved in a script. So your script would look something like this:

note that i just added n for the missing responses, you would need to correct these.

-PLOT 
y 
n
PLD 
11x17 
in 
l 
n 
w 
P1 
P2 
f 
c 
n
PS 
n
n
n
y 

 

Look into the PUBLISH command, it will make our life easier.

Posted

Yes, if there are points that can be aquired in the drawing.

  • 5 years later...
Posted

Please help me.... I cannot manage this lisp becoz... I have 123 a4 size x section in one drawing at model. can i plot at same time? please help me. I need 123 pdf file & print. any lisp for me....

Posted

I cannot work with the attached programm... I am working in autocad2009 version... pls help me

 

(defun c:CPL ( / pld pps ps orsnap p1 p2) (setq PLD "Canon iC2300 PCL5e") ;

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