Click and Trim line(s)

Click and Trim line(s)

AkWillNorris
Explorer Explorer
986 Views
5 Replies
Message 1 of 6

Click and Trim line(s)

AkWillNorris
Explorer
Explorer

Hello! 

I am looking for a lisp that facilitates clicking an intersection point between two lines, then clicking the line that needs to be trimmed. The line selected will then be trimmed on both sides of the intersecting line. The distance can be predetermined, or if possible a prompt asking for trim distance. 

I tried inserting the picture examples to make it easier, however for whatever reason it would only let me attach.

"ONE" shows the intersecting lines, the square is what I typically use to trim the intersecting line. "TWO" shows the trim result. In this instance, I had a total of 3 inches, 1.5 on each side, trimmed. 

If possible, it would save me quite a bit of time if I could pick  intersecting lines and perform this command without having to copy and paste a square each and every time for the proper distance.

Thank you for your time and help.

 

0 Likes
Accepted solutions (1)
987 Views
5 Replies
  • Trim
Replies (5)
Message 2 of 6

devitg
Advisor
Advisor

@AkWillNorris For better understanding, and maybe get further help, please upload such sample.dwg
As far as I know, ACAD only can edit DWG.

0 Likes
Message 3 of 6

ВeekeeCZ
Consultant
Consultant
Accepted solution

Not sure if I understood what desired result should look like, but give this try.

 

(defun c:Xgap ( / p c)

  (or *xgap* (setq *xgap* 3.)) ; change default gap here
  
  (while (progn
	   (initget "Gap")
	   (setq p (getpoint (strcat "\nPick a point or change [Gap] of " (rtos *xgap*) ": "))))

    (if (= p "Gap")
      (setq *xgap* (getdist "\nSpecify distance for gap: "))
      (progn
	(setq c (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 (/ *xgap* 2.)))))
	(command "_.trim" c "" pause "")
	(entdel c))))
  (princ)
  )
Message 4 of 6

AkWillNorris
Explorer
Explorer

Thank you! This is basically what I needed. I tried uploading/inserting a picture showing what I was requesting, however I have been having issues trying to do so.

Thank you for your quick reply. 🙂

0 Likes
Message 5 of 6

Kent1Cooper
Consultant
Consultant

Try >this<.

Kent Cooper, AIA
0 Likes
Message 6 of 6

ВeekeeCZ
Consultant
Consultant

One more version. Just pick a line you want to break at a point close to an intersection point - it will beak it at the closest-one if the line crosses more lines.

 

(vl-load-com)

(defun c:Xgap ( / LM:intersections LM:intersectionsinset s p e d f x)
  
  (or *xgap* (setq *xgap* 3.)) ; change default gap here

  ;; Intersections  -  Lee Mac
  (defun LM:intersections ( ob1 ob2 mod / lst rtn )
    (if (and (vlax-method-applicable-p ob1 'intersectwith)
	     (vlax-method-applicable-p ob2 'intersectwith)
	     (setq lst (vlax-invoke ob1 'intersectwith ob2 mod))
	     )
      (repeat (/ (length lst) 3)
	(setq rtn (cons (list (car lst) (cadr lst) (caddr lst)) rtn)
	      lst (cdddr lst))))
    (reverse rtn))
  
  (defun LM:intersectionsinset ( sel / id1 id2 ob1 ob2 rtn )
    (repeat (setq id1 (sslength sel))
      (setq ob1 (vlax-ename->vla-object (ssname sel (setq id1 (1- id1)))))
      (repeat (setq id2 id1)
	(setq ob2 (vlax-ename->vla-object (ssname sel (setq id2 (1- id2))))
	      rtn (cons (LM:intersections ob1 ob2 acextendnone) rtn))))
    (apply 'append (reverse rtn)))
  
  ; -------------------------------------------------------------------------------------------------------
  
  (while (progn
	   (initget "Gap Undo")
	   (setq s (entsel (strcat "\nPick breakingline or change" (rtos *xgap*) " [Gap/Undo]: "))))
    
    (cond ((= s "Gap")		(setq *xgap* (getdist "\nSpecify gap distance: ")))
	  ((= s "Undo")		(command "_.U"))
	  ((and s
		(setq p (cadr s))
		(setq e (car s))
		(setq d (entget e))
		(or (= "LINE" (cdr (assoc 0 d)))
		    (prompt "\nError: Selected entity is not a LINE!"))
		(setq f (ssget "_F" (list (trans (cdr (assoc 10 d)) 0 1) (trans (cdr (assoc 11 d)) 0 1)) '((0 . "LINE"))))
		(setq f (if (ssmemb e f)
			  f
			  (ssadd e f)))
		(or (> (sslength f) 1)
		    (prompt "\nError: No crossing line found!"))
		(setq x (LM:intersectionsinset f))
		(setq x (car (vl-sort (mapcar '(lambda (i) (trans i 0 1)) x) '(lambda (i1 i2) (< (distance i1 p) (distance i2 p))))))
		)
	   (command "_.break" e
		    "_non" (polar x (angle x (cdr (assoc 10 d))) (/ *xgap* 2.))
		    "_non" (polar x (angle (cdr (assoc 10 d)) x) (/ *xgap* 2.))))))
  (princ)
  )

 

 
0 Likes