Presentation on theme: "AUTOLISP DRAWING (continued)"— Presentation transcript:
1AUTOLISP DRAWING (continued) LESSON 6AUTOLISP DRAWING (continued)In this lesson we will continue drawing the cylinder liner and end up with the drawing below.
2As you will recall the top profile had been drawn and we can name it <TopProfile> The new code will continue in this space. We will first “HATCH” the top profile
3Last minute note !You should put a zoom command before the hatch process so that selection occurs.(command "_zoom" "Extents")The hatch command(command "hatch" "ANSI31" "20" "0" TopProfile "")has the following parametershatch pattern type <ANSI31> (/////)The size of the hatch <20> (appropriate for this drawing)Angle of hatch <0> (default 45 degrees to the right)Selected object(s) <TopProfile>Return <“”> (to stop selecting objects)
4The liner side profile will be drawn by 2 rectangles (one in the other). Therefore the 2 corners of the outer rectangle are set to the variables <R1C1> and <R1C2>2 corners of the inner rectangle are set to the variables <R2C1> and <R2C2>
5Let us take a closer look at <R1C1> The “x” component is aligned with the end of the outer arc (p1)Therefore the “x” component is set to (car p1)The “y” component is lowered by a distance of (R1/2) from p1Thefore the “y” component is set to (- (cadr p1) (/ R1 2))Second component of p1(R1/2)
6Let us take a closer look at <R1C2> The “x” component is (2 x R2) to the right from <R1C1>Therefore the “x” component is set to (+ (car R1C1) (* R2 2))The “y” component is lowered by a distance of H from R1C1Thefore the “y” component is set to (- (cadr R1C1) H)Second component of R1C1
7After <R1C1> and <R1C2> are defined the rectangle is drawn by (command "rectangle" R1C1 R1C2)After drawing the rectangle assign it to the variable <Rectangle1> by selecting the “last” entity and assigning it.(ssget “L”)(setq Rectangle1 (ssget "L"))
8Do the same for <Rectangle2> and then “hatch the area between them by selecting the outer rectangle and then the inner rectangle(command "hatch" "ANSI31" "20" "0" Rectangle1 Rectangle2 "")
9DIMENSIONINGOnly “LINEAR” dimensioning will be covered. The “DIM” command turn on the dimensioning mode. The “exit” command will end the dimensioning mode. There are various SYSTEM VARIABLES about dimensioning. These can be set during the dimensioning mode. For example the following can be set ;(command "dim")(command "dimasz" "5") (sets the arrow head size)(command "dimtxt" "5") (sets the text height)(command "dimdec" "1") (sets the decimal digits)(command "dimexo" "5") ( sets the extension line gap)(command "exit")
10Add the general dimension variables in unit <GLOBAL>
11R1C1(command "dim" "aligned" d1 d2 "A" "90" d3 "" "exit")Computes and writes the distance between d1&d2d3 is the position of the dimension to the right of the points d1&d2"A" "90“ turns the dimension text by 90 deg.d1d3d2R1C2
12(command "dim" "aligned" d1 d2 d3 "" "exit") Computes and writes the distance between d1&d2d3 is the position of the dimension to the top of the points d1&d2d3d2d1
13(command "dim" "aligned" d1 d2 d3 "" "exit") Computes and writes the distance between d1&d2d3 is the position of the dimension to the bottom of the points d1&d2d1d2d3
14This is what you should see when you press the <Plan> button
15Now I would like to talk about the technique I used. Open Delphi and run ME426 and run AutoCad from within the program.Go to <start>..<program>..<accessories>..and open <notepad>Open <sample.lsp> in the <project> directoryWrite in <start>..<run> the following directive c:\Progra~1\Autoca~1\ACAD.EXE /b c:\me426\project\sampleWrite the code in <Sample.lsp> and then save itClose <AutoCad> with <no save>Press <start>..<run>..OKAfter finishing and testing the drawing (steps 5-6-7) <copy – paste> the new lines from <sample.lsp> into your <Delphi Program>Add < Writeln(F,’ > to the beginning and < ‘); > to the end of these newly inserted lines.
16WHAT IF YOUR DRAWING HAS AN ERROR ? When AutoCad is open right click on the command line and click on <Copy History>Press <start>..<program>..<accessories>..<NotePad>Right click in <NotePad> and click on <paste>Examine the fault and switch to <sample.lsp>Make changes in <sample.lsp> and go thru steps 5 – 6 – 7 on the previous page.