Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MULTI LINE OFFSET

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
1339 Views, 0 Replies

MULTI LINE OFFSET

added new function called BOFF

This will mutiple offset from offsetable objects placing the new lines on
layers you choose.


type SETOFF and you are asked how many offsets.
you could enter, say, 4 and then you are asked to type a vlaue, say -12, and
then pick a layer you want it to go on.
then you cycle through for all 4 requets.

once defined, you type boff and touch an offsetable object and all the lines
will be offset and put on the right layer in one whack.

The grunt work has been done but i plan to add more functionality to this to
account for reversed plines and perhaps a list of preset typical cases you
can pull from a list.

you can avoid the setoff step by defining 2 list variables on your own
(perhaps preset and save off someplace for use).

(setq offlist (list -12 -5 5 14 23)) ; (-) means offset left (+) right.
(setq offlayer (list "0" "0" "0" "0" "0" )) ; all liines goto 0 in this
case.

(note: scan this group for ark.lsp if this does not function completely. I
tried to paste all the sub funcionts used but may have gotten them all).

Enjoy, Alex K.

; mvo multi variable offset
;(defun c:mvo ()
;(setq tpt1 (getpoint "Select 1st pt behind object: ") offlist nil flag 0
tot 0)
;(print "Select object to offset: ")(gent)
; (while (= flag 0)
; (setq tt (getstring "Enter an offset value: ") tot (+ tot (atof tt)))
;(if (= tt "") (progn (setq flag 1)) (progn (setq offlist (append offlist
(list (atof tt))))))
; )
;(setq tpt2 entpt tpt (lb tpt1 tpt2 0 (* tot 1.1)))
;(foreach n offlist (progn
;(command "offset" n entn tpt "")(gents (entlast))
; ))
; )




; mvo multi variable offset BY ALEX KONIECZKA
(defun c:mvo ()
(print "Select object to offset: ")(gent)
(setq tpt entpt tpt1 (getpoint "Select side to offset: ") dd 0 tang (angle
entpt tpt1))


(while (setq d (getstring "Enter an offset value (*# for multiple) :"))

(if (= "*" (substr d 1 1))
(progn (setq n (atoi (substr d 2)) d (getstring "Distance: : ") d (atof
) ))
(progn (setq n 1 d (atof d) ))
) ;if

(repeat n (progn

(SETQ DD (+ DD D) tpt (polar tpt tang dd) )
(command "offset" d entn tpt "")(gents (entlast))
))

); while
(princ) )


; offset from base pick a base point and hold the cursor on the side you
want to offset and start typing #'s

(defun c:ob ()
(print "Select base object to offset from and put currsor on the offset
side, then type numbers: ")(gent)
(while (setq d (getstring "Enter an offset value (*# for multiple) :"))
(setq tpt1 (cadr (grread 1)))
(setq tpt entpt dd 0 tang (angle entpt tpt1))
(command "offset" d entn tpt1 "")
); while
(princ) )

; ot offset through will change layer to the picked item.
(defun c:ot ()
(print "Select base object to offset: ")(gent)(setq e (car entn))
(while (gent)
(setq layn (ass 😎 tpt1 entpt)
(command "offset" "t" e tpt1 "")
(gents (entlast))(modent 8 layn)
); while
(princ) )



; dof = double offset to current layer

(defun c:dof ()
(setq d (getval d "Enter doffset: "))
(while (print "Select line to offset: ")(gent)
(if (= (ass 0) "LINE")(progn
(setq e entn tpt1 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi 2))
1) tpt2 (polar (ass 10) (+ (angle (ass 10) (ass 11)) (/ pi -2)) 1) )
(command "offset" d e tpt1 "")(gents (entlast))(modent 8 (getvar
"clayer"))
(command "offset" d e tpt2 "")(gents (entlast))(modent 8 (getvar
"clayer"))
)))
(princ))



; boff = baseline offset by alex konieczka

(defun c:boff ()
(if (= nil offlist)(progn (print " type SETOFF to define offsets. ")(quit)))
(setq cnt 0)
(PRINT "Select object to offset: ")(GENT)(setq e (car entn))
(setq stp (vlax-curve-getStartParam entob) stpt (vlax-curve-getStartPoint
entob))
(setq vec (vlax-curve-getFirstDeriv entob stp))
(setq p1 (polar stpt (+ (angle vec stpt) (d2r -90.0)) 10.0))
(setq p2 (polar stpt (+ (angle vec stpt) (d2r 90.0)) 10.0))
(foreach n offlist (progn
(if (< 0 (nth cnt offlist))
(progn (command "offset" (abs (nth cnt offlist)) e p1 "")(gents
(entlast))(modent 8 (nth cnt offlayer)))
(progn (command "offset" (abs (nth cnt offlist)) e p2 "")(gents
(entlast))(modent 8 (nth cnt offlayer))))
(setq cnt (1+ cnt))
))
(princ))

(defun c:setoff ()
(setq offlist nil offlayer nil n (getint "How many lines will be offset? "))
(repeat n
(setq offlist (append (list (getreal "Enter Offset: " )) offlist))
(print "pick layer you want it to go on: ")(gent)
(setq offlayer (append (list (ass 8)) offlayer))
)
(princ))


; gent returns the entity name of the item picked
(defun gent ()
(setq entn (entsel) entob (vlax-ename->vla-object (car entn)))
(setq entcodes (entget (car entn)))
(setq entpt (cadr entn))
(setq entt (cdr (assoc 0 entcodes)))
)


; ass returns the (cdr (assoc n)) of the the item. (ass 10) => (10 . 1 2 3)
(defun ass (code / )
(cdr (assoc code entcodes))
)

; LB locate bearing by p1 p2 dist and deg +=ccw
(defun lb (tpt1 tpt2 ang dis)
(polar tpt1 (+ (angle tpt1 tpt2) (d2r ang)) dis)
)

; D2R converts degree angle to radians
(defun d2r (deg / d2r)
(setq d2r (/ (* deg pi) 180)) ;deg * pi /180
)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost