Mohamed_Essam_2000 Posted November 21 Posted November 21 I need a lisp to draw circles (1.5mm Dia ) on the ends of one selected line after that trim inside the circles then delete the line. Quote
fuccaro Posted November 22 Posted November 22 @Mohamed_Essam_2000 I think you should learn to code. AutoLisp is not hard to learn... Quote
fuccaro Posted November 22 Posted November 22 Quote [...] after that trim inside the circles then delete the line. I think you meant "then delete the circles" AutoCAD already has a built-in command for that. Search the help file for LENGTHEN. Use the Delta option and enter -0.75 (negative number!) to get the line shortened. Also to make a line shorter, the Lisp I posted as answer to your other request (to extend a line) can be rewritten to suit your need. To rewrite it - that will be your pleasure! Quote
Jonathan Handojo Posted November 23 Posted November 23 16 hours ago, fuccaro said: @Mohamed_Essam_2000 I think you should learn to code. AutoLisp is not hard to learn... When I first started learning, I could barely get any functions running... with which I didn't know any way to debug. Like, I didn't understand what the heck the DXF codes are (why 8? why 40?), or what the heck assoc and cdr are. It wasn't easy for me, at least. Quote
ronjonp Posted November 26 Posted November 26 (edited) @Mohamed_Essam_2000 Here's a quick one to draw the line and add circles at the end: (defun c:foo (/ _circle d p1 p2 r) ;; RJP » 2024-11-26 (defun _circle (p r) (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r)))) (cond ((and (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify next point: ")) ) (_circle p1 (setq r 0.75)) (_circle p2 r) (entmakex (list '(0 . "LINE") (cons 10 (polar p1 (angle p1 p2) (setq d (- (distance p1 p2) r)))) (cons 11 (polar p2 (angle p2 p1) d)) ) ) ) ) (princ) ) And one to select lines: (defun c:foo (/ _circle d el p1 p2 r s) ;; RJP » 2024-11-26 (defun _circle (p r) (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r)))) (cond ((setq s (ssget ":L" '((0 . "LINE")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (_circle (setq p1 (cdr (assoc 10 (setq el (entget e))))) (setq r 0.75)) (_circle (setq p2 (cdr (assoc 11 (entget e)))) r) (setq el (entmod (subst (cons 10 (polar p1 (angle p1 p2) r)) (assoc 10 el) el))) (entmod (subst (cons 11 (polar p2 (angle p2 p1) r)) (assoc 11 el) el)) ) ) ) (princ) ) Edited November 26 by ronjonp 1 Quote
Mohamed_Essam_2000 Posted November 26 Author Posted November 26 3 hours ago, ronjonp said: @Mohamed_Essam_2000 Here's a quick one to draw the line and add circles at the end: (defun c:foo (/ _circle d p1 p2 r) ;; RJP » 2024-11-26 (defun _circle (p r) (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r)))) (cond ((and (setq p1 (getpoint "\nSpecify first point: ")) (setq p2 (getpoint p1 "\nSpecify next point: ")) ) (_circle p1 (setq r 0.75)) (_circle p2 r) (entmakex (list '(0 . "LINE") (cons 10 (polar p1 (angle p1 p2) (setq d (- (distance p1 p2) r)))) (cons 11 (polar p2 (angle p2 p1) d)) ) ) ) ) (princ) ) And one to select lines: (defun c:foo (/ _circle d el p1 p2 r s) ;; RJP » 2024-11-26 (defun _circle (p r) (entmakex (list '(0 . "CIRCLE") (cons 10 p) (cons 40 r)))) (cond ((setq s (ssget ":L" '((0 . "LINE")))) (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (_circle (setq p1 (cdr (assoc 10 (setq el (entget e))))) (setq r 0.75)) (_circle (setq p2 (cdr (assoc 11 (entget e)))) r) (setq el (entmod (subst (cons 10 (polar p1 (angle p1 p2) r)) (assoc 10 el) el))) (entmod (subst (cons 11 (polar p2 (angle p2 p1) r)) (assoc 11 el) el)) ) ) ) (princ) ) That's very nice. Thank you, bro. Quote
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.