Randolph Posted June 6, 2012 Posted June 6, 2012 A small step for a programmer, but a huge step for an architect. I am using an internal system of lisp commands which works like this: TX = translate along x-axis DX = duplicate along x-axis SX = slice YZ-parallel and so on. I tried the same on the MIRROR command an this is the result: ; MIRROR 3D ; ---------------------------------------------------------- (DEFUN C:MX ()(COMMAND "_MIRROR3D" "_YZ")) (DEFUN C:MY ()(COMMAND "_MIRROR3D" "_ZX")) (DEFUN C:MZ ()(COMMAND "_MIRROR3D" "_XY")) Impressive, isn't it. NOW this works fine with previously selected objects. BUT not if you select your objects after the command. Then you have to enter the option (e.g. YZ) afterwards. How can I change my commands to work the way MX- select objects - ENTER? I know that's an easy one for the pros, thanx for your help. Quote
marko_ribar Posted June 6, 2012 Posted June 6, 2012 (defun c:mx ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_zx" pause pause) (princ)) (defun c:my ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_yz" pause pause) (princ)) (defun c:mz ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_xy" pause pause) (princ)) M.R. Quote
Randolph Posted June 6, 2012 Author Posted June 6, 2012 Worxs well, thanx Marko! Here is the version with the corrected options (yz and my were mixed up): (defun c:mx ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_yz" pause pause) (princ)) (defun c:my ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_zx" pause pause) (princ)) (defun c:mz ( / ss) (setq ss (ssget)) (command "_.mirror3d" ss "" "_xy" pause pause) (princ)) Quote
Tharwat Posted June 6, 2012 Posted June 6, 2012 To avoid an error message if the OP did not select any object , add function IF before (setq ss ......... and of course don't forget to add one more paren to close the the IF function . Quote
Randolph Posted June 6, 2012 Author Posted June 6, 2012 Tharwat, that sounds a bit cryptic. I don't get an error message with Marko's code. Could you you code what you wrote for e.g. the MX command? Quote
Tharwat Posted June 6, 2012 Posted June 6, 2012 Tharwat, that sounds a bit cryptic. I don't get an error message with Marko's code. Could you you code what you wrote for e.g. the MX command? Using IF function to guarantee that the function SSGET has a selection of objects to step to the next line of code , but if the SSGET is nil , the function IF would never step to the second line of code since tht it is nil Try your first code and press enter instead of selecting objects and see the error message at the command line , and try the following code with IF function to see the differences . e.g. (defun c:mx ( / ss) [color=blue][b](if [/b][/color](setq ss (ssget)) (command "_.mirror3d" ss "" "_yz" pause pause)[b][color=blue])[/color][/b] (princ)) Quote
pBe Posted June 6, 2012 Posted June 6, 2012 (defun _m3d (filter) (if (ssget "_:L") (command "_.mirror3d" "_P" "" filter pause pause) (princ "\nNo objects selected") ) (princ) ) (defun c:mx ( / _m3d) (_m3d "_yz")) (defun c:my ( / _m3d) (_m3d "_zx")) (defun c:mz ( / _m3d) (_m3d "_xy")) 1 Quote
Randolph Posted June 6, 2012 Author Posted June 6, 2012 I see. What's even more of a problem is the fact, that after provoking this bug, the command is "unknown" - appearingly until reload. I will use pBe's code now, assuming that this does the trick including above problem. Quote
Randolph Posted June 6, 2012 Author Posted June 6, 2012 pBe, your code generates an error message: error: no function definition: _m3d Tharwat, your code worx just fine. Now I will adapt it for the ROTATE 3D command. Thanx! Quote
pBe Posted June 6, 2012 Posted June 6, 2012 You need to load as well (defun _m3d (filter) .... Reason for that, in cae in the future you need to use another point filter. All you need to do is (defun c:mzz ( / _m3d) (_m3d "_z")) ; Quote
Randolph Posted June 6, 2012 Author Posted June 6, 2012 Sorry, pBE, that's beyond my level. I can't follow you. Quote
pBe Posted June 7, 2012 Posted June 7, 2012 Sorry, pBE, that's beyond my level. I can't follow you. Dont worry about it Randolph. Keep on coding 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.