Author Topic: copy and rotate combined  (Read 9837 times)

0 Members and 1 Guest are viewing this topic.

ELOQUINTET

  • Guest
copy and rotate combined
« on: August 11, 2004, 01:10:55 AM »
i have this routine for copy rotate combined but there's a problem. when it copies the new copy has 2 duplicates one on top of another. i just want one copy of the original i can rotate. does this make sense, try it and see what i mean. or does anyone have something else that does what i want. thanks


Code: [Select]
(defun c:cr ()
(princ "\nCopy & Rotate:\n")
(setq ss (ssget))
(command "copy" ss "" "0" "0")(command "move" ss "" pause pause)(command "rotate" ss "" "@" pause))

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
copy and rotate combined
« Reply #1 on: August 11, 2004, 01:50:43 AM »
Perhaps something like this < modified a little > :
Code: [Select]

(defun c:cr (/ ss)
  (princ "\nCopy & Rotate:\n")
  (setq ss (ssget))
;;;;(command "copy" ss "" "0" "0") ;; superfluous command
  (princ "Select From and To points :")
  (command "move" "_Prev" "" pause pause)
  (princ "Select Rotation Angle :")
  (command "rotate" "_Prev" "" "@" pause)
  (princ)
)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

CADaver

  • Guest
copy and rotate combined
« Reply #2 on: August 11, 2004, 07:43:50 AM »
Quote from: Kerry Brown
Perhaps something like this < modified a little > :
Code: [Select]

(defun c:cr (/ ss)
  (princ "\nCopy & Rotate:\n")
  (setq ss (ssget))
;;;;(command "copy" ss "" "0" "0") ;; superfluous command
  (princ "Select From and To points :")
  (command "move" "_Prev" "" pause pause)
  (princ "Select Rotation Angle :")
  (command "rotate" "_Prev" "" "@" pause)
  (princ)
)


Looks like a MOVE & rotate to me, what am I missing?

CADaver

  • Guest
Re: copy and rotate combined
« Reply #3 on: August 11, 2004, 07:47:40 AM »
Quote from: eloquintet
i have this routine for copy rotate combined but there's a problem. when it copies the new copy has 2 duplicates one on top of another. i just want one copy of the original i can rotate. does this make sense, try it and see what i mean. or does anyone have something else that does what i want. thanks


Code: [Select]
(defun c:cr ()
(princ "\nCopy & Rotate:\n")
(setq ss (ssget))
(command "copy" ss "" "0" "0")(command "move" ss "" pause pause)(command "rotate" ss "" "@" pause))


When I do it, there is only the original and the one new copy.  Try MOCORO out of Express Tools (MOVE COPY ROTATE)

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
copy and rotate combined
« Reply #4 on: August 11, 2004, 08:06:20 AM »
Quote from: CADaver

Looks like a MOVE & rotate to me, what am I missing?


Just seeing who is awake ...
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ELOQUINTET

  • Guest
copy and rotate combined
« Reply #5 on: August 11, 2004, 08:12:58 AM »
well i copied it from my home computer last night so it maybe a move. see the original was a copy and i modified to make a move as well. it seems that only sometimes it duplicates what is being copied if that's possible. i think it is this lisp that is doing it, been trying to isolate the problem for a little while now. anyway i'll give yours a shot kerry and see how it goes. thanks alot

daron

  • Guest
copy and rotate combined
« Reply #6 on: August 11, 2004, 08:16:36 AM »
It is my understanding that vla-copy works differently than command copy. If you use copy "m" and try to copy objects at a set distance like every 4 feet, you have to type 4' 8' 16', whereas if you use copym from express tools you can achieve the same thing by typing 4' 4' 4' or 4' repeat, etc. This is achieved through vla-copy and vla-move. It sounds like that is what you're after.

As I reread, maybe not, but it should give you something to think about.

M-dub

  • Guest
copy and rotate combined
« Reply #7 on: August 11, 2004, 08:51:27 AM »
Here are my (stolen) CR and MR (Copy Rotate & Move Rotate) if anyone's interested...

Copy & Rotate
Code: [Select]
;;CR is a command to allow you to copy an object and then do
;;a rotate right after it. Once loaded just type in CR to activate
;;the command.
(defun newgroups (/ GRPS OD GRP1 CHCKR GRPS GNAME)
  (setq OD (namedobjdict))
  (setq GRPS (dictnext OD "acad_group"))
  (while (/= CHCKR 3)
    (setq GRP1 (car GRPS))
    (setq GRPS (cdr GRPS))
    (setq chckr (car GRP1))
    (if (= chckr 3)
      (progn
        (setq NGROUPS (list (cdr GRP1)))
      )
    )
  )
  (while (/= GRPS nil)
    (setq GRP1 (car GRPS))
    (setq GRPS (cdr GRPS))
    (setq chckr (car GRP1))
    (if (= chckr 3)
      (progn
        (setq GNAME (cdr GRP1))
        (setq NGROUPS (cons GNAME NGROUPS))
      )
    )
  )
  (setq EXGNAME (car NGROUPS))
)

;;Error Tile
(defun MYERROR (S)
  (if (/= S "\nFunction cancelled" )
  (princ "\nEnding Copy Rotate..." ))  
  (command "-group" "e" "copier")
  (command "undo" "end")
  (command "u" "u")
  (setvar "CMDECHO" CMD)
  (setq *ERROR* OLDERR )
  (princ)
)

