Mohz Posted February 24 Posted February 24 Can I get a lisp to mirror my selection using one point only , one command vertically & other one for Horizontally Quote
Steven P Posted February 25 Posted February 25 (edited) Above seams a bit long winded try this, as requested 2 commands vertical and horizontal which in this case is probably the quickest option. Add option into the LISP and the command you want to make quicker becomes slower with more user inputs. Commands hmirror and cmirror. (defun c:vmirror ( / MySS Pt1 Pt2) (princ "\nSelect Objects: [Vertical Mirror] ") (setq MySS (ssget)) ;; select objects/ Filter this if you want to limit what is selected (setq Pt1 (getpoint "\nSelect Mirror Axis Point: ")) ;; get a point (setq Pt2 (mapcar '+ '(0 5 0) Pt1)) ;; make Pt2 5 more in the Y axis - vertically upwards (command "Mirror" MySS "" Pt1 Pt2 Pause) ;; Mirror commmand. Retain pause at the end to keep "retain objects" option ) (defun c:hmirror ( / MySS Pt1 Pt2) ;; Comments as above (princ "\nSelect Objects: [Horizontal Mirror] ") (setq MySS (ssget)) (setq Pt1 (getpoint "\nSelect Mirror Axis Point: ")) (setq Pt2 (mapcar '+ '(5 0 0) Pt1)) (command "Mirror" MySS "" Pt1 Pt2 Pause) ) Edited February 25 by Steven P Quote
Steven P Posted February 25 Posted February 25 (edited) and a little shorter code... Sunday night and time to sit for 20 minutes. Swap it around for vertical mirror (defun c:hmirror ( / ) ;; Comments as above (command "Mirror" (ssget) "" (getpoint "\nSelect Mirror Axis Point: ") (mapcar '+ '(5 0 0) (getvar 'lastpoint)) Pause) ) Edited February 25 by Steven P 1 Quote
Jonathan Handojo Posted February 25 Posted February 25 (edited) This only assumes the horizontal and vertical lines are drawn in UCS, and not WCS: (defun c:vmirror nil (OnePointMirror '(00 10 00))) (defun c:hmirror nil (OnePointMirror '(10 00 00))) (defun OnePointMirror (dir / ss pt) (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (mapcar '+ dir pt) "No") ;; <--- Change to Yes to delete source object, or \\ to prompt user. (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) And while this may be off the OP, this might be worth looking at as well: Quick Mirror. Edited February 25 by Jonathan Handojo 4 Quote
DELLA MAGGIORA YANN Posted February 26 Posted February 26 Bonjour, super zézaiement, je cherche depuis longtemps, merci Serait-il possible d’avoir une version où l’objet en miroir disparaît ? et un autre à un angle de 45° ? Ce serait génial merci encore, vraiment Quote
Steven P Posted February 26 Posted February 26 45 degree angle... In all the codes above there is a list something like this: '(0 5 0), change that so the first 2 numbers are the same: '(5 5 0) and use a negative value to rotate the 45 degree angle line: examples: '(5 5 0) '(5 -5 0) '(-10 -10 00) '(-10 10 00) 1 Quote
Jonathan Handojo Posted February 26 Posted February 26 Or if you need it to be something other than 45 degrees: (polar '(0 0 0) (cvunit <your_angle_in_degrees> "degrees" "radians") 10) 3 Quote
DELLA MAGGIORA YANN Posted March 14 Posted March 14 On 2/25/2024 at 10:09 PM, Jonathan Handojo said: Cela suppose uniquement que les lignes horizontales et verticales sont tracées dans le SCU, et non dans le SCG : (defun c:vmirror nil (OnePointMirror '(00 10 00))) (defun c:hmirror nil (OnePointMirror '(10 00 00))) (defun OnePointMirror (dir / ss pt) (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (mapcar '+ dir pt) "No") ;; <--- Change to Yes to delete source object, or \\ to prompt user. (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) Et bien que cela puisse être hors de l’OP, cela pourrait également valoir la peine d’être regardé : Miroir rapide. everything works perfectly I would like to ask you something if possible. I associated lisp with icons, 1 icon for vertical mirror 1 icon for horizontal mirror 1 icon for 45° and -45° mirror all this with deletion of the original object. I wanted to do the same and keep the original object, however it does not work, in fact it modifies my first orders can you help me ? Quote
mhupp Posted March 14 Posted March 14 Make Yes or no a variable then move it to the other side of / in the defun line. this means you will need to add a call like the dir variable (defun c:KeepHmirror nil (OnePointMirror '(10 00 00) "No")) ;keep source (defun c:DeleteHmirror nil (OnePointMirror '(10 00 00) "Yes")) ;delete source (defun OnePointMirror (dir del / ss pt) ;del is yes or no to delete (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (mapcar '+ dir pt) del) ;; <--- Change to Yes to delete source object, or \\ to prompt user. (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) 1 Quote
Jonathan Handojo Posted March 14 Posted March 14 10 hours ago, DELLA MAGGIORA YANN said: everything works perfectly I would like to ask you something if possible. I associated lisp with icons, 1 icon for vertical mirror 1 icon for horizontal mirror 1 icon for 45° and -45° mirror all this with deletion of the original object. I wanted to do the same and keep the original object, however it does not work, in fact it modifies my first orders can you help me ? Creating an icon for a LISP code is possible, but it involves modifying your ribbons through the user interface. For starters, I've made you this ribbon that you can use to display the icons in the ribbon. You can have a look into how to use Partial Customization Files to initialise it into your AutoCAD. However, you need to have this one below loaded, not the above (as the command names have been set to these ones in the CUI). In addition, with enough practice, you may even add more of your own codes to this ribbon if you so desire: (defun c:1pm-h nil (OnePointMirror 0 "No")) (defun c:1pm-hd nil (OnePointMirror 0 "Yes")) (defun c:1pm-v nil (OnePointMirror 90 "No")) (defun c:1pm-vd nil (OnePointMirror 90 "Yes")) (defun c:1pm-45 nil (OnePointMirror 45 "No")) (defun c:1pm-45d nil (OnePointMirror 45 "Yes")) (defun c:1pm--45 nil (OnePointMirror -45 "No")) (defun c:1pm--45d nil (OnePointMirror -45 "Yes")) (defun OnePointMirror (ang del / ss pt) (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (polar pt (cvunit ang "degrees" "radians") 30.0) del) (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) 6 hours ago, mhupp said: Make Yes or no a variable then move it to the other side of / in the defun line. this means you will need to add a call like the dir variable (defun c:KeepHmirror nil (OnePointMirror '(10 00 00) "No")) ;keep source (defun c:DeleteHmirror nil (OnePointMirror '(10 00 00) "Yes")) ;delete source (defun OnePointMirror (dir del / ss pt) ;del is yes or no to delete (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (mapcar '+ dir pt) del) ;; <--- Change to Yes to delete source object, or \\ to prompt user. (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) FYI @mhupp, using macros would've sufficed just as well. Instead of "Yes" and "No", you can use "\\" and create a macro called KeepHmirror and DeleteHmirror in which you fix the inputs "Yes" and "No" into the macro itself. LISP Codes.cuix Quote
DELLA MAGGIORA YANN Posted March 15 Posted March 15 7 hours ago, Jonathan Handojo said: La création d’une icône pour un code LISP est possible, mais cela implique de modifier vos rubans via l’interface utilisateur. Pour commencer, je vous ai créé ce ruban que vous pouvez utiliser pour afficher les icônes du ruban. Vous pouvez découvrir comment utiliser les fichiers de personnalisation partielle pour l’initialiser dans votre AutoCAD. Cependant, vous devez avoir celui-ci ci-dessous chargé, pas le ci-dessus (car les noms de commande ont été définis sur ceux-ci dans le CUI). De plus, avec suffisamment de pratique, vous pouvez même ajouter d’autres de vos propres codes à ce ruban si vous le souhaitez : (defun c:1pm-h nil (OnePointMirror 0 "No")) (defun c:1pm-hd nil (OnePointMirror 0 "Yes")) (defun c:1pm-v nil (OnePointMirror 90 "No")) (defun c:1pm-vd nil (OnePointMirror 90 "Yes")) (defun c:1pm-45 nil (OnePointMirror 45 "No")) (defun c:1pm-45d nil (OnePointMirror 45 "Yes")) (defun c:1pm--45 nil (OnePointMirror -45 "No")) (defun c:1pm--45d nil (OnePointMirror -45 "Yes")) (defun OnePointMirror (ang del / ss pt) (and (setq ss (ssget "_:L")) (setq pt (getpoint "\nSpecify base point <exit>: ")) (command "_mirror" ss "" "_non" pt "_non" (polar pt (cvunit ang "degrees" "radians") 30.0) del) (while (not (zerop (getvar "cmdactive"))) (command "")) ) (princ) ) FYI @mhupp, l’utilisation de macros aurait tout aussi bien suffi. Au lieu de « Oui » et « Non », vous pouvez utiliser « \\ » et créer une macro appelée KeepHmirror et DeleteHmirror dans laquelle vous fixez les entrées « Oui » et « Non » dans la macro elle-même. Codes LISP.cuixRécupération d’informations... I thank you for all your advice for order creation with icon, I manage. I have bricscad 2024. It's quite simple to do on Bricscad. for my problem I found another solution, I found another lisp which did the same thing as my first lisp and which has no influence on it, so it's all good for me Thank you so much.... Quote
mhupp Posted March 15 Posted March 15 13 hours ago, Jonathan Handojo said: FYI @mhupp, using macros would've sufficed just as well. Instead of "Yes" and "No", you can use "\\" and create a macro called KeepHmirror and DeleteHmirror in which you fix the inputs "Yes" and "No" into the macro itself. Are you not doing the same thing I suggested with these calls? (defun c:1pm-h nil (OnePointMirror 0 "No")) Quote
BIGAL Posted March 16 Posted March 16 (edited) Using pop menus rather than ribbon is very easy to have choices. Another as you want 4 choices is use a custom dcl with 4 squares so pick the one you want, uses slides for the images. This is 3x3 Edited March 16 by BIGAL 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.