양쪽으로 옵셋하는 리습입니다.
현재는 offset distance 를 10 을 입력하면 양쪽으로 10m 씩 옵셋되는건데
이것을 10을 입력하면 양쪽으로 절반인 5m씩 옵셋되도록 고치고 싶은데
어디를 고쳐야 할까요?
(vl-load-com)
(vlax-remove-cmd “offsetm”)
(defun C:om
(/ *error* r2luprec
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)
)
;;
(if (=(setq ofsetdst(getvar”offsetdist”))-1.0) (setq ofsetdst(- ofsetdst)))
(setq ofsetmsg(strcat”nSpecify offset distance <“(r2luprec ofsetdst)”>: “))
(initget (+ 2 4))
(if (setq offsetdist(getdist ofsetmsg))
(setq offsetdist(setvar”offsetdist”offsetdist))
(setq offsetdist(setvar”offsetdist”ofsetdst))
)
;; 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 mPoint)”_none”(trans leftpt 0 1)
(list ename mPoint)”_none”(trans rigtpt 0 1) “”
)
(vlax-release-object *ename*)
)
;;(command)
)
)
(*error* nil)
)
(vlax-add-cmd “offsetm” ‘C:offsetm “offsetm” (+ acrx_cmd_Modal acrx_cmd_Redraw))
공유
(setq leftpt(polar mPoint(+ ang(* pi 0.5))dist))
(setq rigtpt(polar mPoint(- ang(* pi 0.5))dist))
두줄을
(setq leftpt(polar mPoint(+ ang(* pi 0.5)) (* 0.5 dist)))
(setq rigtpt(polar mPoint(- ang(* pi 0.5)) (* 0.5 dist)))
두줄을 바꿨는데 2016이어서 그런가 안되네요ㅠ