|
(defun c:3pr nil (3p-rec nil)) ;; Standard version
(defun c:3prd nil (3p-rec t )) ;; Dynamic version
;;----------------------------------------------------------------------;;
(defun 3p-rec ( dyn / *error* gr1 gr2 len lst msg ocs osf osm pt1 pt2 pt3 pt4 pt5 pt6 str tmp vec )
(defun *error* ( msg )
(LM:endundo (LM:acdoc))
(if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*"))
(princ (strcat "\nError: " msg))
)
(redraw) (princ)
)
(if
(and
(setq pt1 (getpoint "\nSpecify 1st point: "))
(setq pt2 (getpoint "\nSpecify 2nd point: " pt1))
(or dyn (setq pt3 (getpoint "\nSpecify 3rd point: " pt1)))
(setq vec (trans (mapcar '- pt2 pt1) 1 0 t)
ocs (trans '(0.0 0.0 1.0) 1 0 t)
pt4 (trans pt1 1 vec)
pt5 (trans pt2 1 vec)
)
(if dyn
(progn
(setq osf (LM:grsnap:snapfunction)
osm (getvar 'osmode)
msg "\nSpecify 3rd point: "
str ""
)
(princ msg)
(while
(progn
(setq gr1 (grread t 15 0)
gr2 (cadr gr1)
gr1 (car gr1)
)
(cond
( (or (= 5 gr1) (= 3 gr1))
(redraw)
(osf gr2 osm)
(setq pt6 (trans gr2 1 vec))
(mapcar '(lambda ( a b ) (grdraw a b 1 1))
(setq lst
(list pt1 pt2
(trans (list (car pt6) (cadr pt6) (caddr pt5)) vec 1)
(trans (list (car pt6) (cadr pt6) (caddr pt4)) vec 1)
)
)
(cons (last lst) lst)
)
(= 5 gr1)
)
( (= 2 gr1)
(cond
( (= 6 gr2)
(if (zerop (logand 16384 (setq osm (setvar 'osmode (boole 6 16384 (getvar 'osmode))))))
(princ "\n<Osnap on>")
(princ "\n<Osnap off>")
)
(princ msg)
)
( (= 8 gr2)
(if (< 0 (strlen str))
(progn
(princ "\010\040\010")
(setq str (substr str 1 (1- (strlen str))))
)
)
t
)
( (< 32 gr2 127)
(setq str (strcat str (princ (chr gr2))))
)
( (member gr2 '(13 32))
(cond
( (= "" str) nil)
( (setq gr2 (LM:grsnap:parsepoint pt1 str))
(setq osm 16384)
nil
)
( (setq tmp (LM:grsnap:snapmode str))
(setq osm tmp
str ""
)
)
( (and pt6
(setq len (distof str))
(setq pt6 (list (car pt6) (cadr pt6) (caddr pt4)))
(not (equal 0.0 (setq tmp (distance pt4 pt6)) 1e-8))
)
(setq gr2 (trans (mapcar '(lambda ( a b ) (+ b (* len (/ (- a b) tmp)))) pt6 pt4) vec 1)
osm 16384
)
nil
)
( (setq str "")
(princ (strcat "\n2D / 3D Point Required." msg))
)
)
)
)
)
)
)
)
(if (listp gr2)
(setq pt6 (trans (osf gr2 osm) 1 vec))
)
)
(setq pt6 (trans pt3 1 vec))
)
)
(progn
(LM:startundo (LM:acdoc))
(entmake
(list
'(000 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(090 . 4)
'(070 . 1)
(cons 038 (caddr (trans pt1 1 ocs)))
(cons 010 (trans pt1 1 ocs))
(cons 010 (trans pt2 1 ocs))
(cons 010 (trans (list (car pt6) (cadr pt6) (caddr pt5)) vec ocs))
(cons 010 (trans (list (car pt6) (cadr pt6) (caddr pt4)) vec ocs))
(cons 210 ocs)
)
)
(LM:endundo (LM:acdoc))
)
)
(redraw) (princ)
)
|
|