Use AUTOCAD to automatically draw the centerline

Use AUTOCAD to automatically draw the centerline

AutoCAD is currently one of the most widely used CAD systems in China. AutoCAD is powerful and a universal CAD platform, but it is very inconvenient to use it if it is not secondary developed according to the needs of this major. Drawing a symmetrical centerline is a problem often encountered in mechanical design.

I used AutoLISP to develop two programs according to national standards, which can easily solve the problem of straight line centerline.

The first procedure is applicable when two sides are continuous straight lines. The method of use is to load GLS.LSP with the LOAD command, run C: GSL, and select the two sides respectively according to the screen prompts to automatically draw the center line.

GSL.LSP:

(defun mid (pt1 pt2) Function function to calculate the midpoint between two points

(setq pt (mapcar '+ pt1 pt2))

(setq pt (mapcar '/ pt' (2 2 2)))

)

(defun c: gsl / m cl1 cl cl2 e pt pt1 pt2 pt3 pt4 a) (SETQ M 1)

(WHILE M

(SETQ CL1 (ENTSEL "Select the first straight line"))

(cond

((not cl1) (prompt "No entity found"))

((/ = "LINE" (cdr (assoc 0 (setqe (entget (car cl1))))))

(prompt "The selected line is not a straight line")

)

(t (prompt "find the first straight line")

(setq m nil); exit the loop

)

)

)

(setq cl (ssget (nth 0 (cdr cl1)))); Get the entity data of the first line

(SETQ M 1)

(WHILE M

(SETQ CL2 (ENTSEL "Select the second straight line"))

(if cl2

(if (ssmemb (car cl2) cl)

(progn

(princ "select repeat, reselect")

(setq cl2 nil)

)

)

)

(cond

((not cl2) (prompt "No entity found or duplicate"))

((/ = "LINE" (cdr (assoc 0 (setq e (entget (car cl2))))))

(prompt "The selected line is not a straight line")

)

(t (prompt "Two straight lines have been selected")

(setq m nil) ;;; Exit the loop

)

)

)

;; Get the coordinates of the points on both ends of the first straight line

(setq pt1 (cdr (assoc 10 e)) pt2 (cdr (assoc 11 e)))

(setq e (entget (car cl1))) ;; Get the entity data of the second straight line

;; Get the coordinates of the two ends of the second straight line

(setq pt3 (cdr (assoc 10 e)) pt4 (cdr (assoc 11 e)))

; Adjust endpoint

(if (inters pt1 pt3 pt2 pt4 t)

(setq pt pt1

pt1 pt2

pt2 pt

)

)

;; Calculate the coordinates of the midpoints at both ends

(setq pt1 (mid pt1 pt3))

(setq pt2 (mid pt2 pt4))

(setq a (angle pt1 pt2)); calculate the inclination of the centerline

(setq pt2 (polar pt2 a 2.5)); calculate the first endpoint of the centerline

(setq pt1 (polar pt1 (+ pi a) 2.5))

(command "layer" "SET" 5 ""); Set the centerline layer

(command "line" pt1 pt2 ""); draw the center line

)

(princ "C: GSL has loaded")

(Princ "for symmetry line")

(princ)

The second procedure is applicable to various situations such as stepped shafts and stepped holes. The method of use is to load GLS1.LSP with the LOAD command, run C: GSL1, and select the endpoints on both sides according to the prompts on the screen to automatically draw the center line.

GSL1.LSP

(defun mid (pt1 pt2)

(setq pt (mapcar '+ pt1 pt2))

(setq pt (mapcar '/ pt' (2 2 2)))

)

(defun c: gsl1 (/ p1 p1 p3 p4 a)

; Save environment variables

(setq os (getvar "osmode"))

(setq cm (getvar "cmdecho"))

;; Set environment variables

(setvar "osmode" 33)

(setvar "cmdecho" 0)

;; Read the end points of two straight lines in turn

(initget 1)

(setq p1 (getpoint "select the first point of the first line"))

(initget 1)

(setq p2 (getpoint "select the second point of the first line"))

(initget 1)

(setq p3 (getpoint "select the first point of the second line"))

(initget 1)

(setq p4 (getpoint "select the second point of the second line"))

;;;; Restore environment variables

(setvar "osmode" os)

(setq p1 (mid p1 p3))

(setq p2 (mid p2 p4))

(setq a (angle p1 p2))

(setq p2 (polar p2 a 2.5))

(setq p1 (polar p1 (+ pi a) 2.5))

(command "layer" "set" 5 "")

(command "line" p1 p2 "")

)

(princ "C: GSL1 has loaded")

(Princ "for symmetry line")

(princ)

Ni-Mh Battery is a kind of long shelf life battery ,it has high capacity and large current ,which can replace traditional dry cells ,take examples as below :

* This is high performance rechargeable Lithium Ion battery with instantaneous start up;

* Durable high impact plastic housing;

* High capacity, performance verified, hermetically sealed, lithium-ion cells;

* Protection against short circuit and improper charge;

* High reliability due to all welded Construction;

* Unit contains safety vented cells;

* 100% final testing;

* Replacement battery for Tait Orca 5000/5010/5020/5030 series two way radios.

•

Item                               Specification

Chemistry:                     Ni-MH

Voltage:                         Typical: 7.4V

Nominal Capacity:        2000mAh at 400mA to 6V at 23℃

Operating Temp:        -20 to +55 ℃

Storage Temp:            -30 to +45 ℃

Exterior/Housing:       Hard Plastic Case


APPLICATIONS:

* Tait Cougar 400; M A-Com Cougar 400;  M A-Com Cougar 6000P;  M A-Com Cougar 625P;  M A-Com Panther 400;  M A-Com Panther 600;  Tait Orca 5000; Tait Orca 5010; Tait Orca 5020; Tait Orca 5030; Tait Orca 5035; Tait Orca 5040;  GE, Ericsson Cougar 400; GE, Ericsson Cougar 6000P; GE, Ericsson Cougar 625P;  GE, Ericsson Panther 400; GE, Ericsson Panther 600.



Ni-Mh battery



Ni-MH Battery

Ni-Mh Battery,Rechargeable Ni-Mh Battery,Ni-Mh Rechargeable Battery,Ni-Mh Universal Battery

YFJ TECHNOLOGY (HK) CO.,LIMITED , http://www.yfjpower.com