Jump to content
wannabe

WTD: Script Tutorials & Examples

Recommended Posts

wannabe

Would be keen to spend a bit of time learning about scripts and what they are used for by other people.

 

Does anyone have one already or fancy doing one(tutorial)?

 

I currently have a couple of examples, but nowhere near an in-depth knowledge; which is what I may be aiming for if I can ascertain that it would be worthwhile.

 

cheers.

Share this post


Link to post
Share on other sites
ReMark

Start learning about scripts right here at CADTutor.

 

At the top of the screen click on Tutorials...AutoCAD...Techniques. Page down to the section titled Perspectives, Slides and Scripts.

Share this post


Link to post
Share on other sites
ReMark

wannabe: Do you know how I found all these links (plus many others)? I used Google. I conducted a search using the following keywords (include the quotation marks and the plus signs):

 

"autocad"+"script"+"tutorial"

 

The key to getting good useful information from any search engine, without getting overwhelmed by a lot of junk, is to conduct a search on specific words and/or combinations of words. Now that you know my trick go out and discover some of your own links to the topic at hand. There is a wealth of information out there and it is right at your fingertips. Be the Internet equivalent of Indiana Jones and find the treasure. Happy hunting.:)

Share this post


Link to post
Share on other sites
wannabe

Indeed, Google does provide many, many links. Whereas a recommendation from a CADTutor member holds more weight, relating to CAD, than anything Google will.

 

Plus, with this information available on this site, I think whoever contributes to this thread will be doing more than just me a favour.

 

Thanks for your time.

Share this post


Link to post
Share on other sites
ReMark

You're entirely welcomed.

 

We pick and choose what has meaning to us alone. My choices may not be the same as yours. I don't confess to be more CAD knowledgeable than any other forum member here including yourself. I do feel I have a certain knack for "finding" things (said with some humility). With that said, I hope the links provide you with a good starting point for your interest in scripts and their use. I'll be counting on you in the future to be our source of script knowledge.:) See you around I hope.

Share this post


Link to post
Share on other sites
wannabe
A link to CAD-Manager.com hosted by Robert Green.Page down to the section titled "Scripting Made Simple".

 

http://www.cad-manager.com/archives/category/code

 

 

This one seems to be the best IMO for getting a basic understanding.

 

Maybe I should post in general and ask people for some examples of scripts they use.

Share this post


Link to post
Share on other sites
ReMark

You might also want to check the AutoDesk and AUGI websites too.

Share this post


Link to post
Share on other sites
ReMark

Scripts can be used to:

 

- Batch recover files

- Automate software installation

- load ARX files

- batch process drawings

- remove hyperlinks from a drawing

- add preview images to earlier releases of AutoCAD

 

These and other tasks can be accomplished using the Scriptpro Utility available at:

 

http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=4091678&linkID=9240618

 

Here is what AutoDesk has to say about Scriptpro:

 

"ScriptPro takes AutoCAD scripting to a new level with an easy-to-use interface, logging, reusable project files, enhanced scripting with new keywords and utilities, and robust error recovery. Using ScriptPro, you can apply a set of commands to multiple drawings by simply specifying a script file and the list of drawings that you would like to apply the script to".

Share this post


Link to post
Share on other sites
ReMark

If you haven't already, I strongly recommend that you join AUGI the AutoDesk Users Group International. Membership is free. By doing so you'll have access to their forums and a host of educational material. Included in the latter is a handout from AutoDesk University written by Daniel Abbott entitled, "Super Scripting Secrets." To locate this handout click on the word Education at the top of the first AUGI webpage. Then click on AU Class Handouts on the drop-down menu. At the next screen you're prompted to indicate both the Year and the Industry. Your selections should be 2001 and Customization & Programming respectively. On the next page you're taken to page down until you get to the handout previously mentioned. Handouts can be downloaded to one's computer for later reading.

 

I would also suggest you check out entries under other years listed using the same Industry catagory as there may have been other class handouts about working with scripts. You can skip year 2000 as there aren't any (I checked that first).

 

I think you have enough to work with given the information I have provided in this post and the one previous to it. Good luck and happy scripting.

Share this post


Link to post
Share on other sites
dbroada

I've come here as I spotted "the other" thread. I don't get this far down very often.

 

Trying to say what a script is used for is a bit like asking what LINE is used for. It is another VERY useful AutoCAD process that few people have ever used. It is basically a series of commands entered from a text file as though you had typed them directly at the command line.

 

my 2 most recent....

ucs
z
90
plan
c
grid
nsmnsd
resume

and

ucs
w
plan
c
grid
off

I was drawing a group of flow diagrams and these just turned the page through 90 degrees and back again.

 

and one to launch a VBA royine to combine 2 DXF files into a single drawing file. This is part of a VB program to create hundreds of similar drawings by linking to a database for the variations.

sdi
1
new
acadiso
vbastmt
DxfImport("H:\Design_Office\E277\Loops\22-IBTSCS2\Output\E277-22-LD001-384_0.dxf")
vbastmt
DxfImport("H:\Design_Office\E277\Loops\22-IBTSCS2\Output\E277-22-LD001-384_1.dxf")
saveas
2007
"H:\Design_Office\E277\Loops\22-IBTSCS2\Output\E277-22-LD001-384"
resume

 

I would also use a script to insert an issue box into a drawing, to update blocks with a new definition or to batch plot a series of drawings.

 

Already the best kept secret of AutoCAD, they may now die out as AutoCAD 2009 comes with a macro recorder which may do all most people want from scripts. I will look when we install or update. :)

Share this post


Link to post
Share on other sites
ReMark

Dave: That's a good point regarding the Macro Reader. New for 2009 right?

Share this post


Link to post
Share on other sites
dbroada
Dave: That's a good point regarding the Macro Reader. New for 2009 right?
Yes. Its a bit more versitile than scripting in that you can put pauses for operator intervention. If you have to do the same thing to a LOT of files then scripting will still win. If you have to do similar tasks often the recorder may win.

 

I haven't tried it yet but did see it demo'ed.

Share this post


Link to post
Share on other sites
dbroada

and another thing, a big problem with scripting is that there is no error trapping. If the command sequence is unusual for any reason then your script will fall over. It will keep reading the next line of the script file until a suitable command is given and then continue from where there. This will usually happen at the point of maximum devastation.

Share this post


Link to post
Share on other sites
ReMark

So Dave, your suggestion would be to test out a script, maybe more than once, to see if it works as intended or bombs part way through?

Share this post


Link to post
Share on other sites
dbroada

from personal experience YES!!!

 

there are a few "gotchas" too. Once that had me confused for a very long time is.....

you know if you print a file AutoCAD thinks the drawing has changed so before you open another file you get "Do you want to save changes?". From the command line the answer would be "N", but in script you are asked "Do you want to discard changes?" and you need to answer "Y".

 

Normally if things go wrong AutoCAD will look through the rest of the script but not find a suitable answer. The problem comes when there is an appropriate answer, but one to a different question.

 

I will normally "write" my script while typing at the keyboard and then try it on another drawing before letting lose on many. I don't always test them as confidence in my ability is greater than it should be. I will test critical ones though, often on copies first.

Share this post


Link to post
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.   Paste as plain text instead

  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.


×
×
  • Create New...