Author Topic: Copy then Rotate  (Read 2136 times)

0 Members and 1 Guest are viewing this topic.

CECE_CAD

  • Guest
Copy then Rotate
« on: February 22, 2007, 01:54:17 PM »
This code works well for copying then rotating, aslo if you change the commands to move and rotate. one thing I don't like is it leaves the copied object grouped even when its told to explode the group. Can anyone tell me how to get ride of the group. I don't want to copy a few objects and have them stay grouped together.

***************************************************
***************************************************
Copy then Rotate


Code: [Select]
(defun c:cr (/ SS1 PT1 PT2)
(setq SS1 nil)
(setq CMD (getvar "CMDECHO"))
(setq OLDERR *ERROR*)
(setq *ERROR* MYERROR)
(command "undo" "begin")
(setvar "CMDECHO" 0)
(prompt "\nSelect Objects to Copy-Rotate: ")
(setq SS1 (ssget))
(command "-group" "" "copier" "" SS1 "")
(setq PT1 (getpoint "\nFirst Point of displacement: "))
(prompt "\Second Point of Displacment: ")
(command "._copy" "g" "copier" "" PT1 pause)
(setq PT2 (getvar "LASTPOINT"))
(prompt "\nSelect Angle of Rotation: ")
(command "._rotate" "last" "" PT2 pause)
(command "-group" "e" "copier")
(newgroups)
(command "-group" "e" EXGNAME)
(command "undo" "end")
(setvar "CMDECHO" CMD)
(redraw)
(prompt "\nCopy Rotate complete....")
(princ)
) ;; End of Copy Rotate


<edit: code tags added>
« Last Edit: February 22, 2007, 02:37:15 PM by CAB »

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy then Rotate
« Reply #1 on: February 22, 2007, 02:35:38 PM »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CECE_CAD

  • Guest
Re: Copy then Rotate
« Reply #2 on: February 22, 2007, 05:59:23 PM »
that is a great command! Thanks

JohnK

  • Administrator
  • Seagull
  • Posts: 10661
Re: Copy then Rotate
« Reply #3 on: February 22, 2007, 06:06:28 PM »
why are you assembling a group?

Code: [Select]
(defun c:cr (/ p1 objects done getpoin7)
  ;; copy and rotate
  ;;
  ;; By: John (Se7en) K
  ;;
  (defun done (s)
    (setq *error* olderr
          olderr  nil)
    (princ) )

  (defun getpoin7 ( msg / x)
    (while
      (not (setq x (getpoint msg)))
      (princ "\nYou missed, try again."))
    x)

  (prompt "Select Objects: ")
  (setq sset (ssget)
        p1 (getpoin7 "\nSelect base point: "))

  (if (and p1 sset)
    (setq olderr *error* *error* done))

  (command "copy" sset "" p1 p1)
  (command "move" sset "" p1)
  (while (eq (logand (getvar 'cmdactive) 1) 1)
         (command PAUSE))
  (command "rotate" sset "" (getvar "lastpoint"))
  (while (eq (logand (getvar 'cmdactive) 1) 1)
         (command PAUSE))

  (done "")
)
TheSwamp.org (serving the CAD community since 2003)
Member location map - Add yourself

Donate to TheSwamp.org

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Copy then Rotate
« Reply #4 on: February 22, 2007, 06:38:01 PM »
That's thinking outside the box. 8-)
Leaving the copies in place, very cool. :-)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CECE_CAD

  • Guest
Re: Copy then Rotate
« Reply #5 on: February 27, 2007, 11:55:14 AM »
I ended up going with this, works well! Allows you to do multiple copy

Code: [Select]
;;;  CopyRotate.lsp by Charles Alan Butler
;;;  by Precision Drafting & Design All Rights Reserved.
;;;  Contact at ab2draft[at]TampaBay.rr.com
;;;
;;;   Version 4.0 Beta  Feb 07,2005
;;;
;;; DESCRIPTION
;;; User pick base point then selects object(s)
;;; Paste mode until Escape is pressed
;;; Once pasted user selects rotation angle
;;;
;;; Command Line Usage
;;; Command: copyr
;;  Copy objects, then paste & rotate new copy
;;  does not show the objects during paste
(defun c:copyr (/ pt ss elast ssnew)
         
  ;; Rune Wold and Michael Puckett - modified ale_lastent ale_ss-after
  (defun ale_lastent (/ entnam outval)
    (and
      (setq outval (entlast))
      (while (setq entnam (entnext outval))
        (setq outval entnam)
      )
    )
    outval
  )

  (defun ale_ss-after (entnam / entnxt selset)
    (cond
      ((not entnam) (ssget "_X"))
      ((setq entnxt (entnext entnam))
       (setq selset (ssadd entnxt))
       (while (setq entnxt (entnext entnxt))
         (if (entget entnxt)
           (ssadd entnxt selset)
         )
       )
       selset
      )
    )
  )
  (if (and (setq pt (getpoint "\nPick base point of object to copy:"))
           (null (prompt "\nSelect objects to copy:"))
           (setq ss (ssget))
      )
    (progn
      (command "._copybase" pt ss "")
      (while (setq pt (getpoint "\nPick insertion point."))
        ;;  get last item in database
        (setq elast (ale_lastent))
        (command "._pasteclip" pt)
        ;;  get new items pasted.
        (setq ssnew (ale_ss-after elast))
        ;;  allow user to rotate
        (command "._rotate" ssnew "" pt pause)
      ) ; while
    ) ; progn
  ) ; endif
  (princ)
)
(princ)

 :ugly:


<edit CAB: updated with lates code version>
« Last Edit: February 27, 2007, 03:32:28 PM by CAB »

CECE_CAD

  • Guest
Re: Copy then Rotate
« Reply #6 on: February 27, 2007, 01:19:42 PM »
Thanks Se7en!  I like this one as well..  I didn't write that code, I was thinking the group was being made because of not knowing how to gather the objects that were copied to rotate.  I could be wrong but thats what I thought.

« Last Edit: February 27, 2007, 01:21:16 PM by CECE_CAD »