本帖最后由 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
|