Escolar Documentos
Profissional Documentos
Cultura Documentos
Scripts
Introduction
ASCII Text File Commands You Can Type at Command Line Not Aliases Commands and Options Lisp Code AutoLISP Functions and Commands Other Scripts Open Dialog Boxes: SAVE~ Limitations: No User Input
2006 Autodesk
Writing Scripts
Special Script Functions:
Backspace key RESUME ; DELAY RSCRIPT Space in line New line
Pauses a script Resumes a paused script Remark within a script Delays the next step a specified time Repeats the script when done Enter key Enter key
2006 Autodesk
Writing Scripts
File Format
All
Separate Save
2006 Autodesk
in drawing in Registry
Extract Block Attributes Make Slides and Run Slide Show Edit Unlimited Number of Drawings
2006 Autodesk
Simple Script
Layer New fl1,fl1-dim,fl1-txt Color 2 fl1 Color 3 fl1-dim Color 4 fl1-txt
2006 Autodesk
2006 Autodesk
Setup Script
LAYER New obj,hid,cen,txt,dim Color 1 hid Color 3 cen Color 4 txt Color 5 dim L hidden hid L center cen S obj STYLE romans romans 0 1 0 N N N APERTURE 5 ATTDIA 1 AUNITS 0 AUPREC 1 BLIPMODE 0 CECOLOR bylayer CELTSCALE 1 CELTYPE bylayer CMDDIA 1 CMDECHO 1 CURSORSIZE 5 DRAGMODE A ELEVATION 0 EXPERT 0 FACETRES 1 FILEDIA 1 FILLETRAD 0 GRIPCOLOR 5 GRIPHOT 1 GRIPS 1 GRIPSIZE 3 HIGHLIGHT 1 LTSCALE 1 MBUTTONPAN 1 MIRRTEXT 0 OSMODE 4133 PELLIPSE 0 PICKADD 1 PICKAUTO 1 PICKBOX 3 PICKFIRST 1 PICKSTYLE 1 PLINEGEN 1 PSLTSCALE 1 SAVETIME 15 SDI 0 SORTENTS 23 THICKNESS 0 UCSICON off UCS w UCSVP 1
2006 Autodesk
Bench-Testing Computers
TIME R BOX 0,0 10,10,10 SPHERE 5,5,5 5 SUBTRACT NON 0,0 L VPOINT 1,-1,1 SLICE L 5,0 5,5 5,5,5 -1,0 3DARRAY L R 4 4 4 10 10 10 ZOOM ALL HIDE VPORTS 4 CVPORT 5 UCS X 90 PLAN C CVPORT 4 UCS W PLAN C CVPORT 2 UCS X 90 UCS Y 90 PLAN C TILEMODE 0 ERASE ALL MVIEW R F MSPACE CVPORT 3 SOLPROF ALL Y Y Y CVPORT 4 SOLPROF ALL Y Y Y CVPORT 5 SOLPROF ALL Y Y Y CVPORT 6 SOLPROF ALL Y Y Y TIME
2006 Autodesk 10
Automatically Updating Drawing Script Files Batch Files Lisp Files Batch-Editing Drawings
11
Introduction
Automatically Updating Multiple Drawings Possibilities:
Reducing file size of all drawings in a directory Replacing existing title blocks with a new one Creating drawing files from existing block definitions Adding attributes to existing block definitions Redefining existing block definitions Extracting attribute information into a text file Repathing all XRefs and images to relative Almost anything elseif you know a little AutoLISP
2006 Autodesk
12
2006 Autodesk
13
Two Cautions!
Try Out Programming in Small Pieces on a Test File
Does the script do what you want it to? Does the Lisp do what you want it to? Does the batch file work with a small group of files?
Back up your original files Make NEW files with this process Dont delete the originals until youre done Place new drawings in their own directory
2006 Autodesk
14
Background - Scripts
Create with Notepad or WordPad Save with an .SCR Extension, NOT .txt You may have to quote filename myscript.scr A Script Can Run on Startup Using the Switch /b Scripts Contain Command-Line Input Try out commands at the command line Use a dash with commands, like -LAYER, -INSERT Turn FILEDIA off to try options of SAVEAS AutoCAD Can Open a Drawing on Startup AutoCAD 2007\acad.exe "path\drawing name"
2006 Autodesk 15
2006 Autodesk
16
2006 Autodesk
18
Example One
Reducing Archive File Sizes
19
2006 Autodesk
20
2006 Autodesk
21
2006 Autodesk
22
page 5
2006 Autodesk
23
2006 Autodesk
24
2006 Autodesk
25
Example Two
Updating a Title Block
26
2006 Autodesk
28
2006 Autodesk
29
2006 Autodesk
30
Example Three
Creating Drawings from Block Definitions
31
2006 Autodesk
32
2006 Autodesk
33
2006 Autodesk
36
Future Considerations
These Programs Were Simplified as Much as Possible Add Documentation to Each File ; before documentation lines in script files REM before documentation lines in batch files ; before documentation lines in Lisp files Use VLISP for Creating Lisp Programs Add Error-Trapping to All Lisp Programs
2006 Autodesk 37
Error-Trapping Example
(defun da_error (msg) (command) (setvar "aperture" ap) (setvar "osmode" os) (setq *error* old_error) (alert "Returning drawing to original status.") ) (defun C:MID (/ p1 p2 old_error) (setq old_error *error*) (setq *error* da_error) etc.
2006 Autodesk 38