+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 13
  1. #1
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    11

    Default custom printing lisp (help please)

    Registered forum members do not see this ad.

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

    ;;************************************************ *************
    (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)

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

    ;************************************************* **************************************************
    )

  2. #2
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

    Default

    Maybe this:
    Type CLP at the command line
    Code:
    (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)
    )

  3. #3
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    11

    Default

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

    Code:
     
    (defun c:CPL ( / pld pps ps orsnap p1 p2); << whats this do?
      (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)); << whats this null do?
          (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); << whats this do?
    )

  4. #4
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

    Default

    Some answers for you, I won't be in for the rest of the day.
    Hope this helps.
    Code:
    (defun c:CPL ( / pld pps ps orsnap p1 p2); make variables local to the lisp
    
     (null (initget 1)); << whats this null do?
     because initget returns nil the null returns true and keeps you in the AND expression
    
      (princ); << whats this do?
    in this case it prevents the routine from returning nil at the command line
    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.
    Code:
    (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.
    Code:
    (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
    )

  5. #5
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    11

    Default

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

  6. #6
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

    Default

    Glad I could help.
    Speaking of plots:
    http://www.theswamp.org/index.php?topic=1916.0

  7. #7
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    11

    Default

    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.

  8. #8
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

  9. #9
    Junior Member
    Using
    AutoCAD 2008
    Join Date
    Dec 2007
    Posts
    11

    Default

    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.

  10. #10
    Super Member CAB's Avatar
    Using
    AutoCAD 2000
    Join Date
    May 2004
    Location
    Tampa, Florida
    Posts
    801

    Default

    Registered forum members do not see this ad.

    The first link is to a Script Generator / Facilitator.
    You load or create a script. In your case it could be simply this:
    Code:
    (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.

Similar Threads

  1. Lisp Routines and Custom Menus
    By STUP in forum AutoCAD Drawing Management & Output
    Replies: 3
    Last Post: 12th Dec 2007, 09:32 pm
  2. Help with custom leader
    By croz in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 11th Oct 2007, 07:12 pm
  3. problem, trying to running a list of lisp from within a lisp
    By twind2000 in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 20th Aug 2007, 04:27 pm
  4. Help with a custom lisp.
    By JSA in forum AutoLISP, Visual LISP & DCL
    Replies: 6
    Last Post: 1st Feb 2006, 06:06 pm
  5. custom hatching?
    By xero in forum AutoCAD General
    Replies: 4
    Last Post: 25th Nov 2004, 04:25 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts