Jump to content

Recommended Posts

Posted

I have 6 different commands for rotate 13 is my rotate command.

1390

13180

13270

1345

13... you get the point. Instead of haveing all these commands I would like to consolidate them into 1 command with options 1=90 2=180 3=... you get the point.

 

I would like to select object, pick point, enter 1-blah blah blah enter and done.

I know I can just use the rotate command but this will play an important roll in a greater lisp routine.

 

Thank you in advance.

 

Here is my basic 13180 command

 

(defun C:13180(/ CtrPt)

(setvar "CMDECHO" 0)

(setq ss1 nil)

(setq ss1 (ssget))

(setq CtrPt (getpoint "\nPick the rotation Point:... "))

(command "rotate" "P" "" CtrPt "180")

(setq ss1 nil)

(setvar "CMDECHO" 1)

(princ)

) ;end defun

Posted

Maybe:

 

[b][color=BLACK]([/color][/b]defun c:rots [b][color=FUCHSIA]([/color][/b]/ ss cp rl il rs[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]if [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
       [b][color=NAVY]([/color][/b]progn
         [b][color=MAROON]([/color][/b]initget 1[b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]setq cp [b][color=GREEN]([/color][/b]getpoint [color=#2f4f4f]"\nBase Point:   "[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]setq rl '[b][color=GREEN]([/color][/b][b][color=BLUE]([/color][/b]1 . 90[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]2 . 180[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]3 . 270[b][color=BLUE])[/color][/b]
                    [b][color=BLUE]([/color][/b]4 . 45[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]5 . 135[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]6 . 225[b][color=BLUE])[/color][/b][b][color=BLUE]([/color][/b]7 . 315[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]setq il [color=#2f4f4f]""[/color][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]foreach r rl
            [b][color=GREEN]([/color][/b]setq il [b][color=BLUE]([/color][/b]strcat il [color=#2f4f4f]" "[/color] [b][color=RED]([/color][/b]itoa [b][color=PURPLE]([/color][/b]car r[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
            [b][color=GREEN]([/color][/b]princ [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"\n"[/color] [b][color=RED]([/color][/b]itoa [b][color=PURPLE]([/color][/b]car r[b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b][color=#2f4f4f]" = "[/color] [b][color=RED]([/color][/b]rtos [b][color=PURPLE]([/color][/b]cdr r[b][color=PURPLE])[/color][/b] 2 0[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]initget 1 il[b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]setq rs [b][color=GREEN]([/color][/b]getkword [b][color=BLUE]([/color][/b]strcat [color=#2f4f4f]"\nRotation Angle "[/color] il [color=#2f4f4f]":   "[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
         [b][color=MAROON]([/color][/b]command [color=#2f4f4f]"_.ROTATE"[/color] ss [color=#2f4f4f]""[/color] cp [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc [b][color=RED]([/color][/b]atoi rs[b][color=RED])[/color][/b] rl[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
[b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

 

-David

Posted

Specify rotation instead e.g. 90 or 180

 


(defun c:test ( / CtrPt ss1 rot )
(if (setq ss1 (ssget))
    (progn
           (setvar "CMDECHO" 0)
           (setq CtrPt (getpoint "\nPick the rotation Point:... ")
                         rot (getint "\nSpecify Rotation : "))
           (command "rotate" "P" "" CtrPt rot)
           (setvar "CMDECHO" 1)
     )
)
(princ)
) ;end defun

Posted (edited)

just for fun

 

(defun c:rot13 ( / rot-list loop ss1 CtrPt inp)
 (vl-load-com)
 (setq rotlist (list 45 90 135 180 225 270) loop t)
 (setvar "CMDECHO" 0)
 (if (and (setq ss1 (ssget))
      (setq CtrPt (getpoint "\nPick the rotation Point:... ")))
   (progn
     (princ "\nCycle angle with tab or L-mouse / accept use enter,space or R-mouse / Esc or x for exit")
     (princ (strcat "\nChoose rotation angle<" (itoa (car rotlist)) "> : "))
     (while loop
   (setq inp (vl-catch-all-apply 'grread (list nil 8 0)))
   (if (vl-catch-all-error-p inp)
     (progn (princ "\nRotation function cancelled")(setq loop nil))
     (progn
       (cond
         ;tab
         ((or (equal inp '(2 9))(= (car inp) 3))
          (setq rotlist (append (cdr rotlist)(list (car rotlist))))
          (princ (strcat "\rChoose rotation angle<" (itoa (car rotlist)) "> : ")))
         ;enter,space,r-mouse
         ((or (equal inp '(2 13)) (equal inp '(2 32))(= (car inp) 25))
          (command "rotate" ss1 "" CtrPt (car rotlist))(setq loop nil))
         ;x or X
         ((member inp '((2 88)(2 120)))(setq loop nil))
       )
     )
   )
     )
   )
 )
 (setvar "CMDECHO" 1)
 (princ)
)

 

and of course this can be easily modified to capture numbers 1-9 (or 0) to specify your desired angle or to instandly rotate.

 

gr. Rlx

Edited by rlx
Posted
just for fun

 

(defun c:rot13 ( / rot-list loop ss1 ctrpt inp)
 (vl-load-com)
 (setq rotlist (list 45 90 135 180 225 270) loop t)
 (setvar "cmdecho" 0)
 (if (and (setq ss1 (ssget))
      (setq ctrpt (getpoint "\npick the rotation point:... ")))
   (progn
     (princ "\ncycle angle with tab or l-mouse / accept use enter,space or r-mouse / esc or x for exit")
     (princ (strcat "\nchoose rotation angle<" (itoa (car rotlist)) "> : "))
     (while loop
   (setq inp (vl-catch-all-apply 'grread (list nil 8 0)))
   (if (vl-catch-all-error-p inp)
     (progn (princ "\nrotation function cancelled")(setq loop nil))
     (progn
       (cond
         ;tab
         ((or (equal inp '(2 9))(= (car inp) 3))
          (setq rotlist (append (cdr rotlist)(list (car rotlist))))
          (princ (strcat "\rchoose rotation angle<" (itoa (car rotlist)) "> : ")))
         ;enter,space,r-mouse
         ((or (equal inp '(2 13)) (equal inp '(2 32))(= (car inp) 25))
          (command "rotate" ss1 "" ctrpt (car rotlist))(setq loop nil))
         ;x or x
         ((member inp '((2 88)(2 120)))(setq loop nil))
       )
     )
   )
     )
   )
 )
 (setvar "cmdecho" 1)
 (princ)
)

 

and of course this can be easily modified to capture numbers 1-9 (or 0) to specify your desired angle or to instandly rotate.

 

Gr. Rlx

 

 

i must remember this code!

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