Jump to content
mhmtlgrr

Multi-offset / Get offset distance values from given polyline.

Recommended Posts

mhmtlgrr

Dear folks,

 

Here I am with an interesting question. Please refer to the attached DWG file for further inspection.

 

The scenerio is:

1. I have a polyline that I use as a base that will be offset to OUTSIDE.

2. Offset values may vary object to object. So what I need to achieve is to draw a polyline that consists of offset values between verticies like:

 

If "-" is polyline length and "x" is vertex:

 

---x-x---x--

 

This polyline says:

Offset the selected polyline 2 units

then offset new one 3 units

then offset latest one 1 units

and lastly 3 units.

 

Is it even possible?

 

Regards,

 

MA

offset-from-polyline.dwg

Share this post


Link to post
Share on other sites
ronjonp

HERE is something that would probably work for you.

Share this post


Link to post
Share on other sites
ronjonp

Here's a quick mod of that code. You need to pick your profile segments in order then select the item(s) to offset.

(defun c:foo (/ _pts lm:clockwise-p a b c e o s)
 ;; Clockwise-p  -  Lee Mac
 ;; Returns T if p1,p2,p3 are clockwise oriented
 (defun lm:clockwise-p	(p1 p2 p3)
   ((lambda (n) (< (car (trans p2 0 n)) (car (trans p1 0 n)))) (mapcar '- p1 p3))
 )
 (defun _pts (e) (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= 10 (car x))) (entget e))))
 (while (setq e (car (entsel "\nPick profile segments in order: ")))
   (setq c (cons (vlax-curve-getdistatparam e (vlax-curve-getendparam e)) c))
 )
 (setq b 0)
 (if (and c (setq s (ssget '((0 . "lwpolyline") (-4 . ">") (90 . 2)))))
   (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (setq a (_pts e))
     (setq a (cond ((lm:clockwise-p (car a) (cadr a) (caddr a)) -)
	    (+)
      )
     )
     (foreach d (reverse c)
;; vlax-invoke will return a list of objects rather than an array
(setq o (car (vlax-invoke (vlax-ename->vla-object e) 'offset (a (setq b (+ b d))))))
;; Use entmod so layer does not need to exist
;; (entmod (append (entget (vlax-vla-object->ename o)) (list (cons 8 d))))
     )
   )
 )
 (princ)
)

Share this post


Link to post
Share on other sites
BIGAL
Posted (edited)

I wrote one that use a csv input 1,2,3,-4,-6,-10 now where did I put it. It just converts the input to a list and repeats the offset command. It may be at home I posted here.

 

 

 

Try these instead AH:test24 is what you want the other is more generic but you dont need to draw the little lines.

 

; multiple offsets just enter values
; by Alan H July 2018
; pick pt3 well away from object and near square off
; for angle to work

(defun AH:test23 ( / ent dist1 obj1 x obj2 pt2 pt1 oldsnap)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 512)
(setq ent (entsel "pick object to offset"))
(setq obj1 (car ent))
(setq pt2 (cadr ent))
(setq  pt3 (getpoint  pt2 "pick right side"))
(setq ang  (angle pt2 pt3))
(while
(setq dist1 (getreal "Enter offset distance -ve for left <Enter> to exit"))
(setq  pt3 (polar pt2  ang  dist1))
(command "offset" (abs dist1) obj1 pt3 "")
)
(setvar 'osmode oldsnap)
(princ)
)
(AH:test23)

 

(defun AH:test24 ( / ent dist1 obj1 x obj2 pt2 pt1 oldsnap)
(setq oldsnap (getvar 'osmode))
(setvar 'osmode 1)
(setq ent (entsel "pick object to offset"))
(setq obj1 (car ent))
(setq pt2 (cadr ent))
(setq  pt3 (getpoint  pt2 "pick right side"))
(setq ang  (angle pt2 pt3))
(while
(setq dist1 (getdist pt2 "Enter offset distance -ve for left"))
(setq  pt3 (polar pt2  ang  dist1))
(command "offset" (abs dist1) obj1 pt3 "")
)
(setvar 'osmode oldsnap)
(princ)
)
(AH:test24)

Edited by BIGAL

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×