Creating a Move/Copy/Rotate/Mirror Command

Creating a Move/Copy/Rotate/Mirror Command

t.brezinsky
Explorer Explorer
2,389 Views
10 Replies
Message 1 of 11

Creating a Move/Copy/Rotate/Mirror Command

t.brezinsky
Explorer
Explorer

Hi All,

I'm looking to create a command or tool similar to the express tool command Move/Copy/Rotate/(scale), but instead of being able to scale the object I'd like to be able to Mirror the object. I'm using AutoCAD 2021 and am VERY green to this sort of customization. Any info helps.

Thanks,

TB.

0 Likes
2,390 Views
10 Replies
Replies (10)
Message 2 of 11

Kent1Cooper
Consultant
Consultant

Assuming some grip location is appropriate as a basis for Move or Copy displacement and/or Rotation base and/or Mirror axis, are you aware that you can do all that with grip-editing, without the need for any command at all, whether native or custom?

Kent Cooper, AIA
0 Likes
Message 3 of 11

t.brezinsky
Explorer
Explorer

I was not aware of that and I'm not sure what grip-editing is.

0 Likes
Message 4 of 11

Kent1Cooper
Consultant
Consultant

See >this<, and look at the "Related" categories at the bottom.

Kent Cooper, AIA
0 Likes
Message 5 of 11

t.brezinsky
Explorer
Explorer

Well that was rather easy. Thanks for your help. Just back to my original question.. Is something like that able to be done and work like the express tool move/copy/rotate?

0 Likes
Message 6 of 11

Sea-Haven
Mentor
Mentor

The express command uses a arx but there is a another close to it and by Autodesk. You could possibly patch that.

 

It may be the original idea looking at 1990.

 

;;;   provides two new commands, MoveRot and CopyRot
;;;   Copyright (C) 1990 by Autodesk Australia Pty. Ltd.
;;;  
;;;   Permission to use, copy, modify, and distribute this software and its
;;;   documentation for any purpose and without fee is hereby granted.  
;;;
;;;   THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. 
;;;   ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF 
;;;   MERCHANTABILITY ARE HEREBY DISCLAIMED.
;;; 
;;;-------------------------------------------------------------------------
;;; DESCRIPTION:
;;;
;;;   Mcr.Lsp provides two new commands, MoveRot and CopyRot.
;;;   MoveRot, MOVEs and ROTATEs selected entities whilst
;;;   CopyRot, COPYies and ROTATEs selected entities.
;;;
;;;   Written by  Sam Crupi, Autodesk Australia Pty. Ltd.
;;;               October 1987
;;;   Modified by Jeff De Silva & Sam Crupi, Autodesk Australia Pty. Ltd.
;;;               November 1990
;;;
;;;   Version 1.0
;;;   4 December 1990
;;;
;;;-------------------------------------------------------------------------
;;;
;;; Error function
;;;
(defun mcr_err (s)                   ; If an error (such as CTRL-C) occurs
   ; while this command is active...
   (if (/= s "Function cancelled") 
      (if (= s "quit / exit abort") 
         (princ) 
         (princ (strcat "\nError: " s))
      )
   ) 
   (if mcr_oer                        ; If an old error routine exists
      (setq *error* mcr_oer)           ; then, reset it 
   ) 
   (if mcr_oce                        ; Reset command echoing on error
      (setvar "cmdecho" mcr_oce)
   ) 
   (princ)
) 
;;;
;;; Command MoveRot
;;;
(defun c:MoveRot (/ sset mcr_oce mcr_oer) 
   (setq mcr_oce (getvar "cmdecho"))  ; save cmdecho setting
   (setvar "cmdecho" 0)               ; turn cmdecho off
   (if *error*                        ; Set our new error handler
      (setq mcr_oer *error* 
      *error* mcr_err)
      (setq *error* mcr_err)
   ) 
   (princ (strcat "\nMoveRot, Version " mcr_ver 
      ", (C) 1990 by Autodesk Australia Pty. Ltd. "
   )
) 
(if (setq sset (ssget))            ; get selection set
   (progn
      (setvar "cmdecho" 1)           ; turn cmdecho on to allow MOVE
      ; prompts to appear
      (command "MOVE" sset "" pause pause) ; MOVE them
      ;; now ROTATE the selection set using the LASTPOINT as Base point
      (command "ROTATE" sset "" (getvar "LASTPOINT") pause) 
   )
)
(setvar "cmdecho" mcr_oce)         ; reset cmdecho to old setting
(if mcr_oer                        ; If an old error routine exists
   (setq *error* mcr_oer)          ; then set it back
) 
(princ)
) 
;;;
;;; Command CopyRot
;;;
(defun c:CopyRot (/ mcr_oce mcr_oer sset) 
(setq mcr_oce (getvar "cmdecho"))  ; save cmdecho setting
(setvar "cmdecho" 0)               ; turn cmdecho off
(if *error*                        ; Set our new error handler
   (setq mcr_oer *error* 
   *error* mcr_err)
   (setq *error* mcr_err)
) 
(princ (strcat "\nCopyRot, Version " mcr_ver 
   ", (C) 1990 by Autodesk Australia Pty. Ltd. "
)
) 
(if (setq sset (ssget))            ; get selection set
(progn
   (command "COPY" sset "" "0,0" "0,0") ; COPY selection set over itself
   (setvar "cmdecho" 1)           ; turn cmdecho on to allow MOVE
   ; prompts to appear
   (command "MOVE" "p" "" pause pause) 
   (redraw)                       ; Redraw screen
   ;; now ROTATE the selection set using the LASTPOINT as Base point
   (command "ROTATE" "p" "" (getvar "LASTPOINT") pause)
)
)
(setvar "cmdecho" mcr_oce)         ; reset cmdecho to old setting
(if mcr_oer                        ; If an old error routine exists
(setq *error* mcr_oer)          ; then set it back
) 
(princ)
) 
;;;
;;; Define the c: functions.
;;;
(defun c:MR () 
(c:MoveRot)
) 
(defun c:CR () 
(c:CopyRot)
) 
(setq mcr_ver "1.0")                 ; set version number string
(princ (strcat "\nC:MCR (v" mcr_ver ") loaded.")) 
(princ 
"\nMR or MoveRot to Move and Rotate, CR or CopyRot to Copy and Rotate.") 
(princ) 


 IT  

