Jump to content

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


mhmtlgrr

Recommended Posts

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

Link to comment
Share on other sites

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)
)

Link to comment
Share on other sites

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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...