Jump to content

a lisp routine to have an object rotate 360


djw

Recommended Posts

  • Replies 32
  • Created
  • Last Reply

Top Posters In This Topic

  • djw

    9

  • alanjt

    8

  • Hippe013

    8

  • Freerefill

    3

Top Posters In This Topic

Posted Images

hi try this:)

 

 

(defun c:ani (/ cntr entgrp fname num rotpnt)
    ; Turn command echoing off
 (setq cmdold (getvar "cmdecho"))
    ;(setvar "cmdecho" 0)
    ; Select the objects
 (setq entgrp (ssget))
    ; Check to make sure you selected something
 (if entgrp
   (progn
    ; Set undo point
     (command ".undo" "Mark")
    ; Pick rotation point
     (setq rotpnt (getpoint "\nPick rotation point:<0,0,0> "))
     (if (= rotpnt nil)
(setq rotpnt (list 0 0 0))
     )
    ; Enter number of images     
     (setq num (getint "\nEnter number of images:<5> "))
     (if (= num nil)
(setq num 5)
     )
    ; Pick or enter degrees of movement     
     (setq deg (getint "\nEnter degrees of movement:<3> "))
     (if (= deg nil)
(setq deg 3)
     )
    ;Enter number name of the first image
     (setq cntr
     (getint "\nEnter the number name of the first image:<1> ")
     )
     (if (= cntr nil)
(setq cntr 1)
     )
    ; Add your path here 
     (setq dir (getstring T "/nEnter the directory name:<Ani>"))
     (if (= dir nil)
(setq dir "Ani")
     )
     (setq fnamechk (strcat "c:\\TestImage\\" dir))
     (if (not (vl-file-directory-p fnamechk))
(vl-mkdir fnamechk)
     )
     (repeat num
(setq
  fname (strcat "c:\\TestImage\\" dir "\\" (itoa cntr) ".jpg")
)
(progn
    ; Change the options
  (command "-render" "medium" "Render" "640" "480" "Yes"
    fname)
    ; Rotate the object
  (command ".move" entgrp "" "@0,0,0" "@0,0,-.25")
  (command ".rotate" entgrp "" rotpnt deg)
  (setq cntr (1+ cntr))
)    ; progn
     )     ; repeat
     (command ".undo" "Back")
   )     ; progn
 )     ; if
    ; Return echo
 (setvar "cmdecho" cmdold)
 (princ)
)

Link to comment
Share on other sites

Rotate two objects (Clockwise) say 90 degrees at the same time,

using a lisp on this post from Freerefill, got it to work for the 90 degrees.

Butt (1) can't git it to go (Clockwise) (2) or Rotate two objects at the same time...

Link to comment
Share on other sites

One more example (you'll need the AT:SS->List subroutine located in my other post):

(defun c:Test3 (/ ss gr)
 ;; Alan J. Thompson, 06.28.10
 (if (setq ss (AT:SS->List (ssget "_:L" '((0 . "INSERT"))) T))
   (while (and (eq 5 (car (setq gr (grread T 15 2)))) (vl-consp (cadr gr)))
     ((lambda (ang)
        (foreach x ss (vla-put-rotation x (+ (vla-get-rotation x) (setq ang (- ang)))))
      )
       0.02
     )
   )
 )
 (princ)
)

 

Test2 (in my other post) is also an example of rotating multiple objects. These are all very simple, but should give you some ideas.

 

ROT.gif

Link to comment
Share on other sites

Hi Alanjt thanks but all I get

Test3; error: no function definition: AT:SS->LIST

it's Probably just me..

Please See Att Jpg..

Link to comment
Share on other sites

Hi Alanjt thanks but all I get

Test3; error: no function definition: AT:SS->LIST

it's Probably just me..

Please See Att Jpg..

 

 

One more example (you'll need the AT:SS->List subroutine located in my other post):

Read the entire post.:roll:

Link to comment
Share on other sites

One more example (you'll need the AT:SS->List subroutine located in my other post):

(defun c:Test3 (/ ss gr)
 ;; Alan J. Thompson, 06.28.10
 (if (setq ss (AT:SS->List (ssget "_:L" '((0 . "INSERT"))) T))
   (while (and (eq 5 (car (setq gr (grread T 15 2)))) (vl-consp (cadr gr)))
     ((lambda (ang)
        (foreach x ss (vla-put-rotation x (+ (vla-get-rotation x) (setq ang (- ang)))))
      )
       0.02
     )
   )
 )
 (princ)
)

 

Test2 (in my other post) is also an example of rotating multiple objects. These are all very simple, but should give you some ideas.

 

[ATTACH]21280[/ATTACH]

 

Nice code AlanJT, I had some fun playing with this.

If the selected blocks would come back in original place it could be useful also. (To point to blocks and animate them to inform which one was meant... yeah...I am bored too...8))

Link to comment
Share on other sites

Nice code AlanJT, I had some fun playing with this.

If the selected blocks would come back in original place it could be useful also. (To point to blocks and animate them to inform which one was meant... yeah...I am bored too...8))

 

with reset...

 

(defun c:Test4 (/ ss gr)
 ;; Alan J. Thompson, 06.28.10
 (if (setq ss (AT:SS->List (ssget "_:L" '((0 . "INSERT"))) T))
   (progn
     (setq ss (mapcar (function (lambda (b) (cons b (vla-get-rotation b)))) ss))
     (while (and (eq 5 (car (setq gr (grread T 15 2)))) (vl-consp (cadr gr)))
       ((lambda (ang)
          (foreach x ss
            (vla-put-rotation (car x) (+ (vla-get-rotation (car x)) (setq ang (- ang))))
          )
        )
         0.02
       )
     )
     (foreach b ss (vla-put-rotation (car b) (cdr b)))
   )
 )
 (princ)
)

Link to comment
Share on other sites

Funny lisp! Maybe I can use it to prank some collegues sometimes. Redifine te erase command.... :shock: lol

 

Thanks for the input!

Link to comment
Share on other sites

Funny lisp! Maybe I can use it to prank some collegues sometimes. Redifine te erase command.... :shock: lol

 

Thanks for the input!

HaHa, go for it.

You're welcome. :)

Link to comment
Share on other sites

jpg did'nt upload please see PDF

 

djw

 

Could you upload your dwg or dxf? It would be easier to create a lisp to animate those objects if we knew what it was that was needed to animate.

 

hippe013

Link to comment
Share on other sites

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