한번에 여러선이나 객체를 중심선 기준으로 현재의 레이어로 양쪽으로 offset 하는 명령어 인데
현재는 입력값이 200인 경우 중심선을 기준으로 양쪽으로 각각 200씩 offset되는데
100씩 offset 되게 수정 부탁 드립니다.
(vl-load-com)
(if (not cal) (arxload(findfile “geomcal.arx”)nil))
(vlax-remove-cmd “aw”)
(defun C:aw
(/ *error* r2luprec getawdist
ofsetdst ofsetmsg offsetdist ss cmdecho
nn ename *ename* sParam eParam sPoint longth dParam mParam dist
ubound mPoint dirpnt ang leftpt rigtpt eline *eline* intsect ;;lists
)
(setvar”errno”0)
(defun *error*(errmsg)
(setvar”cmdecho”0)(command)(command)
(if (and
errmsg
(not(member errmsg ‘(“Function cancelled” “quit / exit abort” “console break”)))
)
(progn(princ”nErrNo “)(princ(getvar”errno”))(princ”: “)(princ errmsg))
)
(if cmdecho(setvar”cmdecho”cmdecho))
(if (and *ename*(not(vlax-object-released-p *ename*))) (vlax-release-object *ename*))
(if (and *eline*(not(vlax-object-released-p *eline*))) (vlax-release-object *eline*))
(if eline(entdel eline))
(princ)
)
;;
(defun r2luprec(num / dimzin return)
(if (=(type num)’STR) (setq num(atof num))(setq num(float num)))
(if (numberp num)
(progn
(setq dimzin(getvar”dimzin”))
(setvar “dimzin”0)
(setq return(rtos num(getvar”lunits”)(getvar”luprec”)))
(setvar “dimzin”dimzin)
) )
return
;;(setq a -1.2)(r2luprec a)(r2luprec”a”)(r2luprec “2.3”)(r2luprec -2.3)
)
;;
(defun getawdist(ofsetmsg / return)
(initget (+ 1 2 4 128))
(if (setq return(getdist ofsetmsg))
(cond
((=””return) return)
((numberp return) (prompt(strcat”n”(r2luprec return)))return)
((=(type return)’STR)
(if (numberp(setq return(cal return)))
(if (< 0 return)
(progn(prompt(r2luprec return))return)
(progn(prompt”nValue must be positive and nonzero.”)(getawdist ofsetmsg))
)
(progn(getawdist ofsetmsg))
)
)
(T (getawdist ofsetmsg))
)
(getawdist ofsetmsg)
)
)
;;
(if (=(setq ofsetdst(getvar”offsetdist”))-1.0) (setq ofsetdst(- ofsetdst)))
(setq ofsetmsg(strcat”nSpecify offset distance <“(r2luprec ofsetdst)”>: “))
(if (=””(setq offsetdist(getawdist ofsetmsg)))
(setvar”offsetdist”ofsetdst)
(setvar”offsetdist”offsetdist)
)
;; You can offset lines, arcs, circles, 2D polylines,
;; ellipses, elliptical arcs, xlines, rays, and planar splines.
(if (setq ss(ssget”:L”
‘((-4 . “<OR”)
(0 . “LINE”)(0 . “ARC”)(0 . “CIRCLE”)(0 . “LWPOLYLINE”)
(-4 . “<AND”)(0 . “POLYLINE”)(-4 . “<NOT”)(-4 . “&=”)(70 . 8)(-4 . “NOT>”)(-4 . “AND>”)
(0 . “ELLIPSE”);;(0 . “XLINE”)(0 . “RAY”)
(-4 . “<AND”)(0 . “SPLINE”)(-4 . “&=”)(70 . 8)(-4 . “AND>”)
(-4 . “OR>”)
)
))
;; “&” Bitwise AND (integer groups only)
;; The bitwise operators “&” and “&=” are valid only for integer-valued groups.
;; The bitwise AND, “&”, is true if ((integer_group & filter) /= 0) that is,
;; if any of the bits set in the mask are also set in the integer group.
;; “&=” Bitwise masked equals (integer groups only)
;; The bitwise masked equals, “&=”, is true if ((integer_group & filter) = filter)
;; that is, if all bits set in the mask are also set in the integer_group
;; (other bits might be set in the integer_group but are not checked).
(progn
(setq cmdecho(getvar”cmdecho”))
(setvar”cmdecho”0)
(setq nn -1)
(while (setq ename(ssname ss(setq nn(1+ nn))))
(setq *ename*(vlax-ename->vla-object ename))
(setq sParam(vlax-curve-getStartParam *ename*))
(setq eParam(vlax-curve-getEndParam *ename*))
(setq sPoint(vlax-curve-getStartPoint *ename*))
(setq longth(vlax-curve-getDistAtParam *ename* eParam))
;;
(setq dParam(*(- eParam sParam)0.0001))
(setq mParam(+ sParam dParam))
(setq dist(* longth 0.000001))
;;
(setq ubound nil)
(while (and
(/= ubound 2)
(setq mParam(+ mParam dParam))
(< mParam eParam)
)
(setq mPoint(vlax-curve-getPointAtParam *ename* mParam))
(setq dirpnt(vlax-curve-getFirstDeriv *ename* mParam))
(setq ang(angle(list 0.0 0.0)dirpnt))
(setq leftpt(polar mPoint(+ ang(* pi 0.5))dist))
(setq rigtpt(polar mPoint(- ang(* pi 0.5))dist))
(entmake (list'(0 . “LINE”)(cons 10 leftpt)(cons 11 rigtpt)))
(setq eline(entlast))
(setq *eline*(vlax-ename->vla-object eline))
(setq intsect(vlax-variant-value(vla-IntersectWith *ename* *eline* acExtendNone)))
(setq ubound(vlax-safearray-get-u-bound intsect(vlax-safearray-get-dim intsect)))
;;(setq lists(vlax-safearray->list intsect))
(cond
((< ubound 0) (setq dist(* dist 2.0)))
((< 2 ubound) (setq dist(* dist 0.9)))
)
(vlax-release-object *eline*)
(entdel eline)
(setq eline nil)
)
;;
(command
“._offset”(getvar”offsetdist”)
(list ename(trans mPoint 0 1)) “_none”(trans leftpt 0 1)
(list ename(trans mPoint 0 1)) “_none”(trans rigtpt 0 1) “”
)
(vlax-release-object *ename*)
)
;;(command)
)
)
(*error* nil)
)
(vlax-add-cmd “aw” ‘C:aw “aw” (+ acrx_cmd_Modal acrx_cmd_Redraw))
(princ)
공유
태은님.