- 积分
- 32618
- 明经币
- 个
- 注册时间
- 2016-9-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
效果如图所示:
系统自带的命令:
命令: LENGTHEN
选择对象或 [增量(DE)/百分数(P)/全部(T)/动态(DY)]: DE
输入长度增量或 [角度(A)] <0.00>:
 - ;;说明:直线、多段线(不含圆弧段)长度增量工具
- (defun c:CDE(/ arcang arcinfo arclength bulge cenpt eang ent ept exang exdis getptlength isstoe istype lm:bulge->arc modpt nearpt obj oldlen param ptlen radius sang spt ss var)
- (vl-load-com)
- ;; Bulge to Arc - Lee Mac
- ;; p1 - start vertex
- ;; p2 - end vertex
- ;; b - bulge
- ;; Returns: (<center> <start angle> <end angle> <radius>)
- (defun LM:Bulge->Arc ( p1 p2 b / c r )
- (setq r (/ (* (distance p1 p2) (1+ (* b b))) 4 b)
- c (polar p1 (+ (angle p1 p2) (- (/ pi 2) (* 2 (atan b)))) r)
- )
- (if (minusp b)
- (list c (angle c p2) (angle c p1) (abs r))
- (list c (angle c p1) (angle c p2) (abs r))
- )
- )
- (defun getptlength(lsobj lsparam / lsspt lsept)
- (list
- (setq lsspt (vlax-curve-getPointAtParam lsobj lsparam))
- (setq lsept (vlax-curve-getPointAtParam lsobj (1+ lsparam)))
- (distance lsspt lsept)
- )
- )
- (while (and (setq exdis (getdist (strcat "\n输入增量:"))) (/= exdis 0))
- (while
- (setq ss
- (ssget ":S"
- '(
- (-4 . "<or")
- (0 . "LINE")
- (-4 . "<and")
- (0 . "LWPOLYLINE")
- (-4 . "!=") (70 . 1)
- (-4 . "and>")
- (-4 . "or>")
- )
- )
- )
- (setq ent (ssnamex ss 0) istype (cdr (assoc 0 (entget (cadar ent)))))
- (setq obj (vlax-ename->vla-object (cadar ent)))
- (setq nearpt (vlax-curve-getClosestPointTo obj (cadr (last (car ent))) t))
- (if (equal istype "LWPOLYLINE")
- (progn
- (setq param (fix (vlax-curve-getParamAtPoint obj nearpt)))
- (setq ptlen (getptlength obj param) spt (car ptlen) ept (cadr ptlen) oldlen (caddr ptlen))
- (setq bulge (vla-GetBulge obj param))
- (if (= bulge 0)
- (progn
- (setq isstoe (> (distance spt nearpt) (distance ept nearpt)))
- (setq modpt (polar (if isstoe ept spt) (if isstoe (angle spt ept) (angle ept spt)) exdis))
- (setq var (vlax-make-safearray vlax-vbDouble '(0 . 1)))
- (vlax-safearray-fill var (list (car modpt) (cadr modpt)))
- (vla-put-Coordinate obj (if isstoe (+ 1 param) (+ 0 param)) var)
- (vla-Update obj)
- (princ (strcat "\n原始线段长【" (rtos oldlen) "】, 增量【" (rtos exdis) "】, 当前线段长【" (rtos (caddr (getptlength obj param))) "】"))
- )
- (progn
- ; (setq arcinfo (LM:Bulge->Arc spt ept bulge) cenpt (car arcinfo) sang (cadr arcinfo) eang (caddr arcinfo) radius (cadddr arcinfo))
- ; (setq arclength (- (vlax-curve-getDistAtParam obj (1+ param)) (vlax-curve-getDistAtParam obj param)))
- ; (setq arcang (/ arclength radius))
- ; (setq exang (/ exdis radius))
- ; (if (or (and (> exang 0) (< (+ exang arcang) (* pi 2))) (and (< exang 0) (< (abs exang) arcang)))
- ; (progn
- ; (setq isstoe (> (distance spt nearpt) (distance ept nearpt)))
- ; (setq modpt (polar cenpt (if isstoe (+ eang exang) (- sang exang)) radius))
- ; (setq var (vlax-make-safearray vlax-vbDouble '(0 . 1)))
- ; (vlax-safearray-fill var (list (car modpt) (cadr modpt)))
- ; (vla-put-Coordinate obj (if isstoe (+ 1 param) (+ 0 param)) var)
- ; (vla-Update obj)
- ; )
- ; )
- )
- )
- )
- (progn
- (setq spt (vlax-curve-getStartPoint obj))
- (setq ept (vlax-curve-getEndPoint obj))
- (setq isstoe (> (distance spt nearpt) (distance ept nearpt)))
- (setq modpt (polar (if isstoe ept spt) (if isstoe (angle spt ept) (angle ept spt)) exdis))
- (if isstoe (vla-put-EndPoint obj (vlax-3D-point modpt)) (vla-put-StartPoint obj (vlax-3D-point modpt)))
- (vla-Update obj)
- (princ (strcat "\n原始线段长【" (rtos (distance spt ept)) "】, 增量【" (rtos exdis) "】, 当前线段长【" (rtos (distance (vlax-curve-getStartPoint obj) (vlax-curve-getEndPoint obj))) "】"))
- )
- )
- )
- )
- (prin1)
- )
针对于圆弧段还有待完善,有兴趣的话,你们可以自己试着去完善!!!
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|