lesson 6 autolisp drawing (continued) in this lesson we will continue drawing the cylinder liner and...

16
LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below.

Upload: nicole-buckels

Post on 14-Dec-2015

232 views

Category:

Documents


9 download

TRANSCRIPT

Page 1: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

LESSON 6AUTOLISP DRAWING (continued)

In this lesson we will continue drawing the cylinder liner and end up with the drawing below.

Page 2: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

As 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

Page 3: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

The hatch command (command "hatch" "ANSI31" "20" "0" TopProfile "")has the following parameters •hatch 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)

Last minute note ! You should put a zoom command before the hatch process so that selection occurs.(command "_zoom" "Extents")

Page 4: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

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

Page 5: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

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

Page 6: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

Let 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

Page 7: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

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

Page 8: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

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

Page 9: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

DIMENSIONING

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

Page 10: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

Add the general dimension variables in unit <GLOBAL>

Page 11: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

d1

R1C1

R1C2d2

d3

(command "dim" "aligned" d1 d2 "A" "90" d3 "" "exit")

1. Computes and writes the distance between d1&d2

2. d3 is the position of the dimension to the right of the points d1&d2

3. "A" "90“ turns the dimension text by 90 deg.

Page 12: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

d1

d2

d3

(command "dim" "aligned" d1 d2 d3 "" "exit")

1. Computes and writes the distance between d1&d2

2. d3 is the position of the dimension to the top of the points d1&d2

Page 13: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

d1 d2

d3

(command "dim" "aligned" d1 d2 d3 "" "exit")

1. Computes and writes the distance between d1&d2

2. d3 is the position of the dimension to the bottom of the points d1&d2

Page 14: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

This is what you should see when you press the <Plan> button

Page 15: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

Now I would like to talk about the technique I used.1. Open Delphi and run ME426 and run AutoCad from within the

program.2. Go to <start>..<program>..<accessories>..and open <notepad>3. Open <sample.lsp> in the <project> directory4. Write in <start>..<run> the following directive c:\Progra~1\

Autoca~1\ACAD.EXE /b c:\me426\project\sample5. Write the code in <Sample.lsp> and then save it6. Close <AutoCad> with <no save>7. Press <start>..<run>..OK8. After finishing and testing the drawing (steps 5-6-7) <copy –

paste> the new lines from <sample.lsp> into your <Delphi Program>

9. Add < Writeln(F,’ > to the beginning and < ‘); > to the end of these newly inserted lines.

Page 16: LESSON 6 AUTOLISP DRAWING (continued) In this lesson we will continue drawing the cylinder liner and end up with the drawing below

WHAT IF YOUR DRAWING HAS AN ERROR ?

1. When AutoCad is open right click on the command line and click on <Copy History>

2. Press <start>..<program>..<accessories>..<NotePad>

3. Right click in <NotePad> and click on <paste>

4. Examine the fault and switch to <sample.lsp>

5. Make changes in <sample.lsp> and go thru steps 5 – 6 – 7 on the previous page.