Jump to content

Run a Script (.scr) on multiple file


Jord_91
 Share

Recommended Posts

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!:unsure:

Thanks to every one!

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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 :unsure: :)

Edited by Jord_91
not exacly what i was looking for
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...