MULTIPLE OFFSET TO THE SELECTED POINTS

MULTIPLE OFFSET TO THE SELECTED POINTS

symoin
Enthusiast Enthusiast
553 Views
7 Replies
Message 1 of 8

MULTIPLE OFFSET TO THE SELECTED POINTS

symoin
Enthusiast
Enthusiast

Hi, I am looking for a lisp code that allows me to select a polyline and then select some points (multiple) and offset the selected polyline to these points and snap the start / end of the polyline to the points.

 

Thanks in advance.

0 Likes
Accepted solutions (1)
554 Views
7 Replies
Replies (7)
Message 2 of 8

Sea-Haven
Mentor
Mentor

Its not offset rather copy a pline and move 1st vertice to a point. Only problem is if pick point is below 2nd point. 

 

2nd question is the offsets always in the X direction or can it be you want a rotated answer ?

0 Likes
Message 3 of 8

symoin
Enthusiast
Enthusiast
Hi Sea-Heaven,
I need an offset, mostly these are cables and pipes which will have bends.
The direction can be any.
0 Likes
Message 4 of 8

Sea-Haven
Mentor
Mentor

Ok "The direction can be any." complicates things. Need to set a rule like always square of 1st leg or pick an angle for end point. Can you help confirming direction to go in. Can be coded. 

0 Likes
Message 5 of 8

symoin
Enthusiast
Enthusiast

please make it to the left

0 Likes
Message 6 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Possibly like this.

 

But it's not bulletproof. It just changes the closer end of the newly created pline to the corresponding selected point.

So the situations as attached are trouble. Though points could shorten plines, if it's beyond the last segment, it's trouble.

 

(vl-load-com)

(defun c:Offselpoints ( / e s i p a d) (if (and (setq e (entsel "\nSelect object to offset: ")) (princ "\nSelect points, ") (setq s (ssget '((0 . "POINT")))) (not (command "_.offset" "_t")) ) (repeat (setq i (sslength s)) (command e "_non" (trans (setq p (cdr (assoc 10 (entget (ssname s (setq i (1- i))))))) 0 1)) (setq a (entlast) d (entget a)) (entmod (subst (cons 10 p) (assoc 10 (if (< (distance (vlax-curve-getstartpoint a) p) (distance (vlax-curve-getendpoint a) p)) d (reverse d))) d)))) (command "") (princ) )

 

0 Likes
Message 7 of 8

symoin
Enthusiast
Enthusiast

Excellent work, Thankyou  ВeekeeCZ

0 Likes
Message 8 of 8

calderg1000
Mentor
Mentor

Regards @symoin 

Please try this code

;;;___
(defun c:o_pt (/ sn snv sp p0 d0 p0f snd i pxi dx lp)
  (if (setq sn	(car (entsel "\Select Lwpolyline: "))
	    snd	(entget sn)
	    snv	(vlax-ename->vla-object sn)
      )
    (progn
      (princ "\nSelect Points...:")
      (vla-getboundingbox snv 'pmin 'pmax)
      (setq sp	(ssget '((0 . "point")))
	    p0	(vlax-safearray->list pmax)
	    d0	(distance p0 (cdr (assoc 10 (entget (ssname sp 0)))))
	    p0f	(mapcar '+ p0 (list 0. d0 0.))
	    snd	(entmod (subst (cons 10 p0f) (assoc 10 snd) snd))
      )
      (repeat (setq i (sslength sp))
	(setq pxi (cdr (assoc 10 (entget (ssname sp (setq i (1- i))))))
	      dx  (distance p0f (list (car pxi) (cadr p0f) 0))
	)
	(vla-offset snv dx)
	(setq lp (entget (entlast)))
	(entmod (subst (cons 10 pxi) (assoc 10 lp) lp))
      )
    )
  )
  (entmod (subst (cons 10 p0) (assoc 10 snd) snd))
  (princ)
)

 


Carlos Calderon G
EESignature
>Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

0 Likes