PDA

View Full Version : Animated layers



artisteroi
2007-05-25, 02:14 AM
This is a lisp make a simple animation.
You will have to set up the save directory and un-comment the line in the code for the size of the objects you want to animate. Load the file into any 3D drawing, MAKE SURE THE BULK OF YOUR DRAWING OBJECTS ARE AT 0,0,0. freeze all the layers and then run the app. It will sort the layers alpha-numerically, turn them on one at a time, render, and save a .bmp file to the chosen directory. This is a great tool for showing clients the current progress of a project. adding numbers to the front of the layer names will insure that they appear in the proper sequence.


; ANIMATOR.LSP: Thaws layers according to given list sequence.
; writes animation frames as camera moves around target
; Written and modified by Steve Caldwell 2006
(alert "Animator.lsp Type ANIME to start")
(defun c:anime (/ laylist compiledlist finallist)
(command "arx" "L" "acrender.arx")
(setq osmode (getvar "osmode")) ; assigns osnap settings to variables
(setvar "osmode" 0) ; turns off osnaps
;(command "_layer" "_make" "target" "") ; creates target layer
;(command "_point" 0,0,0 "") : creates target point
;(command "_layer" "_make" "camera" "") ; creates camera layer
;(command "_point" 0,14,14 "") ; creates camera point for objects under 1 SQ ft
;(command "_point" 0,48,48 "") ; creates camera point for objects under 2 SQ FT
;(command "_point" 0,120,120 "") ; creates camera point for objects under 6 SQ FT
;(command "_point" 0,480,480 "") ; creates camera point for objects under 20 SQ FT
;(command "_point" 0,960,960 "") ; creates camera point for objects under 40 SQ FT
(setq camera (ssget "x" '((8 . "camera"))))
;;;collect all from camera layer
(setq target (ssget "x" '((8 . "target"))))
;;;collect all from target layer
(setq counter 9)
;;;set the save file counter
(setq layercount 0)
(setq compiledlist nil)
;;;create compiledlist with nil value
(setq laylist (tblnext "layer" T))
;;;create layerlist from ACAD drawing database
(while laylist
;;;while layerlist has a value
(setq lname (cdr (assoc 2 laylist)))
;;;create layer name from second object in laylist
(setq compiledlist (append compiledlist (list lname)))
;;;create complete list of layer names
(setq layercount (1+ layercount))
(setq laylist (tblnext "layer"))
;;;loop back to ACAD drawing database
)
;;;close while
(setq moviefile 1000)
;;;set the save file start name
(while (< counter layercount)
;;;set loop counter
(command "_.LAYER" "_Thaw" "0" "_Set" "0" "")
;;;command loop to run
(setq finallist (acad_strlsort compiledlist))
;;;creat final list from sorted complete list
(foreach ln finallist
;;;step thru final list
(if (tblsearch "LAYER" ln)
;;;if layername is in drawing database
(progn
;;;begin loop
(command "_.LAYER" "_Thaw" ln "")
;;;run command using 'ln' for names in final list
(command "regen")
;;;regen layer after thaw
(setq delay 0)
;;;delay re-loop to observe sequence
(while (< delay 1)
;;;set reloop delay
(setq delay (1+ delay))
;;;add one to delay
)
;;;close delay
(setq imagecount 0)
;;;set image counter loop
(while (< imagecount 4)
;;;limit image counter to 5 images
(setq cpt
(cdr
(assoc
10
(entget (ssname (ssget "x" '((8 . "camera"))) 0))
)
)
)
;;;locate camera point
(setq tpt
(cdr
(assoc
10
(entget (ssname (ssget "x" '((8 . "target"))) 0))
)
)
)
;;;locate target point
(setq cam (strcat (rtos (car cpt))
","
(rtos (cadr cpt))
","
(rtos (caddr cpt))
)
)
;;;convert camera point to 3d list
(setq tgt (strcat (rtos (car tpt))
","
(rtos (cadr tpt))
","
(rtos (caddr tpt))
)
)
;;;convert target point to 3d list
(command "ROTATE" Camera "" "0, 0, 0" "-.2")
;;;shift camera X = 0 Y = 02 Z = 00
(setq dist (distance cpt tpt))
;;;calculate distance camera to target
(command "dview" "all" "" "po" tgt cam "d" (rtos dist) "cl" "" "")
;;;set view to perspective for drama
(command "render" "am_plan")
;;;render image if desired
(command
"jpgout"
(strcat
"C:/Documents and Settings/all users/Desktop/animation/Images/"
(itoa moviefile)
)
"all"
""
)
;;;save image as jpeg to designated directory
(setq moviefile (1+ moviefile))
;;;increment file number by one
(setq counter (1+ counter))
;;;increment loop number by one
(setq imagecount (1+ imagecount))
;;;increment imagecounter by one
)
;;;close imagecounter
)
;;;close program loop
) ;close while counter
) ;close table search loop
(princ) ;display results
) ;close for each final list loop
(setvar "osmode" 1) ;turns osnaps on
) ;close lisp program[ Moderator Action = ON ] What are [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code) [ Moderator Action = OFF ]