您好,我正在尝试将一个旧帖子中的hanhphuc lisp转换为从像照片一样的直线垂直距离创建一个点。有人能帮我吗?
- (defun c:test (/ os asin _line p1 p2 d2 l1 ad d ok p ang d3 dir ip )
- ; hanhphuc 25.02.2015
- (COMMAND "_layer" "_m" "new_point" "_c" "10" "" "")
- (setvar 'pdmode 35)
- (setq os (getvar 'osmode)
- asin '((x) (atan (/ x (sqrt (+ 1.0 (* x (- x)))))))
- _line '((a lst) (foreach x lst (entmake (list '(0 . "LINE") (cons 10 a) (cons 11 x)))))
- ) ;_ end of setq
- (setvar 'osmode 1)
- (if (and (setq p1 (getpoint "\nPick point A: "))
- (setq p2 (getpoint p1 "\nPick point B: "))
- (setq d2 (getdist p2 "\nInput perpendicular length: "))
- (setq l1 (list p1 p2)
- ad (mapcar ''((x) (apply x l1)) '(angle distance))
- d (cadr ad)
- ok (< d2 d))
- (setq p (getpoint "\nPick side to draw.. "))
- ) ;_ end of and
- (progn (setq ang (asin (/ d2 d))
- d3 (* d (cos ang))
- dir (car ad)
- ip (apply 'if
- (vl-list*
- (minusp (- (* (- (cadr p) (cadr p1)) (cos dir)) (* (- (car p) (car p1)) (sin dir))))
- (mapcar ''((f) (polar p1 ((eval f) dir ang) d3)) '(- +))
- ) ;_ end of vl-list*
- ) ;_ end of apply
- ) ;_ end of setq
- (_line ip l1)
- ) ;_ end of progn
- (if (not ok) (alert "Perpendicular line exceeds length of A to B!") )
- ) ;_ end of if
- (setvar 'osmode os)
- (command "setvar" "clayer" "0")
- (princ)
- ) ;_ end of defun
谢谢
|