CAVINCA Posted December 18, 2007 Posted December 18, 2007 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) ;************************************************* ************************************************** ) Quote
CAB Posted December 18, 2007 Posted December 18, 2007 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) ) Quote
CAVINCA Posted December 18, 2007 Author Posted December 18, 2007 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] ) Quote
CAB Posted December 18, 2007 Posted December 18, 2007 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 ) Quote
CAVINCA Posted December 18, 2007 Author Posted December 18, 2007 Awesome perfect!! worked great for the 30 plots i needed. Quote
CAB Posted December 18, 2007 Posted December 18, 2007 Glad I could help. Speaking of plots: http://www.theswamp.org/index.php?topic=1916.0 Quote
CAVINCA Posted December 19, 2007 Author Posted December 19, 2007 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. Quote
CAB Posted December 19, 2007 Posted December 19, 2007 Well I feel for you with all those separate files to deal with. Lots of xrefs I assume. What you need is a script or use the PUBLISH command. http://www.theswamp.org/index.php?topic=15168.msg184179#msg184179 http://www.theswamp.org/index.php?topic=9063.0 http://www.theswamp.org/index.php?topic=2948.0 http://www.theswamp.org/index.php?topic=5521.0 http://www.theswamp.org/index.php?topic=9379.0 Quote
CAVINCA Posted December 19, 2007 Author Posted December 19, 2007 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……… 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: Quote
CAB Posted December 19, 2007 Posted December 19, 2007 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. Quote
CAVINCA Posted December 19, 2007 Author Posted December 19, 2007 what about completely automating the process. is it possible to locate and use the coordinates of multiple block references? this is what im working with... i tried inserting it but it wouldnt work... heres the hyperlink... http://img256.imageshack.us/my.php?image=70952229nw4.jpg Quote
CAB Posted December 19, 2007 Posted December 19, 2007 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. Quote
CAB Posted December 19, 2007 Posted December 19, 2007 Yes, if there are points that can be aquired in the drawing. Quote
anaskattayil Posted September 8, 2013 Posted September 8, 2013 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.... Quote
anaskattayil Posted September 11, 2013 Posted September 11, 2013 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") ; Quote
Recommended Posts
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.