CADWORKER Posted November 19, 2020 Share Posted November 19, 2020 Hi all, I have a cad file where there are many polylines with 3 vertices(not exactly 90d), and I have to copy the same polyline and paste to the start and end. its like creating closed polygons. Any code, help or advise will be appreicated very much. Thanks Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 19, 2020 Share Posted November 19, 2020 Something like this ? (defun c:Test (/ sel int ent) ;; Tharwat - 19.Nov.2020 ;; ;; Close opened 3 vertices polylines. ;; (and (princ "\nSelect polylines with THREE vertices : ") (setq int -1 sel (ssget '((0 . "*POLYLINE") (90 . 3) (-4 . "<NOT") (-4 . "&=") (70 . 1) (-4 . "NOT>") ) ) ) (while (setq int (1+ int) ent (ssname sel int)) (vlax-invoke (vlax-ename->vla-object ent) 'Mirror (vlax-curve-getstartpoint ent) (vlax-curve-getendpoint ent) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
CADWORKER Posted November 19, 2020 Author Share Posted November 19, 2020 (edited) Tharwat Thanks for your efforts and response. Might be my request was not clear so I have attached a snap for better understanding of my requirement. Thanks once again Edited November 19, 2020 by CADWORKER Quote Link to comment Share on other sites More sharing options...
Jonathan Handojo Posted November 19, 2020 Share Posted November 19, 2020 (edited) The outcome can be of three possibilities (if on the same plane, otherwise infinite possibilities). You need to be clearer. What you want seems to be the parallelogram rule. I could be wrong. Edited November 19, 2020 by Jonathan Handojo Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 19, 2020 Share Posted November 19, 2020 You said that the objects are polylines in the post and the program that I posted in my first reply also mirror the polylines as shown into your image as the final result unless you are referring now to line objects and not polylines ! Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 19, 2020 Share Posted November 19, 2020 Alright, this one for two connected lines. (defun c:Test (/ int sel ent get rtn new lst pt1 pt2 bs1 bs2) ;;------------------------------------;; ;; Tharwat - Date: 19.Nov.2020 ;; ;;------------------------------------;; (and (princ "\nSelect lines to mirror the two conected lines : ") (setq int -1 sel (ssget "_:L" '((0 . "LINE"))) ) (while (setq int (1+ int) ent (ssname sel int) ) (setq get (entget ent) lst (cons (list (cdr (assoc 10 get)) (cdr (assoc 11 get)) get) lst ) ) ) (foreach grp lst (setq pt1 (car grp) pt2 (cadr grp) new (cdr lst) rtn nil ) (while (and new (not (if (cond ((equal pt1 (caar new) 1e-4) (setq bs1 pt2 bs2 (cadar new) ) ) ((equal pt2 (caar new) 1e-4) (setq bs1 pt1 bs2 (cadar new) ) ) ((equal pt1 (cadar new) 1e-4) (setq bs1 pt2 bs2 (caar new) ) ) ((equal pt2 (cadar new) 1e-4) (setq bs1 pt1 bs2 (caar new) ) ) ) (setq rtn (car new)) ) ) ) (setq new (cdr new)) ) (and rtn (not (equal bs1 bs2 1e-4)) (setq lst (vl-remove rtn lst)) (mapcar (function (lambda (o) (vlax-invoke (vlax-ename->vla-object (cdr (assoc -1 (caddr o)))) 'Mirror bs1 bs2 ) ) ) (list grp rtn) ) ) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
CADWORKER Posted November 22, 2020 Author Share Posted November 22, 2020 On 11/19/2020 at 3:11 PM, Tharwat said: You said that the objects are polylines in the post and the program that I posted in my first reply also mirror the polylines as shown into your image as the final result unless you are referring now to line objects and not polylines ! Its my wrong, Actually its not lines its a polyline. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted November 22, 2020 Share Posted November 22, 2020 29 minutes ago, CADWORKER said: Its my wrong, Actually its not lines its a polyline. You already now have two programs, the first program that I posted works for polylines with three vertices and the last one with work with connected two lines. Have not you tried any of them to know how they work? Quote Link to comment Share on other sites More sharing options...
CADWORKER Posted November 23, 2020 Author Share Posted November 23, 2020 14 hours ago, Tharwat said: You already now have two programs, the first program that I posted works for polylines with three vertices and the last one with work with connected two lines. Have not you tried any of them to know how they work? I tried, both the codes; what I was looking was copy from mid to start and end of the plines and not the mirror. Thanks a lot for your cooperation. 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.