本帖最后由 cq4920 于 2022-12-20 23:20 编辑
自己做的动态倒角,但是效果不是很好
R的值 能显示出来 并且能直接输入 (单击左键输入R值)
R的弦 如果可以控制凹凸 就好了 (原理不难,但非矩形好像没意义)
非直角 也能相对正确倒圆了 (切点的位置不太准确)
生成的圆弧依次收尾相连就是想要得到的图形,但是曲线的端点顺序不太好控制,连接圆弧收尾总是会出现错误,非闭合曲线就更麻烦。
顺便问一下,在模型空间内,我怎么获取视口的最大坐标和最小坐标?黄总的函数解决了,文字大小可以固定了
感谢xyp1964 提供的一串特别好的代码
- ;;多义线倒圆
- (defun c:fds (/ r rr p0 pts en ent k a r pn p1 p2 p3 pa pb pc rr)
- (setq ent (entsel) en (entlast) bb T)
- (setq p0 (mc:mind (car ent))
- pts (MJ:Massoc 10 (entget (car ent))))
- (setq k (car (MJ:Massoc 70 (entget (car ent)))))
- (while bb
- (setq mouse (grread t 8))
- (setq a (car mouse) r t)
- (cond
- ((= a 5)
- (if (= (equal r rr) nil)
- (progn
- (setq pn (cadr mouse)
- r (distance p0 pn)
- n (length pts) ptss pts)
- (if (= k 0) (setq n (- n 2)))
- (vl-cmdf "_.erase" (last_ent en) "")
- (repeat n
- (setq p1 (car ptss)
- p2 (cadr ptss)
- p3 (caddr ptss))
- ;; 核心
- (setq rad (* (- (angle p2 p3) (angle p2 p1)) 0.5)
- rad (if (< rad 0) (+ rad pi)rad);夹角
- ll (abs (/ r (sin rad))) ;斜边长度
- l1 (sqrt (- (* ll ll) (* r r))) ;直角边长度
- pa (polar p2 (angle p2 p1) l1)
- pb (polar p2 (angle p2 p3) l1)
- pc (polar p2 (angle p2 (mc:md pa pb)) (- ll r))
- )
- (make-arc pa pc pb)
- (setq ptss (append (cdr ptss) (list (car ptss))))
- )
- (setq rr r en0 (entlast))
- (setq ptmin (car (viewpnts)) ptmax (cadr (viewpnts)))
- (entmake (list '(0 . "TEXT") (cons 1 (rtos r 2 2)) (cons 10 p0) (cons 40 (/ (distance ptmin ptmax) 100))))
- (setq txt (entlast))
- (Mc:ZXc p0 pn 3)
- (setq zx (entlast))
- )))
- ((= 3 a)
- (progn
- (setq n (length pts) ptss pts r (getdist p0 ))
- (vl-cmdf "_.erase" (last_ent en) "")
- (if (= k 0) (setq n (- n 2)))
- (repeat n
- (setq p1 (car ptss)
- p2 (cadr ptss)
- p3 (caddr ptss))
- (setq rad (* (- (angle p2 p3) (angle p2 p1)) 0.5)
- rad (if (< rad 0) (+ rad pi)rad);夹角
- ll (abs (/ r (sin rad))) ;斜边长度
- l1 (sqrt (- (* ll ll) (* r r))) ;直角边长度
- pa (polar p2 (angle p2 p1) l1)
- pb (polar p2 (angle p2 p3) l1)
- pc (polar p2 (angle p2 (mc:md pa pb)) (- ll r))
- )
- (make-arc pa pc pb)
- (setq ptss (append (cdr ptss) (list (car ptss))))
- )
- (setq bb nil)
- )
- )
- ((or (= 25 a) (= 11 a) (= a 2));右键
- (progn
- (vl-cmdf "_.erase" zx "")
- (vl-cmdf "_.erase" txt "")
- (setq bb nil)
- ))
- )
- )
- )
- ;;117.3 [功能] 返回当前视窗左下角和右上角 坐标
- (defun viewpnts (/ A B C D X)
- (setq d (getvar "screensize")) ;屏像素
- (setq b (* (getvar "viewsize") 0.5) ;viewsize屏竖长
- a (* b (/ (car d) (cadr d))) ;屏横长
- x (trans (getvar "viewctr") 1 2) ;屏中点viewctr
- c (list (- (car x) a) (- (cadr x) b) 0.0)
- d (list (+ (car x) a) (+ (cadr x) b) 0.0)
- )
- (list (trans c 2 1) (trans d 2 1))
- )
|