Edgtrimmer Posted August 5, 2011 Share Posted August 5, 2011 I draw single line branch piping connecting to mains with a 6"x6" by 45degree chamfer often. If trim option is on, both the main and the branch lines are trimmed. I don't want to trim the main pipe line. I turn off trim option and then have to use fillet to clean up the chamfer with the branch line. Anyone have or know of a modified chamfer command that will only trim one of the two lines? - Thanks. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 5, 2011 Share Posted August 5, 2011 Try this code , I have this write it for your case and you have to select the end point of the line that you want to trim and specify the length of distance that you want the selected line to be trimmed to add a new line with the length that you specified with angle 45. (defun c:test (/ *error* acdoc e d len p1 ent p2 lst clse first second ang) ;; Tharwat 05. 08. 2011 (vl-load-com) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq e (entsel "\n Select line :")) (eq (cdr (assoc 0 (setq ent (entget (car e))))) "LINE") (setq d (getdist "\n Specify the distance :")) ) (progn (vla-StartUndoMark acdoc) (setq len (sqrt (+ (* d d) (* d d)))) (setq p1 (cdr (assoc 10 ent ))) (setq p2 (cdr (assoc 11 ent))) (setq lst (vl-remove-if-not (function (lambda (x) (member (car x) '(0 67 410 8 62 210)) ) ) ent ) ) (setq clse (vlax-curve-getclosestpointto (car e) (trans (cadr e) 1 0)) ) (if (< (distance p1 clse) (distance p2 clse)) (progn (setq first p2) (setq second (polar first (setq ang (angle p2 p1)) (- (distance p2 p1) d) ) ) ) (progn (setq first p1) (setq second (polar first (setq ang (angle p1 p2)) (- (distance p1 p2) d) ) ) ) ) (entmakex (append lst (list (cons 10 (trans first 1 0)) (cons 11 (setq x (trans second 1 0))) ) ) ) (entmakex (append lst (list (cons 10 x) (cons 11 (polar x (+ ang 0.785398) len))) ) ) (entdel (car e)) ) (princ "\n Select a line only !! ") ) (vla-EndUndoMark acdoc) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
pBe Posted August 6, 2011 Share Posted August 6, 2011 Another one: (defun c:Test (/ Line1 Line2 PtOfInters ascnum minDist) (vl-load-com) (setq Chad (cond ( (getdist (strcat "\nEnter Distance: <" (rtos (setq Chad (cond ( Chad ) (72))) 2 2) ">: " ) ) ) ( Chad ) ) ) (setvar 'Trimmode 0) (setvar 'ChamferA (setvar 'ChamferB chad)) (cond ((and (setq line1 (car (entsel "\nSelect Main Pipe line: "))) (setq line2 (car (entsel "\nSelect second line: "))) ) (vl-cmdf "_Chamfer" line1 line2) (setq PtOfInters (vlax-invoke (vlax-ename->vla-object Line2) 'intersectwith (vlax-ename->vla-object (entlast)) acExtendBoth)) (setq minDist (mapcar '(lambda (y) (distance PtOfInters (cdr y))) (list (assoc 10 (entget line2)) (assoc 11 (entget line2))))) (entmod (subst (cons (setq ascnum (if (= (length (member (apply 'min minDist) mindist)) 1) 11 10)) PtOfInters)(assoc ascnum (entget Line2))(entget Line2)) ) ) ) (princ) ) No error handler . no setvar reset..... Hope this helps anyway Quote Link to comment Share on other sites More sharing options...
Edgtrimmer Posted August 9, 2011 Author Share Posted August 9, 2011 (edited) The routine you wrote is much appreciated. It worked great but I was wondering if changing it to control the direction the 45 degree chamfer is drawn would be something you would consider doing as an enhancement? ----- USE CODE TAGS PLEASE! (defun c:test (/ *error* acdoc e d len p1 ent p2 lst clse first second ang) ;; Tharwat 05. 08. 2011 (vl-load-com) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq e (entsel "\n Select line :")) (eq (cdr (assoc 0 (setq ent (entget (car e))))) "LINE") (setq d (getdist "\n Specify the distance :")) ) (progn (vla-StartUndoMark acdoc) (setq len (sqrt (+ (* d d) (* d d)))) (setq p1 (cdr (assoc 10 ent ))) (setq p2 (cdr (assoc 11 ent))) (setq lst (vl-remove-if-not (function (lambda (x) (member (car x) '(0 67 410 8 62 210)) ) ) ent ) ) (setq clse (vlax-curve-getclosestpointto (car e) (trans (cadr e) 1 0)) ) (if (< (distance p1 clse) (distance p2 clse)) (progn (setq first p2) (setq second (polar first (setq ang (angle p2 p1)) (- (distance p2 p1) d) ) ) ) (progn (setq first p1) (setq second (polar first (setq ang (angle p1 p2)) (- (distance p1 p2) d) ) ) ) ) (entmakex (append lst (list (cons 10 (trans first 1 0)) (cons 11 (setq x (trans second 1 0))) ) ) ) (entmakex (append lst (list (cons 10 x) (cons 11 (polar x (+ ang 0.785398) len))) ) ) (entdel (car e)) ) (princ "\n Select a line only !! ") ) (vla-EndUndoMark acdoc) (princ) ) Edited August 9, 2011 by SLW210 INSTALL CODE TAGS!!! Quote Link to comment Share on other sites More sharing options...
Edgtrimmer Posted August 9, 2011 Author Share Posted August 9, 2011 Thanks again Tharwat. I tried this one but it crashes when I pick the branch line. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 9, 2011 Share Posted August 9, 2011 Perhaps thin one would work with all angle degrees . (defun c:test (/ *error* acdoc e d a len p1 ent p2 lst clse first second ang) ;; == Tharwat 09. 08. 2011 == ;; (vl-load-com) (defun *error* ( msg ) (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*") (princ (strcat "\n** Error: " msg " **"))) (princ) ) (setq acdoc (vla-get-ActiveDocument (vlax-get-acad-object))) (if (and (setq e (entsel "\n Select line :")) (eq (cdr (assoc 0 (setq ent (entget (car e))))) "LINE") (setq d (getdist "\n Specify the distance :")) (setq a (getangle "\n Specify the angle :")) ) (progn (vla-StartUndoMark acdoc) (setq len (sqrt (+ (* d d) (* d d)))) (setq p1 (cdr (assoc 10 ent ))) (setq p2 (cdr (assoc 11 ent))) (setq lst (vl-remove-if-not (function (lambda (x) (member (car x) '(0 67 410 8 62 210)) ) ) ent ) ) (setq clse (vlax-curve-getclosestpointto (car e) (trans (cadr e) 1 0)) ) (if (< (distance p1 clse) (distance p2 clse)) (progn (setq first p2) (setq second (polar first (setq ang (angle p2 p1)) (- (distance p2 p1) d) ) ) ) (progn (setq first p1) (setq second (polar first (setq ang (angle p1 p2)) (- (distance p1 p2) d) ) ) ) ) (entmakex (append lst (list (cons 10 (trans first 1 0)) (cons 11 (setq x (trans second 1 0))) ) ) ) (entmakex (append lst (list (cons 10 x) (cons 11 (polar x (+ ang a) len))) ) ) (entdel (car e)) ) (princ "\n Select a line only !! ") ) (vla-EndUndoMark acdoc) (princ) ) Tharwat Quote Link to comment Share on other sites More sharing options...
Edgtrimmer Posted August 10, 2011 Author Share Posted August 10, 2011 Thank you for the revised single line chamfer routine! It's works fine and it is generous of you to help me with my request. -Bruce Quote Link to comment Share on other sites More sharing options...
Tharwat Posted August 10, 2011 Share Posted August 10, 2011 Thank you for the revised single line chamfer routine! It's works fine and it is generous of you to help me with my request. -Bruce You're welcome Bruce . I am happy to be able to help you . Tharwat Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.