绘多义线角平分线.lsp*****主题付费,附件免费
本帖最后由 fsy124618 于 2011-9-9 10:22 编辑
绘多义线角平分线.lsp
自己花了一天时间写的
- ===================================================================
- ;;;功能:等分角平分线工具dfj
- ;;;作者:biaoge124 日期:2011.9.8
- ===================================================================
- (defun c:dfj ()
- ;;; 定义系统变量
- (setq osn (getvar "osmode"))
- (setvar "osmode" 0)
- (setvar "cmdecho" 0)
- ;;; 选取对象,必须为多义线
- (setq en (car (entsel "\n选取多边形:")))
- (setq ent (entget en))
- (setq i 0)
- ;;; 定义空集
- (setq plptll '())
- ;;; 提取多义线点集
- (if (null ent)
- ()
- (progn
- (repeat (length ent)
- (setq entnn (nth i ent))
- (if (= (car entnn) 10)
- (setq
- plptll (cons (cdr entnn) plptll)
- )
- )
- (setq i (1+ i))
- )
- )
- )
- (setq plptll (reverse plptll))
- ;;;绘第一个角平分线
- (setq ii 1)
- (setq ptii (nth 0 plptll))
- (setq ptii+ (nth 1 plptll))
- (setq ptii- (nth (1- (length plptll)) plptll))
- (fsy_dfcz)
- ;;;绘中间点角平分线
- (repeat (- (length plptll) 2)
- (setq ptii (nth ii plptll))
- (setq ptii+ (nth (1+ ii) plptll))
- (setq ptii- (nth (1- ii) plptll))
- (fsy_dfcz)
- (setq ii (1+ ii))
- )
- ;;;绘最后一个角平分线
- (setq ptii+ (nth 0 plptll))
- (setq ptii- (nth (- (length plptll) 2) plptll))
- (setq ptii (nth (1- (length plptll)) plptll))
- (fsy_dfcz)
- (setvar "osmode" osn)
- (princ "谢谢使用biaoge124的等分角平分线工具 命令:dfj")
- (princ)
- )
- ;;;"biaoge124"
- ===================================================================
- ===================================================================
- ;;;具体等分操作
- (defun fsy_dfcz ()
- (setq ptang1 (angle ptii ptii+)
- ptang2 (angle ptii ptii-)
- )
- (if (< (abs (- ptang1 ptang2)) pi)
- (progn (setq ptang (/ (+ ptang1 ptang2) 2.0))
- (command "pline"
- ptii
- (polar ptii ptang (distance ptii ptii+))
- ""
- )
- )
- (progn
- (setq ptang (+ (/ (+ ptang1 ptang2) 2.0) pi)
- )
- (command "pline"
- ptii
- (polar ptii ptang (distance ptii ptii+))
- ""
- )
- )
- )
- )
- ;;;"biaoge124"
- ===================================================================
- ===================================================================
复制代码另附动画
|
|