Drawing polylines defined by equations
The easiest way to resolve this problem is to use the Microsoft Excel and Word programs to create an AutoCADĀ® script file (.scr file extension) to draw a polyline that represents the equation.
Procedure 1 (in Excel)
Note: If you do not have Excel, you can use another spreadsheet application, but you might need to adapt these instructions.
- Create a new workbook (XLS file).
- In cell A1, enter -5, which is the smallest x value.
In this example the smallest x value is -5, because you are working within the bounds x=-5 and x=5. - Enter the formula =a1+.1 in cell A2, where .1 is the incremental step.
- Copy cell A2 down the A column until the value equals the largest x value.
In this example, the largest x value is 5 at row 101. Column A should now contain values from -5 to 5 in 0.1 increments. - Enter a comma (,) in cell B1 and copy it down column B until you reach the last value in the A column at row 101.
- Enter the following formula in cell C1, replacing x with A1 as shown, and then copy the formula down column C until you reach the last value in the A column at row 101.
=A1^3+2*A1^2-11*A1-12
At this point you should have values/formulas in all cells in the range A1:C101, as shown in the following table:
Column A
|
Column B
|
Column C
| |
Row 1
|
-5
|
,
|
=A1^3+2*A1^2-11*A1-12
|
......
|
......
|
......
|
......
|
Row 101
|
5
|
,
|
=A101^3+2*A101^2-11*A101-12
|
Note: For clarity, formulas from column C are shown; cells usually show the results of formulas, not the formulas themselves.
7. Select all cells in the range A1:C101 and press CTRL+C to copy the selection to the Clipboard.
8. Save the file if you want to, and then exit Excel.
Procedure 2 (in Word)
Note: If you do not have Word, you can use another word processing application, but you might need to adapt these instructions.
- Start Microsoft Word and create a new document.
- At the beginning of the first line, enter pline, and then move the cursor to the beginning of the second line.
- On the Edit menu, click Paste Special and paste the cells from Excel using the Unformatted Text option.
The Unformatted Text option pastes the data from the cells as text, rather than with table formatting. The pasted value from line 2 is shown in the following example.
-5.0 , -32.0
The spaces between the numbers and the comma are tabs. You need to remove the tabs because they cannot be used in a script file. - On the Edit menu, click Replace.
- In the Find and Replace dialog box, enter ^t in the Find What box and ensure the Replace With box is empty.
- Click Replace All.
Word recognizes ^t as a tab character; with the tabs removed, the pasted values should look like the following example, which is from line 2:
-5.0,-32.0 - Save the file: Set the Save As type field (Save As dialog box) to MS-DOS Text (*.txt) and use the file name eq.scr.
Important: The script will not work unless you save the file as MS-DOS Text (*.txt). - Exit Word.
You can now start the Autodesk software and run the eq.scr script using the SCRIPT command.
If you need to turn the polyline created by the script into a solid, draw the extra polylines and join them together using the PEDIT command to form a closed polyline. You can then use the REGION command to create the solid (note that you cannot create regions in AutoCAD LTĀ® software).
Note: The line between the calculated points is an approximation of the curve. The smaller the step increments, the higher the accuracy of the approximation to the equation.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home