TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Guest on September 18, 2007, 01:15:59 PM

Title: Launch ACAD and run script
Post by: Guest on September 18, 2007, 01:15:59 PM
I know you can use a switch in the shortcut to run a script upon startup, but I was wondering if you can do it using STARTAPP (or some VLispy-type o' code).  I.E.  (startapp "C:\\CADD\\AMEP2008\\acad.exe").
Title: Re: Launch ACAD and run script
Post by: deegeecees on September 18, 2007, 01:31:19 PM
Do you want to run it only when AutoCad starts, or with every drawing?
Title: Re: Launch ACAD and run script
Post by: Guest on September 18, 2007, 01:35:46 PM
Here's what I was thinking....

Use STARTAPP to launch a session of ACAD.  Once that session is done loading, run a script.  This script will in turn open multiple drawings and do something to each one.
Title: Re: Launch ACAD and run script
Post by: deegeecees on September 18, 2007, 01:40:41 PM
From a stand alone VB app, or within a session of AutoCad?

With my limited knowledge, I'm not sure if I'd use ODBX, or a batch process. I don't have full blown VB here at work, and my "Student" copy is fairly old, so I'll just go on record as saying...

...hmmm...
Title: Re: Launch ACAD and run script
Post by: Guest on September 18, 2007, 01:43:15 PM
From a stand alone VB app, or within a session of AutoCad?

From LSP.
Title: Re: Launch ACAD and run script
Post by: Keith™ on September 18, 2007, 01:45:01 PM
You can't run lisp unless you have AutoCAD open .. so I would have to question the need to open AutoCAD if it is already open.
Title: Re: Launch ACAD and run script
Post by: deegeecees on September 18, 2007, 01:47:15 PM
Well I've posted this before, but in lew of searching for it, I'll post it here. In spite of it's ugliness, this has worked for me for years.

Code: [Select]
(DEFUN C:batch_anything ()

;;;;;;;;;;;;;;;;;;;;;;;;;Select directory to be processed

(setq dfil (getfiled "Select A File In The Directory You Want To Batch Process" "p:/" "dwg" 0))
(setq wutdir (vl-filename-directory dfil))
(setq wutfiles (vl-directory-files wutdir "*.dwg"))

(setq scrfile (open "c:\\scrfile.scr" "w"))
(close scrfile)
(setq scrfile (open "c:\\scrfile.scr" "a"))

(foreach n wutfiles
(setq n2 (strcat "\""wutdir "\\" n "\""))
(setq n2 (vl-string-translate "\\" "\\" n2))
(setq scrline (strcat "open" " " n2 " " "(load\"batch_core\")" " " "batch_insert" " " "qsave" " " "close"));;;;;;;COMMANDS FOR BATCH GO HERE
(write-line scrline scrfile)
(princ)
)

(close scrfile)
(command "script" "c:\\scrfile")

(princ "\n***Batch complete.***")
(princ)


);;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;DEFUN

This works from an open AutoCad session.
Title: Re: Launch ACAD and run script
Post by: Kerry on September 18, 2007, 06:46:05 PM

Matt, have you tried ScriptPro ?
http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=4091678&linkID=9240618
Title: Re: Launch ACAD and run script
Post by: Guest on September 19, 2007, 08:30:34 AM

Matt, have you tried ScriptPro ?
http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=4091678&linkID=9240618

No, I haven't, and I doubt I'll be able to get the IT geeks to download and install it for me.  Have you used it before?  One thing that caught my eye was the "robust error recovery".  How does this work?  If it encounters an error in a drawing, will it skip that drawing and move on to the next??

I'll see if I can scrounge up some jelly donuts to bribe the geeks.  :wink:
Title: Re: Launch ACAD and run script
Post by: Guest on September 19, 2007, 08:33:03 AM
You can't run lisp unless you have AutoCAD open .. so I would have to question the need to open AutoCAD if it is already open.

1) It was a curiosity thang and
2) I was just trying to eliminate the need for some people here to have to think.  Because we all know how some people can't grasp even the simplest of concepts.  We all have at least one of those people in the office - well, except for Josh - they just got rid of theirs!