求 内缩中间对半打断分开
本帖最后由 世井 于 2024-4-25 11:30 编辑要怎么把中间没用的线修剪掉呢
(DEFUN C:TT (/ en pykd pd P4 P6 s1 s2 S2E obj e1 e2)
(IF (NULL *pykd) (setq *pykd 15))
(setq pykd (getreal (strcat "\n输入偏移宽度<" (rtos *pykd 2 2) ">:")))
(if (NULL pykd) (setq pykd *pykd) (setq *pykd pykd))
(setq en(car(entsel)))
(setq pd(POLY:clockwise (mapcar 'cdr(vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget en)))))
(vla-offset (vlax-ename->vla-object en)(if pd pykd (- pykd)))
(SETQ s1 (entlast))
(command "change" s1 "" "P" "la" "layer3" "")
(setq p4 (JNH9PT s1 4)
p6 (JNH9PT s1 6))
(setq s2 (LINE p4 p6))
(SETQ S2E (entlast))
(setq obj (vlax-ename->vla-object s2E))
(vla-offset obj (/ pykd 2.0)) (setq e1 (entlast))
(vla-offset obj (- 0 (/ pykd 2.0))) (setq e2 (entlast))
(vla-erase obj)
(princ))
;;;---------------------- 高飞函数改造------------------------------;
;;;功能: 判断多边形的方向(为简单多边形,不自交的多边形);
;;;输入: 多边形顶点列表Pts(参数是点集) ;
;;;输出: 返回T则是顺时针,否则逆时针 ;
(defun POLY:clockwise (Pts / MATet2V)
(defun MATet2V (v1 v2)
(-(* (car v1) (cadr v2))
(* (car v2) (cadr v1)) ) )
(< (* (apply '+
(mapcar 'MATet2V pts
(append (cdr Pts) (list (car Pts)))
)) 0.5 ) 0.0 ))
;
(defun getboundingbox (e / BP UP)
(cond ((equal (type e) 'ENAME) (setq e (vlax-ename->vla-object e))))
(vla-getboundingbox e 'bp 'up)
(list (safearray-value bp) (safearray-value up)))
;包围实体9点坐标 (JNH9PT e site)
(DEFUN JNH9PT (e site / obj p1 p2 p3 p4 p5 p6 p7 p8 p9)
(defun MID (p1 p2) (mapcar '(lambda (x) (* x 0.5)) (mapcar '+ p1 p2)))
(SETQ obj (getboundingbox e))
(setq p1 (car obj))
(setq p9 (cadr obj))
(setq p3 (list (car p9)(cadr p1)))
(setq p7 (list (car p1)(cadr p9)));
(setq p2 (MID P1 P3))
(setq p8 (MID P7 P9))
(setq p4 (MID P1 P7))
(setq p6 (MID P3 P9))
(setq p5 (MID P1 P9))
(nth (- site 1) (list p1 p2 p3 p4 p5 p6 p7 p8 p9)) )
(defun LINE (pt pt1)
(entmake (list '(0 . "LINE") (cons 10 pt) (cons 11 pt1))))求 大神来个内缩中间对半打断 分开 或者三等分
大致改了下你的,快捷键TT
什么的中间,包围盒的中心点? ssyfeng 发表于 2024-4-22 14:13
什么的中间,包围盒的中心点?
对是的... 先偏移,后求偏移对象的包围盒,求中心点,再画条水平射线求交点,再重构两段多段线 ssyfeng 发表于 2024-4-22 14:26
先偏移,后求偏移对象的包围盒,求中心点,再画条水平射线求交点,再重构两段多段线
偏移里面算不来
以下是偏移代码
(setq en(car(entsel)))
(setq pykd(getreal "\n输入偏移宽度"))
(setq pd(POLY:clockwise (mapcar 'cdr(vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget en)))))
(vla-offset (vlax-ename->vla-object en)(if pd pykd (- pykd)))
;;;---------------------- 高飞函数改造------------------------------;
;;;功能: 判断多边形的方向(为简单多边形,不自交的多边形);
;;;输入: 多边形顶点列表Pts(参数是点集) ;
;;;输出: 返回T则是顺时针,否则逆时针 ;
(defun POLY:clockwise (Pts / MATet2V)
(defun MATet2V (v1 v2)
(- (* (car v1) (cadr v2))
(* (car v2) (cadr v1))
)
)
(< (* (apply '+
(mapcar 'MATet2V pts
(append (cdr Pts) (list (car Pts)))
)
) 0.5
) 0.0
)
)
页:
[1]
2