Author Topic: Adding Rotation Command  (Read 1489 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Adding Rotation Command
« on: October 10, 2017, 01:33:29 PM »
How hard is it to create a command for rotation like the fillet command?

The routine originally started from the fillet command.

Code: [Select]
(   (lambda nil
        (foreach rad '(0.5 1 1.5 2 2.5 3 3.5 4 4.5 5 5.5 6 6.5 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 40 50 60 70 80 90 100 200 300 400 500)
           (eval
              (list 'defun
                   (read (strcat "c:r" (vl-string-translate "." "-" (vl-princ-to-string rad))))
                  '( / fil )
                   '(setq fil (getvar 'rotaterad))
                    (list 'setvar ''rotaterad rad)
                  '(vl-cmdf "_.rotate")
                  '(while (< 0 (getvar 'cmdactive)) (vl-cmdf "\\"))
                 '(setvar 'rotaterad fil)
                  '(princ)
               )
           )
        )
     (princ)
   )
)
Civil3D 2020

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Adding Rotation Command
« Reply #1 on: October 12, 2017, 05:07:29 AM »
Code - Auto/Visual Lisp: [Select]
  1. (defun MyRotate (ang / *error* doc pt ss)
  2.  
  3.   (defun *error* (msg)
  4.     (setvar 'cmdecho 1)
  5.     (vla-endundomark doc)
  6.   )
  7.  
  8.   (setvar 'cmdecho 0)
  9.   (if                               ; Can be replaced with while.
  10.     (and
  11.       (setq ss (ssget))
  12.       (setq pt (getpoint "\nRotation point: "))
  13.     )
  14.     (vl-cmdf "_.rotate" ss "" "_non" pt ang)
  15.   )
  16.   (setvar 'cmdecho 1)
  17.   (princ)
  18. )
  19.  
  20. (foreach ang '(10 12 15 22.5 30 45 90 180)
  21.   (eval
  22.     (read
  23.       (strcat
  24.         "(defun c:r" (vl-string-translate "." "-" (vl-princ-to-string ang)) " () "
  25.         "(MyRotate " (vl-princ-to-string ang) "))"
  26.       )
  27.     )
  28.   )
  29. )

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding Rotation Command
« Reply #2 on: October 12, 2017, 07:11:18 AM »
Hey thank you for taking a stab at this! Works great.
Civil3D 2020

Grrr1337

  • Swamp Rat
  • Posts: 812
Re: Adding Rotation Command
« Reply #3 on: October 12, 2017, 08:21:39 AM »
Nice one Roy!
after you figured out the correct command-call and the code MSTG007 posted (author??), heres my attempt to modify the original code:

Code - Auto/Visual Lisp: [Select]
  1. (  
  2.   (lambda ( L )
  3.     (foreach ang L
  4.       (eval
  5.         (list 'defun (read (strcat "c:r" (vl-string-translate "." "-" (vl-princ-to-string ang)))) '( / ss pt )
  6.           (list
  7.             'while  ; Can be replaced with if.
  8.             '(and
  9.               (setq ss (ssget))
  10.               (setq pt (getpoint "\nRotation point: "))
  11.             )
  12.             (list 'vl-cmdf "_.rotate" 'ss "" "_non" 'pt (vl-prin1-to-string ang))
  13.           )
  14.           '(princ)
  15.         )
  16.       )
  17.     )
  18.     (princ)
  19.   )
  20.   '(10 12 15 22.5 30 45 90 180)
  21. )
  22.  
(apply ''((a b c)(a b c))
  '(
    (( f L ) (apply 'strcat (f L)))
    (( L ) (if L (cons (chr (car L)) (f (cdr L)))))
    (72 101 108 108 111 32 87 111 114 108 100)
  )
)
vevo.bg

MSTG007

  • Gator
  • Posts: 2601
  • I can't remeber what I already asked! I need help!
Re: Adding Rotation Command
« Reply #4 on: October 12, 2017, 08:25:55 AM »
Now I see...

The original Author was Mr. LeeMac..https://www.theswamp.org/index.php?topic=49798.0

He makes things seem simple. lol
Civil3D 2020