;;;*********************************************************************;;; Kinetic.lsp 1.01;;; Copyright (C) 1990 by Autodesk, Inc.;;;;;; Entitiy animation command for use with AutoCAD Release 10;;; ;;; Permission to use, copy, modify, and distribute this software and its;;; documentation for any purpose and without fee is hereby granted. ;;;;;; THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ;;; ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF ;;; MERCHANTABILITY ARE HEREBY DISCLAIMED.;;; ;;; Designed and implemented by Jamie Clay in June of 1990;;; Reformatted file for compliance with coding standards. ;;; JSY -- Sept. 1990;;; ;;; Note: Requires the presence of PTOOLS.LSP;;; ;;;*********************************************************************;;; NUMBERS;;; f# - total number of frames;;; s# - entity motion start number;;; r# - entity motion steps;;; c# - count number for entity list;;; m# - stored value for frame starting number;;; rf# - reference entity counter;;; strt# - start number for filmrolls;;; count - animation process counter;;; ent_sel - index counter for anim_set;;; ent_sel# - number of lists in anim_set;;;;;; STRINGS;;; flm - updated name for filmrolls;;; kflm - saved name for filmrolls;;; kname - user entered filmroll name;;; pline - response string for path prompt;;;;;; LISTS;;; anim_set - master animation list;;; hold_set - backup animation list used for test mode;;; items - selected entites;;; camlst - path points;;; remove - polyline paths to be removed in slide animations.;;; rot - block rotation information;;; xs - block x scale information;;; ys - block y scale information;;; zs - block z scale information;;; rfpt;;;;;; MISC;;; appfile - append support file switch;;; hide - hide command switch;;; seepath - read a PATH script switch;;; rem - remove path switch;;; testmode - test animation switch;;; flatland - flatland value when routine is started;;; osmode - object snap value when routine is started;;; blipmode - blip setting value when routine is started;;; *olderror* - stored *error* function;;; steps - while switch;;; select - switch for animation setup while loop;;;;;;*********************************************************************(prompt "\nLoading...")(vmon)(defun c:kinetic (/ outfile select spin flm kflm kname f# items zs spin ent_sel remove anim_set hold_set ent_sel# count camlst r# s# c# pline rfpt rf# hide seepath rem appfile ucsfollow refents sshade) ;; This function has been broken into three parts to allow it to run in ;; very tight memory situations. The three functions are listed below. (kine-1) ; Set up, get name and frames. (kine-2) ; Start the selection while loop. (kine-3) ; Output and cleanup before exiting. (princ));;; Kinetic part 1 of the defun c:kinetic;;; All variables are defined in c:kinetic.(defun kine-1 () (if (= oset "Test")(setq oset nil)) ;; Set up the system variables (setvar "cmdecho" 1)
(setq rf# 0 flatland (getvar "flatland") ucsfollow (getvar "ucsfollow") osmode (getvar "osmode") blipmode (getvar "blipmode") ent_sel -1 *olderror* *error* *error* *close* ) (setvar "flatland" 0) (setvar "osmode" 0) (setvar "highlight" 1) (setvar "ucsfollow" 0) (command "ucs" "world") (getdir) ; Find atk information ;; Get the file name (if (not dwg_name) (setq kflm (substr (justname (getvar "dwgname")) 1 4)) (setq kflm (substr dwg_name 1 4)) ) (while (not kname) (setq kname (getname (strcat "\nFilmroll title <" kflm ">: "))) (if (not kname) (prompt "\nInvalid file name, please re-enter.")) ) (if (= kname "") (setq kname (justname (getvar "dwgname"))) (setq kflm (substr kname 1 4)) ) (while (not f#) (initget 7) (setq f# (getint "\nNumber of frames: ")) (if (< f# 3) (progn (setq f# nil) (prompt "\nPlease use a larger number.") ) ) ) (if (or (not deed) (= deed "TEST")) (setq m# 1)) (if (not m#) (setq m# 1)) (initget 6) (setq strt# (getint (strcat "\nStarting number <" (cname "" m#) ">: ")) ) (if strt# (setq m# strt#)));;; Kinetic part 2 of the defun c:kinetic;;; All variables are defined in c:kinetic.(defun kine-2 () (setq select T) (while select (prompt "\n\n[Entity Selection]\n*press RETURN when finished*") (setq items (elget) ; Collect entities to move xs 0 ys 0 zs 0 rfpt nil steps T ) (if items (progn ;; get the entity motion information (if (/= f# 3) ; if this is a 3 frame animation, skip this part. (motion_steps) (setq s# 1 c# 0) ) ; end of if \= 3 f# ;; get the path information (kine2a) ;; get the spin information (kine2b) ;; set angles and the animation set (kine2c) ) ; end of the 'if items true progn' (progn (if (< (length anim_set) 1) (setq anim_set nil) (progn (initget "Yes No") (setq select (getkword "\nAre you finished with the selection process? <Y>: ") ) (if (or (not select) (= select "Yes")) (setq select nil) ) ) ) ) ) ;end of the 'if items' (setq testf# f# testm# m# ) ) ; end of the 'while select');;; Kinetic part 2, subpart a;;; All variables are defined in c:kinetic.(defun kine2a () ;; get the path information (while (not pline) (initget "Fixed Path List") (setq pline (getkword "\nEntity motion: Path/Fixed/List <Path>: ")) (if (= pline "Path") (setq pline nil)) (cond ((= pline "Fixed") (refpoint)) ((= pline "List") (while (not camlst) (setq pathfile (getstring "\nMotion, point list>> File to use: ") camlst (ptsread pathfile) ) (if (and (< txtpt# r#) camlst) (progn (prompt "\nInsufficient number of points.") (prompt "\nSorry, can not use this file.") (setq camlst nil) ) ) ) ) ((not pline) (progn (while (not pline) (setq pline (entsel "\nMotion path>> Select a polyline: ") ) (setq pline (polytest pline)) ) (if remove (setq remove (ssadd (car pline) remove)) (setq remove (ssadd (car pline))) ) (setq spin T) (if r# (setq camlst (gather pline r#)) (setq camlst (gather pline f#)) ) ) ) ; No T condition. If a cond isn't found it this cond will pass through ) ));;; Kinetic part 2, subpart b;;; All variables are defined in c:kinetic.(defun kine2b () (while spin (initget "Reference X Y Z") (if (or rfpt (= pline "Fixed")) (setq spin (getkword (strcat "\nRotation settings X[" (rtos xs 2 2) "] Y[" (rtos ys 2 2) "] Z[" (rtos zs 2 2) "]\nRotation>> X/Y/Z (press RETURN when finished): ") ) ) (setq spin (getkword (strcat "\nRotation settings X[" (rtos xs 2 2) "] Y[" (rtos ys 2 2) "] Z[" (rtos zs 2 2) "]\nRotation>> X/Y/Z/Reference (press RETURN when finished): ") ) ) ) (initget 1) (cond ((= spin "X") (setq xs (getreal "\nRotation X axis: "))) ((= spin "Y") (setq ys (getreal "\nRotation Y axis: "))) ((= spin "Z") (setq zs (getreal "\nRotation Z axis: "))) ((and (= spin "Reference") (/= pline "Fixed")) (progn (refpoint) (setq items (append (list (entlast)) items)) ) ) ; No T condition. If a cond isn't found it this cond will pass through ) ));;; Kinetic part 2, subpart c;;; All variables are defined in c:kinetic.(defun kine2c () (if r# (setq xang (rtos (/ xs r#) 2 4) yang (rtos (/ ys r#) 2 4) zang (rtos (/ zs r#) 2 4) ) (setq xang (rtos (/ xs (1- f#)) 2 4) yang (rtos (/ ys (1- f#)) 2 4) zang (rtos (/ zs (1- f#)) 2 4) r# f# ) ) (setq spin nil pline nil ent_sel (1+ ent_sel) ent_sel# (1+ ent_sel) count 0 ) (if anim_set (setq anim_set (append anim_set (list (list items rfpt xang yang zang camlst s# c# r#))) ) (setq anim_set (list (list items rfpt xang yang zang camlst s# c# r#)) ) ) (setq camlst nil s# nil ) (setvar "highlight" 0) (command "select" (elgot items) "") (if rfpt (command "select" "p" rfpt "")) (setvar "highlight" 1) (setq select T));;; Kinetic part 3 of the defun c:kinetic;;; All variables are defined in c:kinetic.(defun kine-3 () (output) ; find output format (if (= deed "TEST") (progn (setq hold_set anim_set testmode T ) (while testmode (command "undo" "mark") (k_action) ; do the animation (princ "\n*press any key to reset animation*") (while (/= (nth 0 (grread)) 2)) ;pause for keyboard input (command "undo" "back") (output) ; Get output settings (if (/= deed "TEST") (setq testmode nil) ) (setq count 0 ; Restore the values needed for animation f# testf# m# testm# anim_set hold_set ) ) ) ) ;; if you are doing a slide process, remove the paths. (if you want to) (if rem (command "erase" remove "") ) (if deed (k_action) ) ;; All done, shut her down (if outfile (progn (close outfile) (cond ((= deed "MSLIDE") (princ (strcat "\nAnimation list " (strcase fdir) (strcase fname))) ) ((= deed "SAVE") (princ (strcat "\nDrawing block list " (strcase fdir) (strcase fname))) ) ) (if appfile (princ " updated.") (princ " created.") ) ) ) (if seefile (close seefile)) (if rem (progn (setq repo 0) (repeat (sslength remove) (entdel (ssname remove repo)) (setq repo (1+ repo)) ) ) ) ;; if there are reference entities, remove them. (if refents (command "erase" refents "") ) (command "ucsicon" "all" "on") (command "undo" "end") (setvar "cmdecho" 1) (setvar "highlight" 1) (setvar "ucsfollow" ucsfollow) (setq *error* *olderror*));;; Supporting defuns;;; K_ACTION -(defun k_action () (setq f# (1- f#)) (command "ucsicon" "all" "off") (if seepath (view seepath)) ;; Hide or shade the image as requested (if hide (command "hide") (if sshade (command "shade") ) ) (setq flm (cname kflm m#) m# (1+ m#) ) (if (or (= deed "MSLIDE") (= deed "SAVE")) (supfile flm kname) ) (if (= deed "TEST") (princ (strcat "\nTest mode >> " flm )) (progn (princ (strcat "\nMaking " fdir flm sfx)) (if (and (findfile (strcat fdir flm ".dwg"))(= deed "SAVE"))