Jump to content

wheats

Members
  • Posts

    18
  • Joined

  • Last visited

Everything posted by wheats

  1. Sorry what i was after was for it to terminate the actual acad.exe process the script ran (sometimes the lisp routine we run on files can cause errors and the program is stuck in a constant loop) though ending the process acad.exe closes all process with this image name where i am only after closing the one the script started. I tried adding $PID variable at the start of the RunWait function to terminate it though i get a error message saying that the $pid was not called Else $PID = RunWait('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" "' & $var & '" /b "G:\8333\JOBNO- CAD JOB\04 RESOURCE\03 STANDARDS\clean.scr" /nologo /nossm ' , "", @SW_HIDE) EndIf MsgBox(4096, "", "Batch Cleaning Finished") Func Terminate() ProcessClose($pid) Exit 0 MsgBox(4096, "", "Batch Process Canceled") EndFunc
  2. I think i will forget the write line part because its a lot easier to run this script through AutoCAD without having to open and close because all it is doing is a putting a date on the drawing.
  3. I was putting some thought into it to try and make this program full proof for future years to come instead of having to update it each year with a new release of AutoCAD because the path changes based on the year of the program i was thinking of being able to run something like this (dos command) dir /s /b "%programfiles%AutoDeskacad.exe this returns these values c:program filesautodeskautocad 2012acad.exe c:program filesautodeskautocad 2013acad.exe c:program filesautodesknavisworks simulate 2013lcdbx2013acad.exe RunWait(@ComSpec & " /c dir *.EXE /s/b|cb.exe","",@SW_HIDE) ;Uses(cb.exe) to route output from a commandline app straight to the clipboard .. which can then be interrogated from within AU3 (thereby avoiding the need to bounce the info through a file) Though now i think about it there is no way of narrowing down the file enough to specify the version of acad.exe you want to run (any version of AutoCAD will work though not Navisworks) I have also tried to update the script a bit for instance where the script path is kept changes based on what jobno it is kept in so i tried to created a variable to be based on the @workingdir of the autoit.exe file and then the 04 RESOURCE03 STANDARDSclean.scr and then reference the variable in the script call up section of the RunWait command, though to no luck - The reason for this is that the script file we are going to write a new line to will be in different job folder numbers based on where the autoit.exe is executed from. My script looks like this at the moment. ;#include ;Needed only for _ArrayDisplay $message = "Hold Down Ctrl Or Shift To Choose Multiple Files." $var = FileOpenDialog($message, @WorkingDir, "CAD FILES (*.dwg*)", 1 + 4) If @error Then MsgBox(4096, "", "No File(s) chosen") Exit EndIf ;ConsoleWrite($var & @CRLF) ;For Debug Only If StringInStr($var, "|") Then ;Multiple file $split = StringSplit($var, "|") ;_ArrayDisplay($split) $script_path = @WorkingDir & "\04 RESOURCE\03 STANDARDS\clean.scr" For $i = 2 To UBound($split) - 1 $file_path = @WorkingDir & "\" & $split[$i] ;ConsoleWrite('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" /b "' & $file_path & '"' & @CRLF) RunWait('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" "' & $file_path & '" /b "G:\8333\JOBNO- CAD JOB\04 RESOURCE\03 STANDARDS\clean.scr" /nologo /nossm ' , "", @SW_HIDE) Next Else RunWait('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" "' & $var & '" /b "$script_path" /nologo /nossm ' , "", @SW_HIDE) EndIf MsgBox(4096, "", "Batch Cleaning Finished") Exit
  4. Ill try find some snippets to get some kind of idea, thanks nessie
  5. Ok thanks Nessie Do you know anything about being able to amend lines in notepad using autoit ?? For Instance Line1 - text1 Line2 - text2 Line3 - text3 Message box to pop up asking user to input a text string for this purpose the date "inpute date:" Which would then change text2 to input date?? What i have is a script that goes through all autocad drawings and finds text string xx.xx.xx and replaces with what the user inputs to the correct date - what i am trying to do is able to run the autoit script to update the notepad file before batching the script through autocad.
  6. Ok i figured it out i was putting the @SW_HIDE flag in the workingdir not the flag section of the script. Is there a way to add hotkeys to terminate the script?? I found this section in the help part though I don't really understand how it works within the script. ; Press Esc to terminate script, Pause/Break to "pause" Global $Paused HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{ESC}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d ;;;; Body of program would go here ;;;; While 1 Sleep(100) WEnd ;;;;;;;; Func TogglePause() $Paused = Not $Paused While $Paused Sleep(100) ToolTip('Script is "Paused"', 0, 0) WEnd ToolTip("") EndFunc ;==>TogglePause Func Terminate() Exit 0 EndFunc ;==>Terminate Func ShowMessage() MsgBox(4096, "", "This is a message.") EndFunc ;==>ShowMessage
  7. How do you go about adding a @SW_HIDE Flag into the program so it doesn't constantly open - so you can run the script and then let it go about its business for 20mins without getting windows popping up after each .dwg its processed?
  8. Was there a link missing? Oh! you should get some sleep I had a go at launching ACLauncher.exe on its own through Windows nothing happens. I'll do some googling Also figured out to make multiple switches work its RunWait('"C:\Program Files\Common Files\Autodesk Shared\AcShellEx\AcLauncher.exe" "' & $var & '" /b "c:\datafiles\CP12-3L\wbout.scr" /nologo /nossm ') this actually sped the process up a fair bit. *EDIT* seems you can not run the /b switch with AcLauncher - so you can't run a batch script
  9. Yeah SDI forces AutoCAD to be able to only have 1 file open at a single time, though from my tests the autoit script doesn't process the next file in the selection until autocad has been exited and then it starts another copy and processes the next file. Maybe the solution is to just run multiple switches on the autocad so it runs like a compatibility mode version so it doesn't have to take 30seconds to run through all the plugins. http://usa.autodesk.com/adsk/servlet/ps/dl/item?siteID=123112&id=2894625&linkID=9240617 I may just run a couple of these along with " /b " to simplify the program and hopefully take less loading time. to do these all i would have to do is add /b /nologo - is this correct? Run('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" "' & $var & '" /b /nologo "c:\datafiles\CP12-3L\wbout.scr"')
  10. RunWait works and the script file is processed. Only thing is that once the first file is opened it closes the program to open the next file with the same program, AutoCAD takes about 30seconds to open so the batch processing of this is slowing down obviously having to wait 30seconds between each file the script runs on. I'll have a look around to see if there is any way to force AutoCAD to process each $var while staying open Thanks for all your help Nessie
  11. Yeah this works now for a single file, thought the script section doesn't. If you select multiple files it goes back to the original problem of only opening "a.dwg" "b.dwg" and not "C:Testa.dwg" and "C:Testb.dwg I think the start wait command controls the program to open the files 1 at a time ? %%f will then be used in the second portion of the line as a variable, changing with each pass to the next drawing name. The START /WAIT option starts a windows application and returns control to the batch file when done. Acad.exe is the windows application that is being started. AutoCAD will now start and open each drawing. Because of the /b switch, the script file named “wbout.scr” will run every time AutoCAD starts. When all files with a .dwg extension have been processed (made equal to variable %%f), the program will stop.
  12. Yes i believe so its the launch string of AutoCAD that seems to be causing the path error.
  13. Yes this is the output I am after though this does not work for me. I just removed the /b from the code and it opens for the file correctly. "C:Program FilesAutoDeskAutoCad 2013acad.exe" "C:Testa.dwg" - opens "C:Testa.dwg" and with the /b in the code "C:Program FilesAutoDeskAutoCad 2013acad.exe" /b "C:Testa.dwg" - opens "a.dwg" The /b is obviously having a impact on the opening of the file in regards to its path directory. The /b is a start up switch for AutoCAD telling the program batch process - so hopefully it should only open up one copy of the program and process each file at a time. -- This is where i original got the code for the .bat program --- md c:datafilesCP12-3Ldwgwb FOR %%f in (c:datafilesCP12-3Ldwg*.dwg) do start /wait c:”program files””AutoCAD 2006”acad.exe “%%f” /b c:datafilesCP12-3Lwbout.scr What does this all mean? The first line creates a new folder (directory, sub-directory) name “wb” within an existing folder, so the new versions of the drawing files can be placed there until their integrity is confirmed. The replaceable parameter %%f represents the name of each specified file within the folder named “c:datafilesCP12-3Ldwg.” Each .dwg file in that location will be processed in alphabetical order as it is set to the replaceable parameter %%f. %%f will then be used in the second portion of the line as a variable, changing with each pass to the next drawing name. The START /WAIT option starts a windows application and returns control to the batch file when done. Acad.exe is the windows application that is being started. AutoCAD will now start and open each drawing. Because of the /b switch, the script file named “wbout.scr” will run every time AutoCAD starts. When all files with a .dwg extension have been processed (made equal to variable %%f), the program will stop. Note: the path given to locate the “acad.exe” file is not necessary unless there is more than one acad.exe file on the computer. This could happen if you have multiple releases of AutoCAD or if you have one or more vertical applications on your computer, as is the case for the computers in this lab. It is generally better to be precise in giving a path. The quotation marks within the batch file are required to compensate for spaces in the names of files or folders. Putting quotes around the second occurrence of %%f allows you to process drawing files that have spaces within their names as well. Place the quotations exactly as shown.
  14. I have tried multiple variations of how to get it to open the folderdrawing.dwg but with the modified code of yours it still only tries to open drawing.dwg no path - then if u add @workingdir it then brings up the @workingdir@workingdirdrawing.dwg Same thing happens if you select multiple files the program opens two versions of itself and then only opens drawing.dwg with no path information very confusing haha
  15. Hi This is grabbing the file path but now it is grabbing it multiple times, C:Folder1C:Folder1drawing1.dwg. Also to run the script I would assume that this would be the correct function? Run('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" "' & $file_path & '"') /b c:\scriptfolder\script.scr thanks for your help
  16. Actually even if one file is selected it still says invalid file name it is storing the file name information but not the path of the file so it the users selects c:folder1drawing1.dwg it tries to just open drawing1.dwg and cannot find any path.
  17. Nessie, this allows the user to select files then open the files up but what it is trying to do is open multiple files at once so if drawing1.dwg and drawing2.dwg were selected it trys to open drawing1.dwgdrawing2.dwg as one file and then it is not recognized.
  18. Hello all new to autoit but seems like a very nifty program to be able to write scripts to save alot of users time. What i am after is to be able to run a .exe to allow the user to select files in the folder he/she specifies and then runs an autocad script on each of the selected files. This is what i have so far from general browsing over the forums.. #Include #Include #include $MyDocsFolder = "::{450D8FBA-AD25-11D0-98A8-0800361B1103}" $message = "Hold down Ctrl or Shift to choose multiple files." $var = FileOpenDialog($message, $MyDocsFolder & "\", "All Files (*.dwg*)", 1 + 4 ) If @error Then MsgBox(4096,"","No File(s) chosen") This part allowing the user to select .dwg files from any location he/she wants with performing error message if no files selected. The idea i got was from an Autodesk University tutorial for being able to run scripts through .bat programs though I don't think its possible for .bat files to be able to have user specify files. The Code below is from the .bat functions (where path is the directory the script is stored) For %%f in (path\*.dwg) do start /wait C:\"Program Files"\"AutoDesk"\"AutoCad 2013"\acad.exe "%%f" /b path\scriptname.scr Run ('"C:\Program Files\AutoDesk\AutoCad 2013\acad.exe" /b "path\scriptfilename.scr"') This is where i got to with AutoIT being able to open up AutoCAD and being able to run a script though how do you go about setting the files previously selected as variables so you can tell AutoCAD to open each file and run the script. Thanks for taking the time to read this and all help is much appreciated Mark.
×
×
  • Create New...