Refining the Macro
This macro has been kept as simple as possible to show the principles and to give you as little typing as possible. The standard parts data that you store in text files can be for simple parts (such as washers, gaskets, and studs), or very complex parts (such as mechanical seals and piston assemblies). The principles are the same.
Even for drawing spigots, the macro is very crude. Here are some obvious improvements:
In our macro, P1 and P2 must be digitized in the correct order so the macro knows the correct attitude of the spigot. If you digitize the points in the wrong order, the spigot is drawn as a mirror image of the correct position (try it!). You can rewrite the macro so that the user must digitize a third point (for example, a point at the bottom of the hole), so that the macro knows the attitude of the hole.
For a spigot, we need a friction fit, so the diameter of the spigot is the same as the diameter of the hole. In cases where a loose fit is required, the macro must be able to centralize the item in the hole.
In our file spigot.dat, each data item consists of two digits, and the data is arranged with only one blank between each data item. Normally, tabular data items will have different lengths and each column will be right-justified. So, there will be a varying number of blanks between each data item. Your macro must allow for this.
In the case of our simple spigot, there was only one row of data for each value of D1. If you have several rows of data for each value of D1, (for example, several values of D2 for each value of D1), you must add a loop within a loop to search for the required value of D2.
In the case of P1 and P2 it is assumed that the value of (P1-P2) corresponds to a value of D1 in the file spigot.dat. If the user inputs two points P1 and P2 that do not meet the condition the loop will be executed until the string END-OF-FILE is read. Further execution will be stopped. To allow for this situation you should add a line that exits the loop if END-OF-FILE is read and displays a message to tell the user that the input was incorrect.
Was this helpful?