+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Super Member JPlanera's Avatar
    Computer Details
    JPlanera's Computer Details
    Operating System:
    Win7 x64
    Computer:
    Dell T7400
    CPU:
    (4) Intel Xeon CPU X5272 @ 3.4GHz
    RAM:
    8G
    Graphics:
    NVIDIA Quadro FX 570 & RADEON X6000
    Primary Storage:
    80G main
    Secondary Storage:
    1TB ext
    Monitor:
    (3) DELL 21" wide
    Using
    Mechanical 2012
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    526

    Default BREAKTHROUGH??? Batch processing with user input!

    Registered forum members do not see this ad.

    I needed to print 200+ drawings located in multiple locations, but only a section of each drawing that was not previously defined by a view or common coordinates... A batch printing process that could pause at each drawing to accept user input was what i was after. I stumbled upon a bundle of code that works! As a novice coder, I am hoping someone out there will tell me there is a much easier way!

    In order for this to work, I had to break in to a script file for user input. Since this cant be done, I created 2 seperate scripts within 2 LISPS that would loop infinitely.. I had to creat a txt file containing every drawing to be opened. This was done in excell fairly easily. The purpose of this list is to "read-line" and write to a script file. The script file would then contain one line. "OPEN" "file" "custom command" hopefully it makes sense as I post the code. The master list had to be modified everytime so that the first line is always "next" so I used VBA to delete the first line. This was all done with SDI=1 so i didnt have to worry about coding in a close..

    Ok, here goes nothin...

    SET SDI=1
    Main start program. The first drawing must be open at this time, and the master list will contain drawings 2 on.
    Code:
    ;BATCH PRINT USER DEFINED VIEW
    ;JPLANERA 7/3/12
    ;This routine will allow the user to define the view and will print the stored view
    ;Then the script callout starts the process that alters the "open" file script.
    ;Open the first drawing in the master list and initiate the DVP command to start.
    ;The master list will contain ALL but the current open drawing.
    (DEFUN C:DVP ()
       (command "-view" "W" "1" pause pause)
       (while 
          (= 1 
             (getvar "cmdactive")
          )
         (command pause)
       )
       (command "-plot" "y" "model" "RICOH C5000 ENG" "Letter (8.5\" X 11\")" "i" "P" "n" "V" "1" "f" "c" "y" "monochrome.ctb" "y" "a" "n" "y" "y")
       (command "script" "U:\\batchpress\\mos.scr")
    )
    Contents of mos.scr
    Code:
    -VIEW
    RESTORE
    1
    QSAVE
    MOS
    MOS.LSP this is the routine that reads from the master list, writes to a script file and erases the first line of the master list...
    Code:
    ;OPEN DRAWING SCRIPT MODIFY
    ;JPLANERA 7/3/12
    ;This routine will read the first line of the "master" list of drawings, then write it to a script file.
    ;This script file will contain only 1 line of code so autocad does not get "confused"
    ;A VBA routine is then used to delete the first line of the master list so that when
    ;this routine is run again, the first line to be read is the "next" drawing in the list.
    (defun c:MOS (/ MPTL L1 OF)
      (setq MPTL (open "U:\\batchpress\\masterpresstoollist.txt" "r")
    )
      (setq L1 (read-line MPTL)
    )
      (close MPTL)
      (setq OF (open "U:\\batchpress\\openfile.scr" "w")
    )
      (write-line L1 OF)
      (close OF)
      (startapp "wscript" "\"U:\\batchpress\\deleteline.vbs\"")
      (princ)
      (command "script" "U:\\batchpress\\openfile.scr")
    )

    contents of master list txt file (shortened of course). Done in excell. "DVP" at the end starts the loop back to the first LISP routine.
    Code:
    OPEN M:\ENGR\Drawings\TOOLING\T18516\T18516.dwg DVP
    OPEN M:\ENGR\Drawings\TOOLING\T18519\T18519.dwg DVP
    OPEN M:\ENGR\Drawings\TOOLING\T18530\T18530.dwg DVP

    contents of script file to open drawings and call back first command LISP. I tried to do this all in the master list but kept getting runtime errors. I suspect because the list was being used while I was trying to edit it... solution was two files.
    Code:
    OPEN M:\ENGR\Drawings\TOOLING\T18515\T18515.dwg DVP

    DeleteLine Function by TomRiddle 2008
    Code:
    DeleteLine "U:\BATCHPRESS\masterpresstoollist.txt", "", 1, 0 
     
     Function DeleteLine(strFile, strKey, LineNumber, CheckCase) 
     'DeleteLine Function by TomRiddle 2008 
     'Remove line(s) containing text (strKey) from text file (strFile) 
     'or 
     'Remove line number from text file (strFile) 
     'or 
     'Remove line number if containing text (strKey) from text file (strFile) 
     'Use strFile = "c:\file.txt"  (Full path to text file) 
     'Use strKey = "John Doe"      (Lines containing this text string to be deleted) 
     'Use strKey = ""              (To not use keyword search) 
     'Use LineNumber = "1"         (Enter specific line number to delete) 
     'Use LineNumber = "0"         (To ignore line numbers) 
     'Use CheckCase = "1"          (For case sensitive search ) 
     'Use CheckCase = "0"          (To ignore upper/lower case characters) 
     
        Const ForReading=1:Const ForWriting=2 
        Dim objFSO,objFile,Count,strLine,strLineCase,strNewFile 
        Set objFSO=CreateObject("Scripting.FileSystemObject") 
        Set objFile=objFSO.OpenTextFile(strFile,ForReading) 
        Do Until objFile.AtEndOfStream 
           strLine=objFile.Readline 
           If CheckCase=0 then strLineCase=ucase(strLine):strKey=ucase(strKey) 
           If LineNumber=objFile.Line-1 or LineNumber=0 then 
              If instr(strLine,strKey) or instr(strLineCase,strkey) or strKey="" then 
                 strNewFile=strNewFile 
              Else 
                 strNewFile=strNewFile&strLine&vbcrlf 
              End If 
           Else 
              strNewFile=strNewFile&strLine&vbcrlf 
           End If 
        Loop 
        objFile.Close 
        Set objFSO=CreateObject("Scripting.FileSystemObject") 
        Set objFile=objFSO.OpenTextFile(strFile,ForWriting)  
        objFile.Write strNewFile  
        objFile.Close  
     End Function
    Ok hopefully this all makes sense. If further explaing is needed please let me know. Also i would be happy to hear there is an easier way!! Im sure this could be used to do multiple user input commands but i think i am going to take a break before I try to do any more!
    You might be an engineer, if you tell people that time travel does not exist..... and then 5 minutes later explain how you would build a time machine

    Engineers aren't boring people, we just get excited over boring things.

  2. #2
    Forum Deity Dadgad's Avatar
    Using
    AutoCAD 2012
    Join Date
    Nov 2011
    Location
    At the confluence of worthlessness & invaluability
    Posts
    3,133

    Default

    Sounds like you deserve a little vacation, why not consider a bried virtual trip to ..... http://www.lee-mac.com/programs.html#general.

    There is a better than even chance that you will find something there to help you.

    As for stopping and resuming a script, you might want to read this..... http://www.lukewarmcoffee.com/cad/AU...20Everyone.pdf

    Hope you find some help in those links.
    Volume and repetition do not validate opinions forged in the absence of thought.

  3. #3
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,780

    Default

    Why not just write one big script with every dwg name in it created from the master todo list a script can have hundreds of open dwgs in it make sure close at end, just for practical sense write 1 line for each dwg. I think your over complicating it. Your dwg list can have multiple choice like,
    dwg1name view1name
    dwg1name view2name
    dwg2name viewname
    dwg3name viewname

    Code:
    open dwg1 -VIEW RESTORE 1 dvp close N
    open dwg2 -VIEW RESTORE 1 dvp close N
    open dwg3 -VIEW RESTORE 1 dvp close N
    A man who never made mistakes never made anything

  4. #4
    Super Member JPlanera's Avatar
    Computer Details
    JPlanera's Computer Details
    Operating System:
    Win7 x64
    Computer:
    Dell T7400
    CPU:
    (4) Intel Xeon CPU X5272 @ 3.4GHz
    RAM:
    8G
    Graphics:
    NVIDIA Quadro FX 570 & RADEON X6000
    Primary Storage:
    80G main
    Secondary Storage:
    1TB ext
    Monitor:
    (3) DELL 21" wide
    Using
    Mechanical 2012
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    526

    Default

    Quote Originally Posted by BIGAL View Post
    Why not just write one big script with every dwg name in it created from the master todo list a script can have hundreds of open dwgs in it make sure close at end, just for practical sense write 1 line for each dwg. I think your over complicating it. Your dwg list can have multiple choice like,
    dwg1name view1name
    dwg1name view2name
    dwg2name viewname
    dwg3name viewname

    Code:
    open dwg1 -VIEW RESTORE 1 dvp close N
    open dwg2 -VIEW RESTORE 1 dvp close N
    open dwg3 -VIEW RESTORE 1 dvp close N
    I did try something similar to this, but the script would not resume, unless of course i did something wrong, which is a great possibility.
    You might be an engineer, if you tell people that time travel does not exist..... and then 5 minutes later explain how you would build a time machine

    Engineers aren't boring people, we just get excited over boring things.

  5. #5
    Super Member JPlanera's Avatar
    Computer Details
    JPlanera's Computer Details
    Operating System:
    Win7 x64
    Computer:
    Dell T7400
    CPU:
    (4) Intel Xeon CPU X5272 @ 3.4GHz
    RAM:
    8G
    Graphics:
    NVIDIA Quadro FX 570 & RADEON X6000
    Primary Storage:
    80G main
    Secondary Storage:
    1TB ext
    Monitor:
    (3) DELL 21" wide
    Using
    Mechanical 2012
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    526

    Default

    Quote Originally Posted by Dadgad View Post
    Sounds like you deserve a little vacation, why not consider a bried virtual trip to ..... http://www.lee-mac.com/programs.html#general.

    There is a better than even chance that you will find something there to help you.

    As for stopping and resuming a script, you might want to read this..... http://www.lukewarmcoffee.com/cad/AU...20Everyone.pdf

    Hope you find some help in those links.
    Thank you! As BIGAL said, I definitely think I am over complicating it. I am very green at this stuff and have not had any training, and this was the only (or first) thing I could come up with. I searched the forums and asked around, but noone had a solution to my question... I will check out the links and see what i can dig up. If (or when...) I find something, I will report back with an update. Thank you for the input guys! If LeeMac stumbles on to this I am sure he will have something to say. HA
    You might be an engineer, if you tell people that time travel does not exist..... and then 5 minutes later explain how you would build a time machine

    Engineers aren't boring people, we just get excited over boring things.

  6. #6
    Super Member JPlanera's Avatar
    Computer Details
    JPlanera's Computer Details
    Operating System:
    Win7 x64
    Computer:
    Dell T7400
    CPU:
    (4) Intel Xeon CPU X5272 @ 3.4GHz
    RAM:
    8G
    Graphics:
    NVIDIA Quadro FX 570 & RADEON X6000
    Primary Storage:
    80G main
    Secondary Storage:
    1TB ext
    Monitor:
    (3) DELL 21" wide
    Using
    Mechanical 2012
    Join Date
    Sep 2010
    Location
    Chicago
    Posts
    526

    Default

    Registered forum members do not see this ad.

    Ok.. This is what I found out:

    I did not see anything that would help on Lees page.. But the lukewarmcoffe link had some nice info.

    The RESUME command worked once the script crashes, but you have to type the command in every drawing. It simplifies the code, but requires extra keystrokes.

    It looks like script-hopping is the answer and it appears that this is what i did. The only problem is, it works on 1 drawing only. In order to get the "batch" process to work, one script would have to go to the next line everytime, which is impossible, right?? That is where the VBA came in to remove the processed drawing from the master list and the LISP to write-line to a SCR file.. It may seem overly complicated but I couldnt glean any easier procedure. Please if someone can enlighten me I would appreciate it!
    You might be an engineer, if you tell people that time travel does not exist..... and then 5 minutes later explain how you would build a time machine

    Engineers aren't boring people, we just get excited over boring things.

Similar Threads

  1. Looking for user input
    By Skilbride in forum AutoCAD General
    Replies: 13
    Last Post: 23rd May 2011, 08:28 pm
  2. Looking for user input
    By Skilbride in forum Autodesk Inventor
    Replies: 0
    Last Post: 20th May 2011, 07:28 pm
  3. Using Batch Processing to create a *.dwg File List?
    By muck in forum The CUI, Hatches, Linetypes, Scripts & Macros
    Replies: 7
    Last Post: 29th Sep 2010, 06:07 pm
  4. user input
    By salman in forum AutoLISP, Visual LISP & DCL
    Replies: 1
    Last Post: 13th May 2010, 04:33 pm
  5. User Input:
    By StykFacE in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 10th May 2007, 07:12 pm

Tags for this Thread

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