;; Main section of Copy Rotate
(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 and 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


Move & Rotate
Code: [Select]
;;MR.LSP
;;MR is a command that allows you to MOVE an object(s) and then
;;perform a ROTATE right after it. Once loaded just type in MR to activate
;;the command.
(defun c:MR (/ SS1)

;;Error Tile
(defun MYERROR (S)                    ;;error trap program
   (if (/= S "\nFunction canceled")
     (princ "\nEnding Rotate-Move...")
   )
   (command "undo" "end")
   (command "u")
   (setvar "CMDECHO" CMD)
   (setq *ERROR* OLDERR )
  (princ)
)

  (setq CMD (getvar "cmdecho"))
  (setq OLDERR *ERROR*)
  (setq *ERROR* MYERROR)
  (setvar "cmdecho" 0)
  (command "undo" "begin")
  (prompt "\nSelect objects to Rotate and then Move: ")
  (setq SS1 (ssget))

  (prompt "\nEnter First Point of Displacement: ")
  (command "move" SS1 "" PAUSE PAUSE)
  (prompt "\nEnter Angle of Rotation: ")
  (setq PT1 (getpoint "\nEnter First Point of Displacement: "))
  (command "rotate" SS1 "" PT1 PAUSE)

  (command "undo" "end")
  (setq *ERROR* OLDERR )
  (setvar "cmdecho" CMD)
 (princ)
)

ELOQUINTET

  • Guest
copy and rotate combined
« Reply #8 on: August 11, 2004, 09:09:53 AM »
yeah i know about the express but i don't really care for how it functions. i prefer commands that do one specific thing instead of having to tell it which option i want. anyway i'll try your too mdub thanks

t-bear

  • Guest
copy and rotate combined
« Reply #9 on: August 11, 2004, 09:59:13 AM »
Mike....
Tried your "CR" routine....it moves the object....doesn't leave the original.....the rotate part works super, though....

?????

M-dub

  • Guest
copy and rotate combined
« Reply #10 on: August 11, 2004, 10:33:57 AM »
Quote from: t-bear
Mike....
Tried your "CR" routine....it moves the object....doesn't leave the original.....the rotate part works super, though....

?????


I dunno...It works fine on my machine...I'll have a look.

daron

  • Guest
copy and rotate combined
« Reply #11 on: August 11, 2004, 10:38:16 AM »
Dan, they were just examples of how vla-copy and command copy work differently. I wasn't saying to use copym to solve your problem, just that vla-copy might be another road to take. There's a lot more to copym in express tools than vla-copy.

hyposmurf

  • Guest
copy and rotate combined
« Reply #12 on: August 11, 2004, 10:43:31 AM »
Quote from: t-bear
Mike....
Tried your "CR" routine....it moves the object....doesn't leave the original.....the rotate part works super, though....

?????

Leaves the original in place on mine TBear. :?

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
copy and rotate combined
« Reply #13 on: August 11, 2004, 12:55:13 PM »
why not create our own ?

this should get us started  :roll:  it might need a little more error trapping.
Code: [Select]

;;; copy then rotate  1.1
;;; point selection method
(defun get-point (util_obj st_pt msg / pt)
  (cond ((and st_pt msg)
         (setq pt
               (vl-catch-all-apply
                 'vlax-invoke-method
                 (list util_obj 'GetPoint st_pt msg)
                 )
               ))
        ((and st_pt (not msg))
         (setq  pt
                (vl-catch-all-apply
                  'vlax-invoke-method
                  (list util_obj 'GetPoint st_pt)
                  )
                ))
        ((and msg (not st_pt))
         (setq  pt
                (vl-catch-all-apply
                  'vlax-invoke-method
                  (list util_obj 'GetPoint nil msg)
                  )
                ))
        (T (setq pt
                 (vl-catch-all-apply
                   'vlax-invoke-method
                   (list util_obj 'GetPoint)
                   )
                 ))
        ); cond

  (if (not (vl-catch-all-error-p pt))
    pt nil)
  )
 
(defun release-obj (obj)
  (if
    (= (type obj) 'VLA-OBJECT)
    (if (not (vlax-object-released-p obj))
      (vlax-release-object obj)
      )
    )
  )

(defun get-angle (util_obj pt msg / ang)
  (setq ang
        (vl-catch-all-apply
          'vlax-invoke-method
          (list util_obj 'GetAngle pt (vlax-make-variant msg))
          )
        )
  (if (not (vl-catch-all-error-p ang))
    ang nil)
  )

(defun c:cp-rt (/ active_doc util_obj get_ent obj
                  pt p1 p2 cp_obj ang)
  (vl-load-com)

  (setq active_doc (vla-get-activedocument (vlax-get-acad-object))
        util_obj (vla-get-utility active_doc)
        )

  (setq get_ent
        (vl-catch-all-apply
          'vlax-invoke-method
          (list util_obj 'GetEntity 'obj 'pt)
          )
        )

  (if (not (vl-catch-all-error-p get_ent))
    (if (setq p1 (get-point util_obj nil "\nSelect copy base point: "))
      (if (setq p2 (get-point util_obj p1 "\nTo point: "))
        (vla-move (setq cp_obj (vla-copy obj)) p1 p2)
        )
      )
    )

  (if cp_obj
    (progn
      (if (setq p1 (get-point util_obj nil "\nSelect rotation base point: "))
        (if (setq ang (get-angle util_obj p1 "\nRotation angle: "))
          (vla-rotate cp_obj p1 ang)
          )
        )
      (release-obj cp_obj)
      )
    )
  (mapcar 'release-obj (list active_doc util_obj))
  (princ)
  ); defun cp-rt
TheSwamp.org  (serving the CAD community since 2003)

t-bear

  • Guest
copy and rotate combined
« Reply #14 on: August 11, 2004, 01:31:08 PM »
Mike....
Well that's wierd!  I deleted the routine, reloaded it and dropped it into my startup suite....works OK now.....go figure.
Thanks, amigo.