源码学习 间隙分割,异等偏移,定距等分
本帖最后由 ucuc2003 于 2015-8-11 14:39 编辑;;;http://bbs.mjtd.com/thread-113876-1-1.html
;;;间隙分割,异等偏移,定距等分
;;;by荒野孤行,修改ucuc2003
(defun c:TT5 (/ o_DIMZIN os sel len gap npy a)
(princ"定距等分")
(setvar "cmdecho" 0)
(setq o_DIMZIN (getvar "DIMZIN"))
(setq os (getvar "osmode"))
(defun *Error* (msg);出错处理
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,*EXIT*,")))
(progn
(setvar "DIMZIN" o_DIMZIN)
(setvar "osmode" os)
)
)
)
(setvar "osmode" 15359)
(setvar "DIMZIN" 8)
(if (= djdf_oldlen nil) (setq djdf_oldlen 1000))
(princ (strcat "\n指定等分总距离<" (rtos djdf_oldlen 2 7) ">: "))
(setq len (getdist))
(if len (setq djdf_oldlen len) (setq len djdf_oldlen))
(if (= djdf_oldgap nil) (setq djdf_oldgap 50))
(princ (strcat "\n指定固定间距<" (rtos djdf_oldgap 2 7) ">(这个值不能大于等分总距离" (rtos len 2 7) "): "))
(setq gap (getdist))
(if gap (setq djdf_oldgap gap) (setq gap djdf_oldgap))
(if (> gap len)
(progn (alert "请按照规定重新输入!") (exit))
)
(setq a (1+ (fix (/ len gap))))
(if (= djdf_olddfs nil) (setq djdf_olddfs 10))
(princ (strcat "\n指定等分数<" (rtos djdf_olddfs 2 7) ">(这个值不能大于" (rtos a 2 7) "):"))
(setq npy (getint))
(if npy (setq djdf_olddfs npy) (setq npy djdf_olddfs))
(setvar "DIMZIN" o_DIMZIN)
(if (> npy a)
(progn (alert "请按照规定重新输入!") (exit))
)
;(while
(while
(progn
(setq sel (entsel "\n请点选(直线、多段线、圆弧、圆、射线、或构造线):"))
(not (if (= sel nil)
nil
(wcmatch (cdr (assoc 0 (entget (car sel)))) "LWPOLYLINE,POLYLINE,LINE,XLINE,RAY,SPLINE,CIRCLE,ARC") ;实体类型必须为大写
)
)
)
(princ"\n未选取任何图元,请重新点选:")
)
(setq len (/ (- len (* (- npy 1) gap)) npy))
(initget 1)
(setq pt1 (getpoint "\n指定等分偏移方向:"))
(setvar "osmode" 0)
(setq len1 len
gap1 gap
)
(command "undo" "be")
(repeat (- npy 1)
(command "OFFSET" len sel pt1 "")
(setq gap (+ gap1 len))
(command "OFFSET" gap sel pt1 "")
(setq len (+ len1 gap))
)
(command "OFFSET" len sel pt1 "")
(setvar "osmode" os)
(command "undo" "e")
;);while
(princ)
)
源码学习: 《间隙分割,异等偏移,定距等分》
修改了下,增加了自动记忆功能,以及判断等分数,重新发帖
鸣谢原帖作者:荒野孤行
http://bbs.mjtd.com/thread-113876-1-1.html
大神,能不能把标尺寸的插件发一下啊, 大佬,能麻烦修改下源码嘛,点选对象改成捕捉对角点支持横向竖向,然后。输入等分距离,然后等分数量,空格结束我觉得这样方便点,更快 alexmai 发表于 2017-11-29 18:43
如果要实现这种等分,应如何操作?
这个功能实现了吗 顶顶顶!! 顶顶顶!! 感谢 ucuc2003 分享程序!!!! 好! 回帖是一种美德!感谢楼主的无私分享 谢谢 这个修改非常好用了感谢 感谢 很有用啊,感谢楼主分享 很好的程序,顶楼主