Jump to content

Mirror 3D with predefined mirror plane


Randolph

Recommended Posts

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.

Link to comment
Share on other sites

(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.

Link to comment
Share on other sites

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))

Link to comment
Share on other sites

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 .

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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))

Link to comment
Share on other sites

(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"))

  • Like 1
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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")) ;

 

 

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...