0 Likes
Message 7 of 11

ВeekeeCZ
Consultant
Consultant

No way to edit MOCORO anyhow.

Why you're using that command? What's the advantage of its usage? The reason I am asking is, that we may recommend you some other way to achieve that. Personally, I never found this command useful. It's too cumbersome for me.

0 Likes
Message 8 of 11

Kent1Cooper
Consultant
Consultant

[Some of the Express Tools are defined in .lsp files, so I was thinking maybe it would be possible to edit MOCORO to add a Mirror option somehow,  But unfortunately, the MOCORO command is in an .arx file, which I don't think can be edited -- at least, I don't know how.]

Kent Cooper, AIA
0 Likes
Message 9 of 11

t.brezinsky
Explorer
Explorer

I use MOCORO because it's continuous, most times I'm not moving rotating or copying from a grip, and I don't mind using the keyboard keys to switch the function of the command. I just thought if the mirror command could be added in somehow that would be a bonus. I am however open to new ideas... 

0 Likes
Message 10 of 11

Sea-Haven
Mentor
Mentor

As I suggested what I posted is maybe the 1st version of the command, you can use that and add on to it.

 

You need a front end something like this keep choosing till you exit or hit OK the way this is set up you click a choice and dcl closes do not actually need to pick OK its there more for repeat.

 

screenshot295.png

 

 

0 Likes
Message 11 of 11

ВeekeeCZ
Consultant
Consultant

@ВeekeeCZ wrote:

No way to edit MOCORO anyhow.

Why you're using that command? What's the advantage of its usage? The reason I am asking is, that we may recommend you some other way to achieve that. Personally, I never found this command useful. It's too cumbersome for me.


 

No way to edit the current command but could be imitated and possibly enhanced. Still not sure if I find the usage for this, but certainly closer to my idea of how such a tool should perform.

 

Differences from the original MOCORO:

(prompt "\rSpecify point for qmove or [MovE/Copy/Rotate/Align/mIrroW/Flip/Scale/Base] <eXit>: ")

 

;; command options by single key stoke, no need to confirmation by enter or space

;; commands not obvious:
;; default is QuickMove - without osnaps, ignores base-ref-point if specified
;; both M/E are for the same Move - a classic command with a prompt for base-ref-point if unspecified yet
;; Copy - single copy only with prompt for base ref point if unspecified yet (not possible make it multiple as original MOCORO)
;; I/W/F for Mirror
;; I for classic Mirror with 'Remove objects' prompt
;; W for Mirror with NO to 'Remove objects' prompt, F for YES option
;; Align and Mirror ignors&resets base-ref-point if already specified

 

 

;---------

Footnote: qmove isn't as q as I thought would be because can't have grread on 2nd point 😞