One click mirror with osnap...

One click mirror with osnap...

danglar
Advocate Advocate
1,510 Views
9 Replies
Message 1 of 10

One click mirror with osnap...

danglar
Advocate
Advocate

Hi All.

This command (created by Kent Cooper and slightly modified by me) can mirror object by one click

(defun c:MV ()

  (command
    "_.mirror"
    pause ""
    "_none" "@"
    "_none" "@0,1"
    "_yes"
  )
)

but when I invoke this function osnap not working at all

 

Is it possible to change this code in order to involve osnap selection to working process?

Any help will be very appreciated

0 Likes
Accepted solutions (1)
1,511 Views
9 Replies
Replies (9)
Message 2 of 10

_Tharwat
Advisor
Advisor

Hi,

The "_none" is the code that disable the osnap object.

0 Likes
Message 3 of 10

danglar
Advocate
Advocate

It's no so simple..

If you disable "none" function MV becomes to "two or three click" mirror command..

Need to be only one click with enabled osnap

0 Likes
Message 4 of 10

wkmvrij
Advocate
Advocate

Try this:

 

(DEFUN C:MV ()
  (SETQ os (GETVAR "OSMODE"))
  (COMMAND "_.mirror" pause "" "_none" "@" "_none" "@0,1" "_yes")
  (SETVAR "OSMODE" os)
  (PRINC)
)
0 Likes
Message 5 of 10

stevor
Collaborator
Collaborator

 

Seems more useful here:

(setvar 'cmdecho 0)
(defun c:MV () (command "_.mirror" "nea" pause "" "_non" "@" "_non" "@0,1" "_y" ) (princ)  )

S
0 Likes
Message 6 of 10

Kent1Cooper
Consultant
Consultant
Accepted solution

@danglar wrote:

....

This command (created by Kent Cooper and slightly modified by me) can mirror object by one click

(defun c:MV ()

  (command
    "_.mirror"
    pause ""
    "_none" "@"
    "_none" "@0,1"
    "_yes"
  )
)

but when I invoke this function osnap not working at all

 

Is it possible to change this code in order to involve osnap selection to working process?

....


If you want Osnap on for the object selection to be at some Osnappable location among the modes you have set, then you would have to use (getpoint) instead of just a pause for object selection, because Osnap doesn't work during object selection when you run an editing command manually, either.  If you save a point that you get with Osnap, you can then use that point for the selection, rather than a pause.

 

Try something like this [lightly tested]:

 

(defun c:MVO (/ pt); = Mirror across Vertical axis, with Object Snap for selection

  (setq pt (getpoint "\nOsnap-select single object at vertical-Mirror-axis location: "))
  (command
    "_.mirror"
    pt ""
    "_none" "@"
    "_none" "@0,1"
    "_yes"
  )
)

 

That depends on your having Osnap running.  If you might not always have running Osnap modes going, you could decide on a combination that would always work for your purposes, and build the setting of OSMODE to that value into the beginning of the routine.

Kent Cooper, AIA
Message 7 of 10

danglar
Advocate
Advocate

Wow Kent!

It's awesome! Another excellent solution. I did not even think about

this approach, but it's work and work perfect

Thank you Kent

0 Likes
Message 8 of 10

danglar
Advocate
Advocate

.. based on your solution Kent

but in case if we need horizontal mirror

All credits to Kent!

(defun c:MH (/ pt); = Mirror across Horizontal axis, with Object Snap for selection

  (setq pt (getpoint "\nOsnap-select single object at Horizontal-Mirror-axis location: "))
  (command
    "_.mirror"
    pt ""
    "_none" "@"
    "_none" "@1,0"
    "_yes"
  )
)
0 Likes
Message 9 of 10

wkmvrij
Advocate
Advocate

Nice, kent. This starts looking like a forum discussion several years ago where we and a lot of others developed the routine to select transparently a point as the middle between two points. Dragged on for weeks and some time later it was incorporated in Autocad as MTP command modifier


;;; = Mirror across Horizontal axis, with Object Snap for selection (defun MH (/ pt os) (setq os (getvar "OSMODE") pt (getpoint "\nOsnap-select single object at Horizontal-Mirror-axis location: " ) ) (command "_.mirror" pt "" "_none" "@" "_none" "@1,0" "_yes") (setvar "OSMODE" os) )

 

What if there are two objects present at the (getpoint)? I only want to mirror one object, and for the action want to use a snapmode which is currently not selected...

 

 

 

 

0 Likes
Message 10 of 10

Kent1Cooper
Consultant
Consultant

@wkmvrij wrote:

....


.... (setq os (getvar "OSMODE") .... (setvar "OSMODE" os) ....

 

What if there are two objects present at the (getpoint)? I only want to mirror one object, and for the action want to use a snapmode which is currently not selected...


[That saving and resetting of the OSMODE System Variable are really not necessary in this case.  Calling for "_none" object snap preceding an individual point designation does not change the OSMODE setting, but only disables it for that one pick, and it goes back into effect immediately afterwards.  That's why it's needed before both mirror-axis-defining points.  There's nothing in that code that changes the setting, so there's no need to save it first and then restore it afterwards.]

 

If you want to use an Osnap mode that is not currently set, you can type in [or pick from a toolbar or something] a mode, and (getpoint) will "wait" through that so that there can be two inputs involved [the selection of the mode, and the selection of the location].

 

But if there are multiple objects at that location, you won't have any control over which one it "sees" and selects.  If that's a possibility, I think you would need a more involved routine, to first select the object and then the location to use for defining the mirroring axis.

Kent Cooper, AIA
0 Likes