Jump to content

TRIM THEN JOIN


LITOKARDO_BC

Recommended Posts

Try this perhaps.

(defun c:hop (/ a b d e ent i o p1 p2 p3)
  ;; RJP » 2020-02-19
  ;; Set below for hop size
  (setq a 0.5)
  (while (setq ent (entsel "\nSelect polyline to add hop: "))
    (cond
      ((= (cdr (assoc 0 (entget (setq e (car ent))))) "LWPOLYLINE")
       (setq p1 (vlax-curve-getclosestpointto e (trans (cadr ent) 1 0)))
       (setq i (fix (vlax-curve-getparamatpoint e p1)))
       (setq b (vla-getbulge (setq o (vlax-ename->vla-object e)) i))
       (setq d (vlax-curve-getdistatpoint e p1))
       (vlax-put (vlax-ename->vla-object (tblobjname "layer" (vla-get-layer o))) 'lock 0)
       (if (and	(setq p2 (vlax-curve-getpointatdist e (+ d a)))
		(setq p3 (vlax-curve-getpointatdist e (- d a)))
	   )
	 (cond
	   ((= (fix (vlax-curve-getparamatpoint e p2)) (fix (vlax-curve-getparamatpoint e p3)) i)
	    (vlax-invoke o 'addvertex (setq i (1+ i)) (mapcar '+ p2 '(0 0)))
	    (vlax-invoke o 'addvertex i (mapcar '+ p3 '(0 0)))
	    (vla-setbulge o i (if (< (angle '(0 0 0) p2) (angle '(0 0 0) p3)) -1. 1.)
	    )
	   )
	   ((princ "\nVertex overlap! Pick another point..."))
	 )
       )
      )
      (princ "\nObject needs to be a lwpolyline...")
    )
  )
  (princ)
)

 

2020-02-19_11-11-16.gif

Link to comment
Share on other sites

41 minutes ago, ronjonp said:

Try this perhaps.


(defun c:hop (/ a b d e ent i o p1 p2 p3)
  ;; RJP » 2020-02-19
  ;; Set below for hop size
  (setq a 0.5)
  (while (setq ent (entsel "\nSelect polyline to add hop: "))
    (cond
      ((= (cdr (assoc 0 (entget (setq e (car ent))))) "LWPOLYLINE")
       (setq p1 (vlax-curve-getclosestpointto e (trans (cadr ent) 1 0)))
       (setq i (fix (vlax-curve-getparamatpoint e p1)))
       (setq b (vla-getbulge (setq o (vlax-ename->vla-object e)) i))
       (setq d (vlax-curve-getdistatpoint e p1))
       (vlax-put (vlax-ename->vla-object (tblobjname "layer" (vla-get-layer o))) 'lock 0)
       (if (and	(setq p2 (vlax-curve-getpointatdist e (+ d a)))
		(setq p3 (vlax-curve-getpointatdist e (- d a)))
	   )
	 (cond
	   ((= (fix (vlax-curve-getparamatpoint e p2)) (fix (vlax-curve-getparamatpoint e p3)) i)
	    (vlax-invoke o 'addvertex (setq i (1+ i)) (mapcar '+ p2 '(0 0)))
	    (vlax-invoke o 'addvertex i (mapcar '+ p3 '(0 0)))
	    (vla-setbulge o i (if (< (angle '(0 0 0) p2) (angle '(0 0 0) p3)) -1. 1.)
	    )
	   )
	   ((princ "\nVertex overlap! Pick another point..."))
	 )
       )
      )
      (princ "\nObject needs to be a lwpolyline...")
    )
  )
  (princ)
)

 

2020-02-19_11-11-16.gif

 

 

 

https://drive.google.com/file/d/126bvy7_lAzTiZ81TAvlJb2Cx24vCLupH/view?usp=sharing

Link to comment
Share on other sites

Try this to set the hop size .. I don't have time at the moment to do the precision for you.

(defun c:hop (/ a b d e ent i o p1 p2 p3)
  ;; RJP » 2020-02-19
  ;; Set below for hop size
  (setq	a (/ (cond ((setq a (getdist "\nEnter hop size: ")))
		   (1)
	     )
	     2.
	  )
  )
  (while (setq ent (entsel "\nSelect polyline to add hop: "))
    (cond
      ((= (cdr (assoc 0 (entget (setq e (car ent))))) "LWPOLYLINE")
       (setq p1 (vlax-curve-getclosestpointto e (trans (cadr ent) 1 0)))
       (setq i (fix (vlax-curve-getparamatpoint e p1)))
       (setq b (vla-getbulge (setq o (vlax-ename->vla-object e)) i))
       (setq d (vlax-curve-getdistatpoint e p1))
       (vlax-put (vlax-ename->vla-object (tblobjname "layer" (vla-get-layer o))) 'lock 0)
       (if (and	(setq p2 (vlax-curve-getpointatdist e (+ d a)))
		(setq p3 (vlax-curve-getpointatdist e (- d a)))
	   )
	 (cond
	   ((= (fix (vlax-curve-getparamatpoint e p2)) (fix (vlax-curve-getparamatpoint e p3)) i)
	    (vlax-invoke o 'addvertex (setq i (1+ i)) (mapcar '+ p2 '(0 0)))
	    (vlax-invoke o 'addvertex i (mapcar '+ p3 '(0 0)))
	    (vla-setbulge
	      o
	      i
	      (if (< (angle '(0 0 0) p2) (angle '(0 0 0) p3))
		-1.
		1.
	      )
	    )
	   )
	   ((princ "\nVertex overlap! Pick another point..."))
	 )
       )
      )
      (princ "\nObject needs to be a lwpolyline...")
    )
  )
  (princ)
)

 

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