Jord_91 Posted February 22, 2018 Posted February 22, 2018 Hi, I need to run a scrit on multiple files and I would like it To chose wich SCR to run bas on the begining of the Name of the DWG File. In this case i have file with 2436, 3648 etc... and my scr would need to run the 2436INS.SCR on the 2436 ans same thing with the 3648 etc... I have try using Script Pro 2.0 But as it's openning a new file that has nothing in it it wont run proprelly the srcip. Here's my .scr _-view _Left _ai_selall section _crossing 0,0 23-1/8,84 0,4-1/2 23-3/8,4-1/2 26,8 effacer _crossing 0,0 23-1/8,4 _-view _top -INSERER "C:/Users/jlarrivee/Desktop/pattes/2436OVA.dwg" 0,0,0 1 1 0 ANNULER fin decompos _last _Qsave Also Got it in Macro Command ^c^c_-view;_Left;^c^c_ai_selall;section;_crossing;0,0;23-1/8,84;;0,4-1/2;23-3/8,4-1/2;26,8;^c^ceffacer;_crossing;0,0;23-1/8,4;;^c^c_-view;_top;-INSERER;"C:/Users/jlarrivee/Desktop/pattes/2442OVA.dwg";0,0,0;1;1;0;^c^cdecompos;_last;;^C^C_Qsave I would at least be able to run it in Script Pro but if someone is able to make a.bat or a lisp quith that it would be so fantastic I'm really sorry for my bad english! Thanks to every one! Quote
BIGAL Posted February 23, 2018 Posted February 23, 2018 A script can not choose what to do based on the filename, but the script can pass to a lisp the file name and run the correct sequence. You would create a lisp that has the sequence of commands as a defun a little mini program but you would have two programs 2436 and 3648. You would autoload this lisp or load as you open every dwg This is NOT TESTED (defun 2436 ( ) (command _-view _Left "" "") (command "_ai_selall" "section" "_crossing" "0,0" "23-1/8,84" "" "0,4-1/2" "23-3/8,4-1/2" "26,8" "" "" "effacer" "_crossing" "0,0" "23-1/8,4" "" "" "") (command "_-view" "_top") (command "-INSERER" "C:/Users/jlarrivee/Desktop/pattes/2436OVA.dwg" "0,0,0" 1 1 0 ANNULER fin decompos "_last" "" "") (command "_save" "Y" "close") ) (defun 3648 () ....... ....... ) (defun mysize (dwgname / ) (setq stfile (substr dwgname 1 4)) (cond ((= stfile "2436)(2436)) ; check 4 characters and runs correct defun ((= stfile "3648)(3648)) ) ) Script open dwg1 (mysize (getvar "dwgname")) open dwg2 (mysize (getvar "dwgname")) ; lisp is called 24363648.lsp open dwg1 (if (not 2436)(load "24363648")) (mysize (getvar "dwgname")) open dwg2 (if (not 2436)(load "24363648")) (mysize (getvar "dwgname")) Quote
rlx Posted February 23, 2018 Posted February 23, 2018 A script can not choose what to do based on the filename, but the script can pass to a lisp the file name and run the correct sequence. You would create a lisp that has the sequence of commands as a defun a little mini program but you would have two programs 2436 and 3648. You would autoload this lisp or load as you open every dwg I am 100% with you on this Bigal. If you have something simple like a plot command I would use notepad and put all the prompts for the commands there in a row. But when it gets more complicated I write a lisp for it and a simple script to call this lisp : open dwg , load lisp , run lisp , save drawing , next... Quote
BIGAL Posted February 23, 2018 Posted February 23, 2018 Thanks Rlx There is another post here by Jord_91 similar theme, hopefully will be read. Quote
Jord_91 Posted February 23, 2018 Author Posted February 23, 2018 (edited) I'd like to understand and correct me if i'm wrong So i have to Load The lisp and then run the script? I complete the Lisp with my need but i'm not sure for the script because i have like 8 different values. Lisp Code: (defun c:2048 () (command _-view _Left "" "") (command "_ai_selall" "section" "_crossing" "0,0" "19-1/8,84" "" "0,4-1/2" "19-3/8,4-1/2" "26,8" "" "" "effacer" "_crossing" "0,0" "19-1/8,4" "" "" "") (command "_-view" "_top") (command "-INSERER" "C:/Users/jlarrivee/Desktop/pattes/2042OVA.dwg" "0,0,0" 1 1 0 ANNULER fin decompos "_last" "" "") (command "_save" "Y" "close") ) (defun c:2430 () (command _-view _Left "" "") (command "_ai_selall" "section" "_crossing" "0,0" "23-1/8,84" "" "0,4-1/2" "23-3/8,4-1/2" "26,8" "" "" "effacer" "_crossing" "0,0" "23-1/8,4" "" "" "") (command "_-view" "_top") (command "-INSERER" "C:/Users/jlarrivee/Desktop/pattes/2430OVA.dwg" "0,0,0" 1 1 0 ANNULER fin decompos "_last" "" "") (command "_save" "Y" "close") ) (defun c:2436 () (command _-view _Left "" "") (command "_ai_selall" "section" "_crossing" "0,0" "23-1/8,84" "" "0,4-1/2" "23-3/8,4-1/2" "26,8" "" "" "effacer" "_crossing" "0,0" "23-1/8,4" "" "" "") (command "_-view" "_top") (command "-INSERER" "C:/Users/jlarrivee/Desktop/pattes/2436OVA.dwg" "0,0,0" 1 1 0 ANNULER fin decompos "_last" "" "") (command "_save" "Y" "close") ) (defun c:2442 () (command _-view _Left "" "") (command "_ai_selall" "section" "_crossing" "0,0" "23-1/8,84" "" "0,4-1/2" "23-3/8,4-1/2" "26,8" "" "" "effacer" "_crossing" "0,0" "23-1/8,4" "" "" "") (command "_-view" "_top") (command "-INSERER" "C:/Users/jlarrivee/Desktop/pattes/2442OVA.dwg" "0,0,0" 1 1 0 ANNULER fin decompos "_last" "" "") (command "_save" "Y" "close") ) (defun mysize (dwgname / ) (setq stfile (substr dwgname 1 4)) (cond ((= stfile "2030)(2030)) ; check 4 characters and runs correct defun ((= stfile "2036)(2036)) ((= stfile "2042)(2042)) ((= stfile "2048)(2048)) ((= stfile "2430)(2430)) ((= stfile "2436)(2436)) ((= stfile "2442)(2442)) ((= stfile "2448)(2448)) ) ) and there's the Script open dwg1(if ( 2030 )(load "2030")) Then (Elseif ( 2036 )(load "2036")) Then (Elseif ( 2042 )(load "2042")) Then (Elseif ( 2048 )(load "2048")) Then (Elseif ( 2430 )(load "2430")) Then (Elseif ( 2436 )(load "2436")) Then (Elseif ( 2442 )(load "2442")) Then (Elseif ( 2448 )(load "2448")) Then (mysize (getvar "dwgname")) open dwg2 (if ( 2030 )(load "2030")) Then (Elseif ( 2036 )(load "2036")) Then (Elseif ( 2042 )(load "2042")) Then (Elseif ( 2048 )(load "2048")) Then (Elseif ( 2430 )(load "2430")) Then (Elseif ( 2436 )(load "2436")) Then (Elseif ( 2442 )(load "2442")) Then (Elseif ( 2448 )(load "2448")) Then (mysize (getvar "dwgname")) Sorry for my multiple posts, It's just because my needs had changed and I don't want people to be too confused. As I said before i may be completely wrong i'm trying to learn these but I'm a noob at the moment Edited February 23, 2018 by Jord_91 not exacly what i was looking for Quote
rlx Posted February 23, 2018 Posted February 23, 2018 nope , the script loads the lisp , just like bigal's example. the script file could look like : open dwg1 (load "mysize.lsp") (mysize) .qsave open dwg2 (load "mysize.lsp") (mysize) ,qsave etc etc... there are a few potential problems with this, both dwg and lisp must be in your searchpath or you must specify the full path. If dwgname contains spaces you must put the name in a string "c:/test/mydwg dwg1.dwg" , or use (findfile). Also all your (sub) functions must be in 1 file or you must load them each separately. gr. Rlx Quote
SLW210 Posted February 27, 2018 Posted February 27, 2018 Please read the Code Posting Guidelines and have your Code to be included in Code Tags, not QUOTE TAGS.[NOPARSE] Your Code Here[/NOPARSE] = Your Code Here Quote
Jord_91 Posted February 27, 2018 Author Posted February 27, 2018 Thanks, I'll make sure to use the proprer way to do the next time. 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.