ALBANEXTDOOR Posted January 8, 2023 Posted January 8, 2023 Please help me create this lisp. pls pls. Quote
Steven P Posted January 8, 2023 Posted January 8, 2023 How far have you got with this yourself? Obviously we don't know your abilities with LISP so it might be useful to show if you have done anything or if you have no idea where to start and need guidance the whole way - both are OK, you're here to learn. The actual LISP should be fairly easy. For your question, 'trim circles inside' how do we know which side of the line is 'inside' and 'outside. You might want to post a sample drawing showing perhaps a before and after so we know for sure what you want Quote
ALBANEXTDOOR Posted January 8, 2023 Author Posted January 8, 2023 Thanks for replying my queries. Here's the item I want to automate, the circle on each edge of vertex and at the same time trim the line inside the circle. Does it possible.? I'm gladly appreciate your help. Quote
devitg Posted January 8, 2023 Posted January 8, 2023 How do you want to trim the circle at the end and start vertex. Please upload as DWG, and how far you went on LISP. Quote
ALBANEXTDOOR Posted January 8, 2023 Author Posted January 8, 2023 Hello initially, I coded this : (defun C:CC (/ coords ent rad) (setq rad (getreal"\nEnter radius: ")) (while (setq ent (entsel "\nSelect polyline (or press Enter to Exit) >> ")) (setq ent (car ent)) (setq coords (vl-remove-if 'not (mapcar (function (lambda(p) (if (= 10 (car p))(cdr p)))) (entget ent)))) (foreach pt coords (command "_circle" "_non" pt rad) ) ) (princ) ) This will convert polyline vertices to circle. What I want is to automate trim the vertices inside the circle. Hope someone help me to include extrim or any code on this. Thank you sir. 1 Quote
devitg Posted January 8, 2023 Posted January 8, 2023 54 minutes ago, ALBANEXTDOOR said: Hello initially, I coded this : "code erased" This will convert polyline vertices to circle. What I want is to automate trim the vertices inside the circle. Hope someone help me to include extrim or any code on this. Thank you sir. Ok , how do you need or want to trim the circles at both end and start points. Please upload you sample.dwg with a BEFORE and an AFTER Quote
Steven P Posted January 8, 2023 Posted January 8, 2023 also though this probably doesn't apply to what you do, where would you trim in this case? Quote
devitg Posted January 8, 2023 Posted January 8, 2023 maybe some like it No arc at start neither end vertex 1 Quote
Tsuky Posted January 8, 2023 Posted January 8, 2023 And why not apply a donut of white color and the circle of the color of the current layer? So in paper space or when printing it will look the same as if the polyline was adjusted. In addition you keep your polyline in one piece... (defun C:CC (/ coords ent rad) (initget 7) (setq rad (getdist "\nEnter radius: ")) (while (setq ent (entsel "\nSelect polyline (or press Enter to Exit) >> ")) (setq ent (car ent) coords (vl-remove-if 'not (mapcar (function (lambda (p) (if (= 10 (car p)) (cdr p)) ) ) (entget ent) ) ) ) (foreach pt coords (entmake (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) (cons 8 (getvar "CLAYER")) '(62 . 7) '(420 . 16777215) '(100 . "AcDbPolyline") '(90 . 2) '(70 . 1) (cons 43 rad) (cons 38 (getvar "ELEVATION")) (cons 39 (getvar "THICKNESS")) '(39 . 0.0) (cons 10 (trans (list (+ (car pt) (* 0.5 rad)) (cadr pt)) 1 0)) (cons 40 rad) (cons 41 rad) '(42 . 1.0) '(91 . 0) (cons 10 (trans (list (- (car pt) (* 0.5 rad)) (cadr pt)) 1 0)) (cons 40 rad) (cons 41 rad) '(42 . 1.0) '(91 . 0) '(210 0.0 0.0 1.0) ) ) (entmake (list '(0 . "CIRCLE") '(100 . "AcDbEntity") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) (cons 8 (getvar "CLAYER")) (cons 10 (trans pt 1 0)) (cons 40 rad) '(210 0.0 0.0 1.0) ) ) ) ) (princ) ) 2 Quote
Steven P Posted January 8, 2023 Posted January 8, 2023 Anyway, this might be as good starting point for you? https://autocadtips1.com/2012/03/08/autolisp-trim-objects-on-one-side/ I haven't tried this yet but if you make a selection set of the circles as you create them, to be variable t1 in this code, the polyline to be a selection set, e, and then you can use something like (setq p (osnap (vlax-curve-getStartPoint (entlast)) "gcen")) as the point p, side to trim on. However... I think this will only work if the polyline is a closed polyline - which should be OK to do, copy the existing polyline and call this new line a name (setq Polyinename (entlast)) - something like that. Something like this from Lee Mac (http://lee-mac.com/polylineprograms.html) will close a polyline. So with a closed polyline I think this should work. Trim the circles, delete this temporary polyline (which you can do since you were bullying calling it names). Errors might do strange things such as leaving the temporary polyline in place. For Devtigs question, what to do with the end circles, this will trim them as if the missing link in the polyline is there. If you want to do something else then don't add them to the polyline.. Right, kind of hoping you follow all of that? 1 Quote
Steven P Posted January 8, 2023 Posted January 8, 2023 (edited) 4 hours ago, ALBANEXTDOOR said: What I want is to automate trim the vertices inside the circle. Ahh, have I got my answer the wrong way round by the way? I am trimming the circles and leaving the polyline as it was. Are you wanting to leave the circles and trimming the polyline Which the link will do just needs to think the other way round -EDIT- This will cut a polyline out of the circles as above picture, (defun C:CC (/ coords ent rad e t1) (defun MTR (e t1 p / l c) (command "TRIM" e "") (command (list t1 p)) (command "") ) (setq rad (getreal"\nEnter radius: ")) (while (setq ent (car (entsel "\nSelect polyline (or press Enter to Exit) >> "))) (setq t1 ent) (setq coords (vl-remove-if 'not (mapcar (function (lambda(p) (if (= 10 (car p))(cdr p)) )) (entget ent) ) ; end mapcar )) ; end setq, vl-remove-if (setq coords (reverse coords)) (foreach pt coords (command "_circle" "_non" pt rad) (setq e nil) (setq e (entlast)) (setq p (assoc 10 (entget e))) (setq p (list (cadr p) (caddr p) (cadddr p))) (command "TRIM" e "") (command (list t1 p)) (command "") ) ; end foreach ) ; end while (princ) ) Edited January 8, 2023 by Steven P 1 Quote
Isaac26a Posted January 8, 2023 Posted January 8, 2023 Maybe this would work ;;; By Isaac A. ;;; https://www.cadtutor.net/forum/topic/76618-how-to-create-circle-in-every-corner-of-polyline-and-trim-circles-inside/ ;;; Draws circles in every vertex of plines and trims them (defun c:ctri (/ b foo ss) (if (not etrim) (load "extrim.lsp")) (defun foo (p) ;; Alan J. Thompson, 09.09.10 ;; https://www.cadtutor.net/forum/topic/25037-drawing-circles-to-all-vertices-of-polyline/ (if (vl-consp p) (or (vl-member-if (function (lambda (a) (equal (list (car a) (cadr a)) (list (car p) (cadr p))))) plst ) (setq plst (cons (cdr (assoc 10 (entmake (list '(0 . "CIRCLE") (cons 10 p) (cons 40 b))) ) ) pLst ) ) ) ) ) (if (and (setq ss (ssget '((0 . "*POLYLINE")))) (not (initget 6)) ;;; (setq i -1) (setq b (getdist "\nSpecify circle radius :")) ) ((lambda (i / e eLst p pLst) (while (setq e (ssname ss (setq i (1+ i)))) (vl-position (cdr (assoc 0 (entget e))) '("LWPOLYLINE" "POLYLINE")) (repeat (setq p (1+ (fix (vlax-curve-getEndParam e)))) (foo (vlax-curve-getPointAtParam e (setq p (1- p)))) ) (etrim e (ia:midp (vlax-curve-getStartPoint e) (vlax-curve-getEndPoint e))) ;;; (osnap (vlax-curve-getStartPoint e) "gcen") ) ) -1 ) ) (princ) ) ;;; ia:midp ;;; Returns the midpoint of 2 given points (defun ia:midp (a b) (mapcar '* (mapcar '+ a b) '(0.5 0.5 0.5)) ) Although most of the code is from Alan J. T., thanks for sharing your codes. This will work with open polylines but as has been said it will not work on the start and end point because it needs 2 points on the polyline to trim the circles. HTH. 1 Quote
ALBANEXTDOOR Posted January 9, 2023 Author Posted January 9, 2023 7 hours ago, Steven P said: Ahh, have I got my answer the wrong way round by the way? I am trimming the circles and leaving the polyline as it was. Are you wanting to leave the circles and trimming the polyline Which the link will do just needs to think the other way round -EDIT- This will cut a polyline out of the circles as above picture, (defun C:CC (/ coords ent rad e t1) (defun MTR (e t1 p / l c) (command "TRIM" e "") (command (list t1 p)) (command "") ) (setq rad (getreal"\nEnter radius: ")) (while (setq ent (car (entsel "\nSelect polyline (or press Enter to Exit) >> "))) (setq t1 ent) (setq coords (vl-remove-if 'not (mapcar (function (lambda(p) (if (= 10 (car p))(cdr p)) )) (entget ent) ) ; end mapcar )) ; end setq, vl-remove-if (setq coords (reverse coords)) (foreach pt coords (command "_circle" "_non" pt rad) (setq e nil) (setq e (entlast)) (setq p (assoc 10 (entget e))) (setq p (list (cadr p) (caddr p) (cadddr p))) (command "TRIM" e "") (command (list t1 p)) (command "") ) ; end foreach ) ; end while (princ) ) This one really works for me. Thanks for the help. Very much appreciated Quote
BIGAL Posted January 9, 2023 Posted January 9, 2023 I would look at using a wipeout rather than a trim then your pline still exists but will look like its broken just make a polygon rather than a circle if you have a reasonable number of sides it will look like a circle. 20 sides 2 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.