RIA Posted August 7, 2021 Share Posted August 7, 2021 Quote Link to comment Share on other sites More sharing options...
devitg Posted August 7, 2021 Share Posted August 7, 2021 10 hours ago, RIA said: For better understanding, and maybe get further help, please upload such sample.dwg. State constraints Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 7, 2021 Share Posted August 7, 2021 Like devitg the constraints, can be input values or hard coded. Quote Link to comment Share on other sites More sharing options...
RIA Posted August 8, 2021 Author Share Posted August 8, 2021 Dear Bigal your ss is perfect for me req Quote Link to comment Share on other sites More sharing options...
Ajmal Posted August 8, 2021 Share Posted August 8, 2021 (edited) can you try this, i am not expert maybe this is what you ask. this is i copy from another code and i just edit something (defun c:test(/ ew_layer p1 p2 msg height ang ent lent) (setq clayer(getvar "clayer") height (/ 250 (getvar "CANNOSCALEVALUE")) ang 45) (if (setq ent(entget(setq lent(car(entsel "/nSelect object"))))) (progn (setq p1(cdr(assoc 10 ent)) p2(cdr(assoc 10(reverse ent)))) (draw-ew p1 p2 clayer) (entdel lent) ) ) (princ) ) (defun draw-ew (p4 p1 lay / p2 p3) (setq p2 (polar p1 (- (angle p1 p4) (/ (* ang pi) 180)) height) p3 (polar p4 (+ (angle p4 p1) (/ (* ang pi) 180)) height) ) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 lay) (cons 90 4) '(70 . 0) (cons 10 (trans p1 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p2 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p3 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p4 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) '(210 0.0 0.0 1.0) ) ) ) this is with fillet (defun c:test(/ ew_layer p1 p2 msg height ang ent lent) (setq clayer(getvar "clayer") height (/ 250 (getvar "CANNOSCALEVALUE")) ang 45) (if (setq ent(entget(setq lent(car(entsel "/nSelect object"))))) (progn (setq p1(cdr(assoc 10 ent)) p2(cdr(assoc 10(reverse ent)))) (draw-ew p1 p2 clayer) (entdel lent) (command "_.fillet" "_r" height) (command "_.fillet" "_p" (entlast)) ) ) (princ) ) (defun draw-ew (p4 p1 lay / p2 p3) (setq p2 (polar p1 (- (angle p1 p4) (/ (* ang pi) 180)) height) p3 (polar p4 (+ (angle p4 p1) (/ (* ang pi) 180)) height) ) (entmakex (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 8 lay) (cons 90 4) '(70 . 0) (cons 10 (trans p1 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p2 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p3 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) (cons 10 (trans p4 1 0)) '(40 . 0.0) '(41 . 0.0) '(42 . 0.0) '(210 0.0 0.0 1.0) ) ) ) Edited August 8, 2021 by Ajmal Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 9, 2021 Share Posted August 9, 2021 (edited) Another, change off and rad to suit. ; 45 ends to a single line or pline ; BY alanH info@alanh.com.au ; Aug 2021 (defun doline ( / d1 d2) (setq pt1 (vlax-get Obj 'StartPoint)) (setq pt2 (vlax-get Obj 'EndPoint)) (setq d1 (distance pt1 pt3) d2 (distance pt2 pt3) ) (if (< d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) (princ) ) (defun dopl ( / d1 d2 temp) (setq pt1 (vlax-curve-getStartPoint obj)) (setq pt2 (vlax-curve-getEndPoint obj)) (setq d1 (distance pt1 pt3) d2 (distance pt2 pt3) ) (if (< d1 d2) (progn (setq temp pt1) (setq pt1 pt2) (setq pt2 temp) ) ) (princ) ) (defun C:45ends ( / oldsnap pt1 pt2 pt3 pt4 pt5 pt6 off rad ent) (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (setq off 10.0 rad 10.0) (setvar 'filletrad rad) (while (setq ent (entsel "\npick p/line near end Enter to exit")) (setq pt3 (cadr ent)) (setq obj (vlax-ename->vla-object (car ent))) (cond ((= (vla-get-objectname obj) "AcDbLine")(doline)) ((= (vla-get-objectname obj) "AcDbPolyline")(dopl)) ) (setq ang (angle pt1 pt2)) (setq pt3 (polar pt1 (- ang (/ pi 2.0)) off)) (setq pt4 (polar pt2 (- ang (/ pi 2.0)) off)) (setq pt5 (polar pt3 (+ (* pi 0.25) ang) off)) (command "line" pt3 pt5 "") (setq pt5 (mapcar '* (mapcar '+ pt3 pt5) '(0.5 0.5))) (command "fillet" ent pt5) (setq pt6 (polar pt4 (+ ang (* pi 0.75)) off)) (command "line" pt4 pt6 "") (setq pt6 (mapcar '* (mapcar '+ pt4 pt6) '(0.5 0.5)))4 (command "fillet" ent pt6) ) (setvar 'osmode oldsnap) (princ) ) Edited August 11, 2021 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
RIA Posted August 9, 2021 Author Share Posted August 9, 2021 Dear Bigal its work for me great. and thank you so much, If you can add options to make the same for multiple lines in a single selection, it will make the tasks superfast. thank you so much. Quote Link to comment Share on other sites More sharing options...
RIA Posted August 9, 2021 Author Share Posted August 9, 2021 ajmal ur program lep to make new lines its great, but for existing Quote Link to comment Share on other sites More sharing options...
Ajmal Posted August 9, 2021 Share Posted August 9, 2021 you need existing line ???? Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 10, 2021 Share Posted August 10, 2021 If ran on multiple lines it would remove the direction of the offset side, I tested on angled lines. Yes it could be changed. A simple pick pick can be added very simply, how many do you want to change in 1 go ? (while (setq ent (entsel "\npick p/line near end ")) ........... .......... .......... (command "fillet" ent pt6) ) ; while (setvar 'osmode oldsnap) Quote Link to comment Share on other sites More sharing options...
RIA Posted August 10, 2021 Author Share Posted August 10, 2021 Hi bigal 10 to 20 lines in one go.. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 11, 2021 Share Posted August 11, 2021 This is pick pick as the number is not huge it still gives then control as to up or down direction. See updated code above. Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 11, 2021 Share Posted August 11, 2021 (edited) I saw this last night and was intrigued, so here is my version, adding in the ability to select many lines (lines and polylines, finishing with filleted polylines)(you can limit this to just polylines). Also because it is for me, option to set the chamfer length, fillet radius and the angle each time (maybe later to fix this to set a value or press enter to keep a value) (defun c:filletends ( / chamferlength chamferangle filletradius MyLines MyLine acount) ;;Get inputs ;;Lengths and Radius ;;modify this as required ;;;;;;;;;;;;;;;;;;;;;;;;;; (setq chamferlength (getreal "\nEnter Chamfer Length: ")) (setq filletradius (getreal (strcat "\nEnter Fillet Radius: "))) (setq chamferangle (getreal "\nEnter Chamfer Angle: ")) ;;-or set angles and lengths in LISP-;; ; (setq chamferlength 10) ; (setq filletradius 10) ; (setq chamferangle 45) ;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Select Lines (princ "Select Lines") (setq MyLines (ssget '((0 . "*LINE") ))) ;;change to LWPOLYLINE if just wanting polylines (setq acount 0) ;;Run Make fillet routine (while (< acount (sslength MyLines)) (setq MyLine (ssname MyLines acount)) (filletends MyLine chamferlength chamferangle filletradius) (setq acount (+ acount 1)) ) (princ) ) ;;Make Fillet Routine (defun filletends ( myline chamferlength chamferangle filletradius / maxfilletradius filletangle lineent enda endb mylinelength mylineangle linea lineb) ;;Subroutines (defun RadtoDeg( r / ) (* 180.0 (/ r pi)) ) (defun DegtoRad (d / ) (* pi (/ d 180.0)) ) (defun TAN (z / ) (/ (sin z) (cos z)) ) ;;Get line end points, length and angle (if ( = (cdr (assoc 0 (entget myline))) "LWPOLYLINE") ;;fixes a thing (progn (command "_.explode" myline) (setq myline (entlast)) ) ) (setq lineent (entget myline)) (setq enda (cdr (assoc 10 lineent)) ) (setq endb (cdr (assoc 11 lineent)) ) (setq mylinelength (distance enda endb)) (setq mylineangle (RadtoDeg (angle enda endb))) ;;If you want, these 2 lines to make the chamfer length and fillet radius a percent of the original line length;; ;; (setq chamferlength (* ( / chamferlength 100.0) mylinelength) ) ;; (setq filletradius (* ( / filletradius 100.0) mylinelength) ) ;;draw lines. Might be faster to do entmake but not much (setq oldsnap (getvar 'osmode)) (setvar 'osmode 0) (command "line" enda (STRCAT "@" (rtos chamferlength) "<" (rtos (- mylineangle (- 180 chamferangle)) 2)) "") (setq linea (entlast)) (command "line" endb (STRCAT "@" (rtos chamferlength) "<" (rtos (- mylineangle chamferangle) 2)) "") (setvar 'osmode oldsnap) (setq lineb (entlast)) (command "_.pedit" "m" linea myline lineb "" "Y" "J" "" "") ;;Make Fillets (if (< chamferlength (/ mylinelength 2)) (setq smallestline chamferlength) (setq smallestline (/ mylinelength 2) ) ) (setq maxfilletradius (abs(* (TAN (DegtoRad ( - 90 (/ (abs chamferangle) 2))) ) smallestline)) ) (if ( > filletradius maxfilletradius) (setq filletradius (* maxfilletradius 0.95)) ) (setvar "filletrad" (abs filletradius)) (command "_.fillet" "_polyline" (entlast)) (princ) ) Edited August 12, 2021 by Steven P Whoops - a mistake in the 'maxfilletradius' line 1 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 12, 2021 Share Posted August 12, 2021 (edited) A couple of suggestions, if you have a pline no need to explode if using VL, (setq start (vlax-curve-getstartpoint Obj ))(setq end (vlax-curve-getendpoint Obj )) Also not sure why you dont just work out everything in radians it is very rare for me to have to use rtd or dtr. Except for entry of angle but all coding would then be in radians. If a pline is more than l section what then ? Same in my code may not be correct. The only reason I did not post a do all auto is simple draw a line left to right, then a second right to left, one answer will go up the other will go down. with plines same thing depends on direction. The red lines show the length of the original line or pline, Your code middle not sure about this, drew 2 plines L-R & R-L 10 10 45. Mine on right choice up down depending on end picked. Also note your answer increased overall length this is up to RIA to confirm the final length required. There are other posts floating around on multiple forums seeking multiple solutions for a number of patterns like this. Edited August 12, 2021 by BIGAL 1 Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 12, 2021 Share Posted August 12, 2021 Thanks BigAl, Degrees and Radians is a simple thing, my mind visualises degrees better than radians, in checking if it says 0.7854 I'd have to think, 45 and I know that. If I can change my mind about it would make these and excel macros easier sometimes. Multiple selection... because she asked for it.. more than likely I'd do this for 1 line at a time. Up or down fillets are tricky, just thinking whether the user could specify clockwise / anticlockwise (in case of a vertical line), and base the fillet direction on that. Direction based on the furthest right point or something (or top point in a vertical line)? Would that work? Exploding the pline at the start, in my code it was confusing itself with small angles and which end to fillet of the 2 open ends were close to each other, I've changed it about since than and it should work as a pline now... thanks for the comment I'll change it back. Multiple pline sections would be useful. Something to think about this afternoon, the boss is still insisting I do do some work each week. Not sure about your screen shot... did my version draw the lines like that or are you showing them like that as an example? It works OK on my machine - always a good get out clause. Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 12, 2021 Share Posted August 12, 2021 7 hours ago, BIGAL said: A couple of suggestions, if you have a pline no need to explode if using VL, (setq start (vlax-curve-getstartpoint Obj ))(setq end (vlax-curve-getendpoint Obj )) This was a quick fix and looks like it works, also with multiple section plines. Take out the commented out lines, add in the others ;;Get line end points, length and angle ; (if ( = (cdr (assoc 0 (entget myline))) "LWPOLYLINE") ;;fixes a thing ; (progn ; (command "_.explode" myline) ; (setq myline (entlast)) ; ) ; ) ; (setq lineent (entget myline)) ; (setq enda (cdr (assoc 10 lineent)) ) ; (setq endb (cdr (assoc 11 lineent)) ) (setq lineent (entget myline)) (setq enda (cdr (assoc 10 lineent)) ) (if ( = (cdr (assoc 0 (entget myline))) "LWPOLYLINE") (setq endb (cdr (assoc 10 (reverse lineent))) ) (setq endb (cdr (assoc 11 lineent)) ) ) Quote Link to comment Share on other sites More sharing options...
Steven P Posted August 12, 2021 Share Posted August 12, 2021 Adding this in after my last post, should set all the lines pointing in the same direction (generally downwards except vertical line where it goes right), knowing it will do that can set the angle as a + or - to give the direction you want (if (> (car enda) (car endb)) (progn (setq tempend enda) (setq enda endb) (setq endb tempend) )) (if (= (car enda) (car endb)) (if (> (cadr enda) (cadr endb)) (progn (setq tempend enda) (setq enda endb) (setq endb tempend) ) )) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 13, 2021 Share Posted August 13, 2021 Not sure why your code gave odd result, I drew the 2 plines on a angle as a test in two directions, You are right I have been using pick an end for direction for like 30 years, you get used to it. RIA waiting for you. 1 Quote Link to comment Share on other sites More sharing options...
yxl030 Posted August 14, 2021 Share Posted August 14, 2021 (edited) Thanks!I've been looking for the lisp like this for ages. How to modify it to do that? draw a pline ,then click the mouse to give the direction Edited August 14, 2021 by yxl030 Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 15, 2021 Share Posted August 15, 2021 Have a look at my code it checks which end did you pick, so the extra pick a side as it appears you only want 1 end. Other way is a left or right prompt. Look at the polar in the code where it works out the new end point. Using a vla-getclosestpointto - pick point will give the angle direction. Inclined lines ok. (Setvar 'filletrad 0.0) so its a chamfer. Have a go if stuck post. 1 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.