 - (defun C:w3 ( / curve ent holdcmd holdosmode jang n pt pt1 pt2 ss tmp x)
- (defun LEN (CURVE / TLEN)
- (setq TLEN (vlax-curve-getdistatparam CURVE (vlax-curve-getendparam CURVE)))
- )
- (command "_.UNDO" "BE")
- (if (null tee_dist) (setq tee_dist 10.0)) ;_设置全局变量
- (setq HOLDOSMODE (getvar "OSMODE"))
- (setq HOLDCMD (getvar "CMDECHO"))
- (setvar "CMDECHO" 0)
- (setvar "OSMODE" 0)
- (if (setq ss (ssget '((0 . "*LINE,CIRCLE,ARC"))))
- (progn
- (setq n 0)
- (initget 2)
- (if (setq tmp (getdist (strcat "\n指定偏移距离(正__向外偏移 /负__向内偏移): <" (rtos tee_dist 2) ">")))
- (setq tee_dist tmp)
- ) ;_不输入时自动使用上一次输入数值
- (repeat (sslength ss)
- (setq ent (ssname ss n)
- n (1+ n)
- )
- (setq CURVE (vlax-ename->vla-object ENT)
- x (vlax-curve-getParamAtDist curve (/ (len curve) 3.33))
- pt (vlax-curve-getPointAtParam curve x)
- );_获得线上指定距离值的点及参数
- (setq JANG (angle '(0 0 0) (vlax-curve-getfirstderiv CURVE X)))
- (setq PT1 (polar PT (+ JANG (* 0.5 pi)) 0.00000001))
- (setq PT2 (polar PT (- JANG (* 0.5 pi)) 0.00000001))
- (command "_.OFFSET" (abs tee_dist) ENT PT1 "")
- (if (or (and (> tee_dist 0) (> (LEN CURVE) (LEN (entlast))))
- (and (< tee_dist 0) (< (LEN CURVE) (LEN (entlast))))
- )
- (progn
- (entdel (entlast))
- (command "_.OFFSET" (abs tee_dist) ENT PT2 "")
- (command "change" (entlast) "" "p" "c" 4 "")
- )
- )
- )
- )
- )
- ;;<<<
- ;;改变颜色
- ;;参考http://bbs.mjtd.com/forum.php?mod=viewthread&tid=101254
- ;(command "change" ss "" "p" "c" 4 "")
- ;;<<<
- (setvar "OSMODE" HOLDOSMODE)
- (setvar "CMDECHO" HOLDCMD)
- (command "_.UNDO" "E")
- (princ)
- )
|