Add calculator function to AutoCAD
When drawing with AutoCAD, it is often necessary to perform some necessary calculations. Although Autodesk provided a LISP program CALC.LSP that can be used for simple calculations with AutoCAD, the program was developed earlier and used under the COMMAND command. The interface is not intuitive and is not convenient to use. In this paper, through the study of the dialog box structure and AutoLISP in AutoCAD, a method of using the dialog box structure to implement the calculator function is proposed, and the program flow chart is also provided for your reference. This procedure has been applied to the actual work of our hospital.
1 Principles and methods AutoCAD dialog structure contains a variety of components, such as edit_box (edit box), text (text), button (button) and so on. Using these tools, a user-friendly utility can be developed. Figure 1 is implemented in this way. Arrange the numbers and various operation symbols in the calculator into 5 rows and 5 columns in the form of buttons, and display the calculation results in a dialog box as a text component to obtain the dialog box structure shown in Figure 1 (dialog box File # CAL.DCL). Finally, a driver program for displaying and completing various calculation functions in the dialog box can be prepared (driver program # CAL.LSP), and the program flowchart is shown in FIG. 2.
Various numerical calculation and variable conversion functions provided by AutoLISP are used in the # CAL.LSP program. It should be noted that during the debugging process, the author found that some functions have some special requirements on variables, which are now introduced as follows, to discuss with the reader:
1. In expt base power, the requirements for variables base (base) and power (power) are different from the power operation requirements in algebra. The requirements for variables base and power in algebra are as follows:
When base> 0, power can be any real number;
When base = 0, power must be greater than 0;
When base <0, power can be an integer, if it is a decimal or fraction, it is required that the denominator cannot be an even number when it is reduced to the simplest fraction.
However, when the variable base <0 in AutoLISP, power is only required to be an integer or a real number that is 0 after the decimal point, such as 2, -2.0, etc., otherwise you will get an error message or return an error result (depending on the power value and set). In addition, when the calculation result is too large and overflows, the FOR DOS version of AutoCAD will return 1.67e + 308, while the WINDOWS version will return 1.79769e + 308.
2. The sine and cosine functions (sin x) and (cos x) require that the variable x must be less than or equal to 9.223372e + 18 (of course, the number of decimal places can be extended), otherwise the correct result cannot be obtained. For example, when the variable is 9.223373e + 18, the FOR DOS version of AutoCAD returns NAN, while the WINDOWS version returns the variable value itself.
3. When using the function (rtos) to convert the data into a string, the author found that when the data is greater than 1e + 100 (that is, the 100th power of 10), the index 100 is automatically changed to 99. For example, after executing (rtos 6e + 100 2 6), you get "6.000000E + 99" instead of the expected "6.000000E + 100". Therefore, this procedure specifies that the maximum data cannot be greater than 1e + 99, otherwise an overflow error will be displayed. Of course, by compiling another conversion program, the maximum data can be increased to the maximum data that AutoCAD can accept (after testing, the maximum value can be 1.79769e + 308). Due to space limitations, this conversion function is no longer provided in this article, and the comrades in need can contact the author.
2 How to use the program Copy the program # CAL.LSP and dialog file # CAL.DCL to the directory that AutoCAD can find, and type (LOAD "#CAL") under the Command: command to load the program, just like other #CAL is also used for AutoCAD internal commands. You can also add the following line to the drop-down menu or on-screen menu part of the menu file used (such as ACAD.MNU): [calculator] ^ C ^ C ^ P (if (null c: #cal) (load " #cal ")) #cal Later you can drive the program directly from the menu.
The icons in the dialog box are similar to ordinary calculators, "C" means to clear, "M +" means to store the result, "MR" means to pop up the stored result, "sqrt" means to prescribe, "X ** y" means to ask power. When the input data is inappropriate or the calculation result overflows, an error message will be displayed in the dialog box.
This program has been debugged on AutoCAD R12.0 FOR DOS and FOR WINDOWS versions, but the graphics displayed in the WINDOWS version are slightly different from Figure 1.
The electrolyte material inside the Electrolytic capacitor, which has charge storage, is divided into positive and negative polarity, similar to the battery, and cannot be connected backwards.A metal substrate having an oxide film attached to a positive electrode and a negative electrode connected to an electrolyte (solid and non-solid) through a metal plate.
Nonpolar (dual polarity) Electrolytic Capacitor adopts double oxide film structure, similar to the two polar electrolytic capacitor after two connected to the cathode, the two electrodes of two metal plates respectively (both with oxide film), two groups of oxide film as the electrolyte in the middle.Polar electrolytic capacitors usually play the role of power filter, decoupling (like u), signal coupling, time constant setting and dc isolation in power circuit, medium frequency and low frequency circuit.Non-polar electrolytic capacitors are usually used in audio frequency divider circuit, television S correction circuit and starting circuit of single-phase motor.
Electrolytic capacitor
Electrolytic Capacitor,Aluminum Electrolytic Capacitor,High Voltage Electrolytic Capacitor,12V Electronic Components Capacitor
YANGZHOU POSITIONING TECH CO., LTD , https://www.yzpstcc.com