dnovember99 Posted January 12, 2018 Share Posted January 12, 2018 SO i was browsing around lee mac's website and came across his http://www.lee-mac.com/quickmirror.html lisp. not sure if this is something that could be done or not (and not saying that lee mac's works isnt good) but rather than doing a mirror the old fashion way by selecting the object, pick a point, drag the mouse, click and then type yes to delete old or no to keep old. lee mac's is a very quick routine to do such a thing. however you have to pick a line in order to mirror said object. i am wondering if there is something out there that someone has that would allow you to do the following: select object (line, polyline, block etc.)type command and drag mouse to the left or to the right and click. so to say have this only be able to mirror on a horizontal plan, and the objects selection point. like below and get that. (hope this makes sense) not sure if this is something that is out there or not but i have yet to find anything. thank you all Quote Link to comment Share on other sites More sharing options...
aawilds Posted January 12, 2018 Share Posted January 12, 2018 I think this might be close to what you want. I just tweaked an old one I made as I was learning to write lisp. (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq obj (entsel "\nSelect Object to Mirror: ")) (setq objinfo (entget (car obj))) (setq objpt (cdr (assoc 10 objinfo))) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" obj "" midpt midend "N" ) (princ) ) Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 12, 2018 Author Share Posted January 12, 2018 I think this might be close to what you want. I just tweaked an old one I made as I was learning to write lisp. (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq obj (entsel "\nSelect Object to Mirror: ")) (setq objinfo (entget (car obj))) (setq objpt (cdr (assoc 10 objinfo))) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" obj "" midpt midend "N" ) (princ) ) this is exactly what i am looking for. i wanted to see about making one minor change? i am not sure how i would add to be able to select multiple object? like text and the leader, a block with a leader? Quote Link to comment Share on other sites More sharing options...
aawilds Posted January 12, 2018 Share Posted January 12, 2018 It should be doable but we are prepping for a big project right now. I just happened to have that mostly done. Maybe someone else can pick it up, sorry. Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 12, 2018 Author Share Posted January 12, 2018 It should be doable but we are prepping for a big project right now. I just happened to have that mostly done. Maybe someone else can pick it up, sorry. hey no worries, that still is a big help to me so thank you Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 12, 2018 Share Posted January 12, 2018 Hi, Something like this? (defun c:mymirror (/ sel pt1 pt2 int ent) (princ "\nSelect objects to mirror :") (and (setq sel (ssget "_:L")) (setq pt1 (getpoint "\nSpecify 1st point :")) (setq int -1 pt2 (getpoint "\nSpecify 2nd point :" pt1)) (while (setq ent (ssname sel (setq int (1+ int)))) (vlax-invoke (vlax-ename->vla-object ent) 'mirror pt1 pt2) (entdel ent) ) ) (princ) ) (vl-load-com) Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 12, 2018 Author Share Posted January 12, 2018 Hi,Something like this? (defun c:mymirror (/ sel pt1 pt2 int ent) (princ "\nSelect objects to mirror :") (and (setq sel (ssget "_:L")) (setq pt1 (getpoint "\nSpecify 1st point :")) (setq int -1 pt2 (getpoint "\nSpecify 2nd point :" pt1)) (while (setq ent (ssname sel (setq int (1+ int)))) (vlax-invoke (vlax-ename->vla-object ent) 'mirror pt1 pt2) (entdel ent) ) ) (princ) ) (vl-load-com) this is very similar to another one that i have seen. but the first code (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq obj (entsel "\nSelect Object to Mirror: ")) (setq objinfo (entget (car obj))) (setq objpt (cdr (assoc 10 objinfo))) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" obj "" midpt midend "N" ) (princ) ) this allows you to be able to make your selection (but only one entity) and then pick a point either to the left or to the right. i am wondering if the part of the code that you have that allows you to be able to select multipule objects can be added to the other? Quote Link to comment Share on other sites More sharing options...
Tharwat Posted January 12, 2018 Share Posted January 12, 2018 i am wondering if the part of the code that you have that allows you to be able to select multipule objects can be added to the other? ssget function allows you to select one or multiple objects if the mode string is not including ":S". Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 12, 2018 Author Share Posted January 12, 2018 ssget function allows you to select one or multiple objects if the mode string is not including ":S". where would i place the (ssget) within this code? (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq obj (entsel "\nSelect Object to Mirror: ")) (setq objinfo (entget (car obj))) (setq objpt (cdr (assoc 10 objinfo))) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" obj "" midpt midend "N" ) (princ) ) Quote Link to comment Share on other sites More sharing options...
BKT Posted January 12, 2018 Share Posted January 12, 2018 where would i place the (ssget) within this code? (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq obj (entsel "\nSelect Object to Mirror: ")) (setq objinfo (entget (car obj))) (setq objpt (cdr (assoc 10 objinfo))) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" obj "" midpt midend "N" ) (princ) ) The problem with trying to substitute SSGET in this code is that ENTSEL gives you a point (objpt) on the selected object. If you want to use the above code you'll need to provide a point somewhere with respect to all of the selected objects. Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 12, 2018 Author Share Posted January 12, 2018 The problem with trying to substitute SSGET in this code is that ENTSEL gives you a point (objpt) on the selected object. If you want to use the above code you'll need to provide a point somewhere with respect to all of the selected objects. OK not saying that i have to use the above code. just saying that this is what i am looking for other than the ability to select more than one thing at a time. i am still new to the lisp world (understanding and writing) Quote Link to comment Share on other sites More sharing options...
BKT Posted January 12, 2018 Share Posted January 12, 2018 OK not saying that i have to use the above code. just saying that this is what i am looking for other than the ability to select more than one thing at a time. i am still new to the lisp world (understanding and writing) Well, you could select the objects using SSGET and then select a point on or near one of the objects (endpoint, screen position, etc.) and then select the point for the mirrored objects. There may be easier ways, and somebody may come along with one, but here's an example using the code you posted, but modified a bit: (defun C:testmirror ( / obj objinfo objpt pt dist ang midpt midend) (setq objs (ssget "\nSelect Objects to Mirror: ")) (setq objpt (getpoint "\nSelect Object Point: ")) (setq pt (getpoint "\nSelect point to left or right")) (setq dist (distance objpt pt)) (setq ang (angle objpt pt)) (setq midpt (polar objpt ang (/ dist 2))) (setq midend (list (car midpt) (- (cadr midpt) 10))) (command "mirror" objs "" midpt midend "N" ) (princ) ) Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 13, 2018 Share Posted January 13, 2018 How about we allow cycling the inputs: (defun C:test ( / L f ) (and (setq L (CycleInputs '( (SS (progn (princ "\n>>Select objects to mirror: ") (ssget "_:L"))) (p1 (progn (initget "Exit") (apply 'getpoint (append (if p2 (list p2)) '("First Point [Exit]: ")))) ) (p2 (progn (initget "Exit") (apply 'getpoint (append (if p1 (list p1)) '("Second Point [Exit]: ")))) ) ) (lambda (s v) (= "Exit" v) ) ); CycleInputs ); setq L (= 3 (length L)) (setq f (lambda (x) (cdr (assoc x L)))) (progn (setvar 'cmdecho 0) (command "_.MIRROR" (f 'SS) "" "_non" (f 'p1) "_non" (f 'p2) "N") (setvar 'cmdecho 1) ) ) (princ) ); defun C:test (defun CycleInputs ( inpL exitf / tmp ) (cond ; (87 114 105 116 116 101 110 32 98 121 32 71 114 114 114) ( (not inpL) inpL) ( (setq tmp (vl-catch-all-apply (function (lambda (a b) (set a (eval b)))) (car inpL))) (cond ( (vl-catch-all-error-p tmp) (prompt (vl-catch-all-error-message tmp)) ) ( (and exitf (vl-catch-all-apply (function exitf) (list (caar inpL) tmp))) (set (caar inpL) nil) ) ( (mapcar (function (lambda (tmp) (set (car tmp) nil) tmp)) (cons (cons (caar inpL) tmp) (CycleInputs (cdr inpL) exitf)) ) ) ) ) ( (CycleInputs (reverse (cons (car inpL) (reverse (cdr inpL)))) exitf) ) ) ) Quote Link to comment Share on other sites More sharing options...
BKT Posted January 13, 2018 Share Posted January 13, 2018 Gotta ask - "exitf"? Maybe just a BricsCAD vs. AutoCAD thing... Quote Link to comment Share on other sites More sharing options...
dnovember99 Posted January 15, 2018 Author Share Posted January 15, 2018 How about we allow cycling the inputs: (defun C:test ( / L f ) (and (setq L (CycleInputs '( (SS (progn (princ "\n>>Select objects to mirror: ") (ssget "_:L"))) (p1 (progn (initget "Exit") (apply 'getpoint (append (if p2 (list p2)) '("First Point [Exit]: ")))) ) (p2 (progn (initget "Exit") (apply 'getpoint (append (if p1 (list p1)) '("Second Point [Exit]: ")))) ) ) (lambda (s v) (= "Exit" v) ) ); CycleInputs ); setq L (= 3 (length L)) (setq f (lambda (x) (cdr (assoc x L)))) (progn (setvar 'cmdecho 0) (command "_.MIRROR" (f 'SS) "" "_non" (f 'p1) "_non" (f 'p2) "N") (setvar 'cmdecho 1) ) ) (princ) ); defun C:test (defun CycleInputs ( inpL exitf / tmp ) (cond ; (87 114 105 116 116 101 110 32 98 121 32 71 114 114 114) ( (not inpL) inpL) ( (setq tmp (vl-catch-all-apply (function (lambda (a b) (set a (eval b)))) (car inpL))) (cond ( (vl-catch-all-error-p tmp) (prompt (vl-catch-all-error-message tmp)) ) ( (and exitf (vl-catch-all-apply (function exitf) (list (caar inpL) tmp))) (set (caar inpL) nil) ) ( (mapcar (function (lambda (tmp) (set (car tmp) nil) tmp)) (cons (cons (caar inpL) tmp) (CycleInputs (cdr inpL) exitf)) ) ) ) ) ( (CycleInputs (reverse (cons (car inpL) (reverse (cdr inpL)))) exitf) ) ) ) ok so i just tested this out and i like it for sure! the only thing that i would say is it possible to be able to have the original be deleted? Quote Link to comment Share on other sites More sharing options...
Grrr Posted January 15, 2018 Share Posted January 15, 2018 ok so i just tested this out and i like it for sure! the only thing that i would say is it possible to be able to have the original be deleted? Yes, thats an easy fix: Change: (command "_.MIRROR" (f 'SS) "" "_non" (f 'p1) "_non" (f 'p2) "[color="red"]N[/color]") To: (command "_.MIRROR" (f 'SS) "" "_non" (f 'p1) "_non" (f 'p2) "[color="red"]Y[/color]") 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.