The hottest VisualLISP 3D cylindrical helix progra

  • Detail

Visual LISP 3D cylindrical helix program

Abstract This paper introduces the development of 3D cylindrical helix program with Visual LISP development tool in AutoCAD 2000, and gives the development program code and running results, as well as 3D spring and thread drawing examples

keywords Visual LISP 3D cylindrical helix

1. Introduction

among many AutoCAD development tools, AutoLISP is the simplest, most widely used and most user-friendly development tool. However, AutoLISP is only an interpreted language and cannot be encrypted. Visual LISP is fully compatible with the previous AutoLISP, and applies ObjectARX object-oriented technology and ActiveX technology, another development tool of AutoCAD, which makes the application developed by Visual LISP more powerful and runs faster, so as to truly become a development platform that developers can never use hard tools to clean industrial software. In this paper, the author uses Visual LISP in AutoCAD 2000 to develop the three-dimensional cylindrical helix program, and works with all the employees of aut company firmly around the company's theme and objectives. Combined with OCAD 2000 interactive drawing, the author can quickly draw three-dimensional threads and springs

2. Raising problems

when drawing 3D engineering drawings with AutoCAD 2000, the author often encounters the problem of drawing 3D cylindrical spiral lines such as threads and springs. In AutoCAD, there are many commands for drawing 3D lines, such as line, 3dpoly, spline and so on, but the lines that can be used as 3D extrusion paths are only the lines drawn by 3dpoly command, and the fitting items in them can not be used. Therefore, in order to ensure the accuracy of the dimension of the drawn three-dimensional cylindrical helix, a large amount of accurate data must be input to draw the required helix bit by bit, which is very troublesome. According to relevant information, the spiral line [1] is formed by arc approximation, but the thread drawn in this way cannot pass the assembly interference inspection. Because it is inconvenient to draw helix in AutoCAD, in order to solve this problem, the author compiles a lisp program to realize it. The program can realize the automatic drawing of cylindrical helix, which can not only be used to draw the spring helix and the thread line of thread. Parametric drawing can also be carried out

3. Drawing of cylindrical helix

3.1 mathematical model of cylindrical helix

* formation of cylindrical helix

cylindrical helix is the most widely used spatial curve in technology, and its formation is shown in Figure 1. When a moving point m moves in a straight line with constant velocity along the generatrix ab of the cylinder, and the generatrix rotates at constant angular velocity around the axis of the cylinder, the trajectory of point m is the helix of the cylinder

* mathematical model

when the axis of the cylindrical helix coincides with the Z axis of the coordinate system, the parameter equation of the moving point m (x, y, z) on the cylindrical helix is as follows:

x=rcos α

y=rsin α

z=±t1* α/(2 π)

in the parameter equation: R is the radius of the cylindrical surface, α Is the helix rise angle, T1 is the lead (that is, the distance that the moving point m rises along the axis direction when the bus AB rotates for one cycle), and the right rotation takes a positive sign, and the left rotation takes a negative sign

3.2 program block diagram


parameter r, T1, K assignment

give the base point coordinates

calculate the coordinates of X, y, Z points

draw the spiral line


3.3 program code

open AutoCAD2000 to enter the Visual LISP development environment, create a new file, and program code in the Visual LISP texter window

AutoLISP program code for drawing cylindrical helix is as follows:

; This program is using for drawing a hel "the development of the domestic new material industry has been plagued by a serious disconnect between R & D and utilization ix

(setq B1 (getpoint" please enter the base point ")

(setq R (getreal" radius r=: ")

(setq T1 (getreal" pitch t1=: ")

(setq K (getInt" segment number k=: ")

(setq n (getInt" circle number n=: ")

(setq ta (/(* 23.14159) k))

(setq J1 (/T1 K))

(setq a 0)

(setq jj 0)

(setq ii 0)

(command "ucs" "o" b1)

(command "3dpoly" (list r 0 0))

(repeat n

(repeat k

(setq jj (+ jj 1))

(setq a (+ ta a))

(setq x (* r (cos a)))

(setq y (* r (sin a)))

(setq z (* j1 jj))

(setq p2 (list x y z))

(command p2)


(setq ii (+ ii 1))

(setq z (* t1 ii))


(command "" )

the number of segments K is preferably 36 or a multiple of 36 (72). When drawing the spring, n is the total number of turns of the spring; When drawing the thread, if the length of the thread is l, then n=l/T1. Save this LISP program as "P".

when writing LISP program, you should pay attention to the correct input, brackets and spaces are essential, otherwise it will affect the trajectory of the helix.

3.4 program running result

load and run "P "In the program, first, a prompt appears on the command line of the AutoCAD2000 drawing window. After inputting the values of parameters R, T1, K and n according to the prompt, the spiral line is drawn.

4. Apply

* to draw the spring

change the coordinate system in the AutoCAD2000 drawing window and use" draw a circle " Draw the spring section with the command of, and then stretch the spiral line as the spring stretching path, and draw the support section with appropriate sectioning, as shown in Figure 5

the spring parameters we draw are as follows:

outer diameter d=14mm, d=1mm, pitch t=4mm, effective number of coils n1=10, number of supporting coils n2=2.5, right-hand rotation

* draw thread

if you use the "draw polygon" command to draw a triangular or rectangular section, and then stretch the helix as the thread stretching path. Then make appropriate trimming

5. Conclusion

(1) load and run the AutoLISP program of cylindrical helix in the Visual LISP development environment. After the command line of AutoCAD2000 drawing window, input different parameters according to the prompt, and you can draw the required three-dimensional cylindrical helix. Therefore, various 3D threads and springs can be quickly drawn parametrically

(2) previously, AutoLISP applications had to find another texter to write source code, and then return to AutoCAD to load and run, which was not convenient for program debugging. With Visual LISP integrated development environment, we can perform text, program debugging, interaction with AutoCAD and other applications in a separate environment, which greatly facilitates the secondary development of AutoCAD and meets the secondary development needs of technicians. (end)

Copyright © 2011 JIN SHI