- (defun c:tt ()
- "参照角度画矩形"
- (defun AngleAtPoint (s1 pt / pa)
- (setq pt (vlax-curve-getclosestpointto s1 pt)
- pa (vlax-curve-getparamatpoint s1 pt)
- )
- (angle pt (mapcar '+ pt (vlax-curve-getfirstderiv s1 pa)))
- )
- (if (and (setq p1 (getpoint "\n请输入斜矩形第一点: "))
- (setq p2 (getpoint p1 "\n请输入斜矩形对角点:"))
- (setq e (entsel "\n参照角度边线: "))
- )
- (progn
- (setq s1 (car e)
- pt (osnap (cadr e) "nea")
- rad (AngleAtPoint s1 pt)
- p2a (polar p2 (+ rad (* pi 0.5)) 1)
- p1a (polar p1 (+ rad (* pi 0.5)) 1)
- p12 (inters p1 (polar p1 rad 1) p2 p2a nil)
- p21 (inters p2 (polar p2 rad 1) p1 p1a nil)
- )
- (command "pline" p1 p12 p2 p21 "c")
- )
- )
- (princ)
- )
|