home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / p / p086 / 3.img / ACADSUP.LIF / PATH.LSP < prev    next >
Encoding:
Lisp/Scheme  |  1991-06-03  |  23.6 KB  |  5 lines

  1. ;;;*********************************************************************;;;   PATH.lsp 1.01;;;   Copyright (C) 1990 by Autodesk, Inc.;;;;;;   AutoShade/RenderMan camera path command for 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;;;    ;;;*********************************************************************(prompt "\nLoading...")(vmon);;; Load the support functions(setq loaded T)(if (not gather) (load "ptools"))(defun c:PATH (/  count MVI_file SCR_file targ Clens scene ani_name kin#                   campth cm cam_pt index kstart# ask frame# p3 spx2                   pal_flm kin_flm back name# kin Zlens zrate dwg_name                   cam_pline targ_pline anim_set filmroll sht record                  bcolor atkblk targfile targpath pathfile twist)  ;; Setup the system variables  (path_1)  ;; Filmroll setup and number of frames  (path_2)      ;; Fix view settings and get the camera target information  (path_3)    ;; Get Lighting scene information and lens size or zoom  (path_4)     ;; Final steps before getting started  (path_5)      ;; Open up some files for writing, Create the script file header,  ;; and start the Autoshade commands.  (path_6)    ;; Read the data and build the script and MVI files  (path_7)    ;; All done, close up shop.  (write-line ". *\n. **THE END***************************" SCR_file)  (close SCR_file)  (prompt     (strcat "\nAutoShade script " fdir ani_name ".scr has been Created.")  )  (close MVI_file)  (prompt    (strcat "\nAnimation list " fdir ani_name ".mvi has been Created.")  )     ;; Return the system to "normal"   (command "ucs" "P")  (setq *error* *olderror*)  (setvar "cmdecho" 1)  (setvar "osmode" osmode)  (setvar "flatland" flatland )  (setvar "ucsfollow" ucsfollow)  (princ));;;;;; Setup the system variables;;;(defun path_1 ()  ;; Setup the system variables  (setq dwg_name   (justname (getvar "dwgname"))                flatland   (getvar "flatland")        osmode     (getvar "osmode")        ucsfollow  (getvar "ucsfollow")        texteval   (getvar "texteval")        *olderror* *error*        *error*    *close*        ans        T  )  (setvar "osmode" 0)  (setvar "flatland" 0)  (setvar "highlight" 1)  (setvar "ucsfollow" 0)  ;; If this system can use DDATTE, run ATKSetup  (if (= (getvar "popups") 1)    (progn      (setq atkblk (ssget "x" '((2 . "ATKSETUP"))))      (if atkblk        (progn          (if (> (sslength atkblk) 1)            (progn              (setq atkblk nil)              (while (not atkblk)                (setq atkblk (car (entsel "\nATK Setup to use: ")))                (if atkblk                   (if (/= "ATKSETUP" (cdr (assoc 2 (entget atkblk))))                    (setq atkblk nil)                  )                )              )            )            (setq atkblk (ssname atkblk 0))          )          (atkread atkblk)        )        (c:atksetup)                  ; rem out for testing non aui        ;; (setq fdir (getvar "dwgprefix")) ; use for testing non aui      )    )    (setq fdir (getvar "dwgprefix"))  )  (setvar "cmdecho" 0)  (setq holdname dwg_name) ; store the dwg_name setting for later use.  ;; Move to the real world    (command "ucs" "w")  ;; Start asking details  (while (not ani_name)    (setq ani_name (getname                      (strcat "\nAnimation name <" dwg_name ">: "))                   )    (if (not ani_name) (prompt "\nInvalid file name, please re-enter."))  )  (if (= ani_name "")      (setq ani_name dwg_name)  )  ;;  Setup name for scenes and images  (setq rnd_name (substr ani_name 1 4))  (initget "Yes No")  (setq ask (getkword "\nKinetic animation? <N> "))    (if (/= ask "Yes")    (setq dwg_name (getstring                      (strcat "\nFilmroll name <" dwg_name ">: "))                   )  )  (if (/= dwg_name "")      (setq dwg_name (justname dwg_name))  ));;;;;; Filmroll setup and number of frames;;;(defun path_2 ()  ;; Filmroll setup  (if (= ask "Yes")    (progn      (initget 7)      (setq kin# (getint "\nKinetic>> Number of filmrolls to use: "))      (initget 6)      (setq kstart# (getint "\Kinetic>> Starting number <0001>: "))      (if kstart# (setq kstart# (1- kstart#)))      (initget "Sequential or Palindromic")      (setq kin         (getkword "\nKinetic>> Sequential or Palindromic <S>: ")      )      (cond        ((or (= kin nil)(= kin  "Sequential")) (setq kin "S"))        ((= kin "Palindromic") (setq kin "P"))      )      (setq kin_flm             (getstring               (strcat "\nKinetic>> Filmroll title <"                 (strcase (substr holdname 1 4)) ">: "              )            )            kin_flm (substr (justname kin_flm) 1 4)      )      (if (= kin_flm "") (setq kin_flm (substr holdname 1 4)))    )    (if (= dwg_name "") (setq dwg_name holdname))  )  ;; Get number of frames  (while (not frame#)    (if (and kin# (> kin# 2))         (progn        (initget 6)        (setq frame# (getint                        (strcat "\nNumber of Frames <" (itoa kin# )">: ")                     )        )      )      (progn        (initget 7)        (setq frame# (getint "\nNumber of Frames: "))      )    )    (if (not frame#)      (setq frame# kin#)    )    (if (< frame# 3)      (progn        (setq frame# nil)        (princ "\nPlease use a larger number.")      )    )  )  (setq index 0)  ;; Get the camera information  (initget "Fixed Path List")  (setq cm (getkword "\nCamera position: Path/Fixed/List <Path>: "))  (if (= cm "Path")    (setq cm nil)  ));;;;;; Fix view settings and get the camera target information;;;(defun path_3 ()  ;; Fixed view settings  (if (= cm "Fixed")    (progn      (if kin#        (setq cam_pt (getpoint  "\nCamera, fixed view>> Pick a point (press RETURN to use a Scene): ")        )        (progn          (initget 1)          (setq cam_pt (getpoint                         "\nCamera, fixed view>> Pick a point: ")          )        )      )      (if (not cam_pt)        (progn          (setq scene (getstring                        "\nCamera, use Scene>> Enter name <SHOT>: " )          )          (if (= scene "") (setq scene "SHOT"))        )        (setq cam_pt               (strcat (rtos (car cam_pt) 2 4) ","                 (rtos (cadr cam_pt) 2 4) ","                 (rtos (caddr cam_pt) 2 4)              )        )      )    )    (if (not cm)      (progn        (while (not cam_pline)          (setq cam_pline (entsel "\nCamera path>> Select a polyline: "))          (setq cam_pline (polytest cam_pline))        )        (setq campth (gather cam_pline frame#))      )      (progn        (while (not campth)          (setq pathfile (getstring "\nCamera list>> File name: "))                 (setq campth (ptsread pathfile))          (if (and (< txtpt# frame#) campth)            (progn                            (prompt "\nInsufficient number of points.")              (prompt "\nSorry, can not use this file.")              (setq campth nil)            )           )         )      )    )  )  ;; Get the camera target information  (if (= cm "Fixed")    (progn      (initget "Path Fixed List")      (if kin#        (setq targ_type (getkword                          "\nTarget position: Fixed/Path/List <Fixed> "))        (setq targ_type "Path")      )    )    (progn      (initget  "Path Same Fixed List")      (setq targ_type (getkword               "\nTarget position: Fixed/Path/Same path/List <Fixed>: ")      )    )  )  (if (not targ_type)    (setq targ_type "Fixed")  )    (cond    ((= targ_type "Fixed")      (progn        (initget 1)        (setq targ (getpoint "\nFixed target>> Pick a point: "))        (setq targ (strcat (rtos (car targ) 2 4) ","                            (rtos (cadr targ) 2 4) ","                            (rtos (caddr targ) 2 4)                   )        )      )    )    ((= targ_type "Path")      (progn        (while (not targ_pline)          (setq targ_pline                 (entsel "\nTarget path>> Select a polyline: "))          ;;; check and see if this is a legit polyline          (setq targ_pline (polytest targ_pline))                        (if (and cam_pline targ_pline)                  ;;; if we have both, lets see if they are the same.                        (if (eq (car cam_pline) (car targ_pline))              (progn                (initget "Yes No")                (setq test (getkword       "\nDid you want to use the Camera path as the Target path?<N>: ")                )                (if (= test "Yes")                  (setq targ_type "Same")                  (setq targ_pline nil)                )              )            )                      )        )        (if (= targ_type "Path")                      (setq targpath (gather targ_pline frame#))                 )      )    )    ((= targ_type "List")       (while (not targfile)        (setq targfile (getstring "\nTarget list>> File to use: ")              targpath (ptsread targfile)        )        (if (not targpath)           (set targfile nil)          (cond            ((= targfile pathfile)              (progn                (prompt             "\nSorry, you can't use the same file used for Camera path.")                (setq targfile nil)              )            )            ((< txtpt# frame#)              (progn                              (prompt "\nInsufficient number of points.")                (prompt "\nSorry, you can not use this file.")                (setq targfile nil)              )            )            ((equal targpath campth)              (progn                (prompt "\nCamera and target lists are identical.")                (prompt "\nSorry, you can not use this file.")                (setq targfile nil)              )            )          )          )        (setq targ_type "Path")      )    )  )  );;;;;; Get Lighting scene information and lens size or zoom;;;(defun path_4 ()  ;; Get Lighting scene information  (if (not scene)     (progn      (setq scene (getstring "\nScene Name for lighting <None>: "))      (if (or (= scene "") (= scene "None")) (setq scene nil))    )  )  ;; Camera lens size or zoom  (if (not Clens)    (progn      (initget "Zoom")      (setq Clens (getreal "\nCamera Lens length or Zoom <30>: "))      (if Clens T (setq Clens 30))      (if (= Clens "Zoom")        (progn          (initget 1)          (setq lens_s (getreal "\nZoom>> Starting Lens length: "))           (initget 1)          (while (not Zlens)            (setq lens_e (getreal "\nZoom>> Ending Lens length: "))            (if (= lens_s lens_e)                                                       (princ   "\nZoom>> Ending Lens can not be the same length as the Starting Lens."                )                (setq Zlens T)            )          )        )      )    )  )  (if (= Clens "Zoom")    (setq zrate (/ (- lens_e lens_s) (1- frame#))          lens_s (- lens_s zrate)    )  )  ;; Camera twist  (if (not twist) ; check to see if already set    (progn      (initget "Fixed None")      (setq twist (getreal "\nCamera twist - Enter amount/Fixed <None>: "))      (initget 1)      (if (= twist "Fixed")          (setq twist (getreal "\nCamera twist>> Fixed angle: ")              twfx T        )      )         )    )  (if (= twist "None") ;; if twist is off set the value nil    (setq twist nil)  )  (if (and twist (not twfx)) ;; set the value to a progressive rate.    (setq twist (/ twist frame#))  ));;;;;; Final steps before getting started;;;(defun path_5 ()  ;; Final steps before getting started  ;; ask for shade output type  (if (not sht)           (progn       (initget "1 2 3 4 5")      (setq sht (getkword    "\nAutoShade output:\n1)Full 2)Fast 3)Quick 4)Slide 5)RenderMan <1>: "                )      )      (if sht                  (setq sht (read sht))        (setq sht 1)      )    )  )  ;; if fullshade and not RenderMan, ask if they want intersetion  (initget "Yes No")  (if (and (not ints) (= sht 1))    (setq ints (getkword "\nIntersection on ? <N>: "))  )  (if (= ints "No") (setq ints nil))  (if (not record)     (progn       (if (< sht 4)        (progn          (initget "Hardcopy Record Saveimage")          (setq record (getkword                "\nSave images by: Record/Hardcopy/Saveimage <Record>: "                       )          )         )        (progn          (initget "RSB RIb")          (setq record (getkword                         "\nSave images by: RSB/RIb <RSB>: "                       )          )           (initget 1)          (setq ribname (getstring "\nRenderMan Setup Block to use: "))          )      )    )   )  (if (not record) (setq record ""))  (cond    ((or (and (= record "") ribname)         (= (strcase (substr record 1 2)) "RS")) (setq record "RSB"))    ((or (and (= record "") (not ribname))         (= (strcase (substr record 1 2)) "RE")) (setq record "R"))    ((= (strcase (substr record 1 1)) "S") (setq record "S"))    ((= (strcase (substr record 1 2)) "RI") (setq record "RI"))    (T (setq record "H"))  )  (cond                  ; set the suffix for the .mvi file   ((= sht 3) (setq sufx ".sld"))   ((= sht 5) (setq sufx ".tga"))   (    T     (setq sufx ".rnd"))  )     (if (or (not ask) (= ask "No"))     (progn      (initget "Yes No")      (setq filmroll (getkword "\nCreate a filmroll now? <N>: "))      (if (= filmroll "No") (setq filmroll nil))      (if filmroll         (progn          (setvar "cmdecho" 1)          (command "filmroll")          (command (strcat fdir dwg_name))          (setvar "cmdecho" 0)        )      )       )  ));;;;;; Open up some files for writing, Create the script file header,;;; and start the Autoshade commands.;;;(defun path_6 ()  ;; Open up some files for writing  (setq SCR_file (open (strcat fdir ani_name ".scr") "w"))  (setq MVI_file (open (strcat fdir ani_name ".mvi") "w"))     ;; Create the script file header    (write-line     ". ***************************************************************"       SCR_file  )  (write-line (strcat ". *  "  (strcase ani_name) ".SCR\n. *") SCR_file)  (if (= sht 5)    (write-line ". * Autodesk RenderMan process" SCR_file)  )  (if kin#    (write-line        ". * Path 1.01 - Kinetic animation script for AutoShade."        SCR_file    )     (write-line        ". * Path 1.01 - Camera path animation script for AutoShade."        SCR_file    )                        )  (write-line     (strcat ". *\n. * Total frames: " (itoa frame#)) SCR_file  )  (write-line     (strcat ". * Source drawing: " (strcase holdname) ".DWG\n. *") SCR_file  )   (write-line     ". ***************************************************************"       SCR_file  )  ;; Start the Autoshade commands   (if (and (< sht 4) (/= record "S"))     (if (= record "H")       (write-line "hardcopy on" SCR_file)       (write-line "record on" SCR_file)     )   )       (if kin     (setq name# 0) ; set the name counter     (progn       (header)
  2.        (write-line (strcat "open " (strcase dwg_name T)) SCR_file)     )   )         (setq count 1));;;;;; Read the data and build the script and MVI files;;;(defun path_7 ()  (repeat frame#    (write-line       (strcat         ". *\n. **FRAME " (itoa count)"*************************\n. *"      )       SCR_file    )    ;; Kinetic Sequential order    (cond       ((= kin "S")         (progn          (setq name# (1+ name#))          (if (> name# kin#)            (setq name# 1)          )          (if kstart#            (setq pal_flm (cname kin_flm (+ name# kstart#)))            (setq pal_flm (cname kin_flm name#))          )          (header)
  3.           (write-line (strcat "open " pal_flm) SCR_file)        )      )      ;; Kinetic Palendromic order      ((= kin "P")        (progn          (if (>= name# kin#)            (setq back 1)            (if (= name# 1)              (setq back nil)            )          )          (if back            (setq name# (1- name#))            (setq name# (1+ name#))          )          (if kstart#            (setq pal_flm (cname kin_flm (+ name# kstart#)))            (setq pal_flm (cname kin_flm name#))          )          (header)
  4.           (write-line (strcat "open " pal_flm) SCR_file)        )      )    )    ;; Camera lens zoom control    (if (= Clens "Zoom")      (progn        (setq lens_s (+ lens_s zrate))        (write-line (strcat "lens " (rtos lens_s 2 4)) SCR_file)      )    )    ;; Camera twist control    (if twist      (progn        (setq tw2 (rtos twist 2 6))        (write-line (strcat "twist " tw2) SCR_file)        (if (= twist "Fixed") T (setq twist (+ twist tw)))      )    )    ;; Camera position control    (if (/= cm "Fixed")      (progn        (setq cam_pt (nth index campth)              cam_pt (strcat                        (rtos (car cam_pt) 2 4) ","                        (rtos (cadr cam_pt) 2 4) ","                        (rtos (caddr cam_pt) 2 4)                      )        )      )    )    ;;  Camera target control    (if cam_pt       (progn        (cond          ;;  Target Path          ((= targ_type "Path")            (progn              (setq targ2 (nth index targpath)                    targ2 (strcat                             (rtos (car targ2) 2 4) ","                             (rtos (cadr targ2) 2 4) ","                             (rtos (caddr targ2) 2 4)                          )              )              (write-line (strcat "target " targ2) SCR_file)            )          )          ;; Target fixed point          ((= targ_type "Fixed")             (write-line (strcat "target " targ) SCR_file)          )          ;; Target Same path          ((= targ_type "Same")            (progn              (if (< index (1- (length campth)))                (setq targ2 (nth (1+ index) campth))                (setq targ2 (polar                               (setq a1 (nth index campth))                               (angle (setq a2 (nth (1- index)campth))a1)                              (distance a1 a2)                            )                )              )              (setq targ2 (strcat                             (rtos (car targ2) 2 4) ","                             (rtos (cadr targ2) 2 4) ","                             (rtos (caddr targ2) 2 4)                          )              )              (write-line (strcat "target " targ2) SCR_file)            )          )        )        (write-line (strcat "camera " cam_pt) SCR_file)      )    )    ;; Shade type control    (cond      ((= sht 1) (write-line                    (if (= record "S")                      (strcat "fullshade" "")                      (strcat "fullshade " (cname rnd_name count))                    )                    SCR_file                 )      )      ((= sht 2) (write-line                    (if (= record "S")                      (strcat "fastshade" "")                      (strcat "fastshade " (cname rnd_name count))                    )                   SCR_file                 )      )      ((= sht 3) (write-line                    (if (= record "S")                     (strcat "quickshade" "")                     (strcat "quickshade "(cname rnd_name count))                   )                   SCR_file                 )      )      ((= sht 4) (write-line                    (strcat "slide " (cname rnd_name count))                    SCR_file                  )      )      ((= sht 5)         (if atkblk           (progn             (if shads               (if (and (= shads 2) (not kin))                 (setq shadows "off,on")                 ;; Set shads to 2 to turn off create.                 (setq shadows "on,on" shads 2)               )               (setq shadows "off,off")             )             (write-line (strcat "ribspec 0,0," imagerez ","                                   prate "," shadows ",,")                                      SCR_file             )             (if (/= record "RI")               (write-line (strcat "render on, ATKTemp, "                                    (cname rnd_name count))                                    SCR_file               )              )           )           (if (= record "RSB")             (write-line (strcat "render on, ATKtemp, "                                          (cname rnd_name count))                         SCR_file             )           )         )         (if (or (= routput "framebuffer") (= record "S"))           (write-line (strcat "saveimage "                               (cname rnd_name count)                                    ",tga,0,0," imagerez)                                SCR_file           )         )       )    )    ;; do a Saveimage    (if (and (= record "S") (< sht 4))      (write-line (strcat "saveimage "                           (cname rnd_name count)                           ",tga,0,0," imagerez)                    SCR_file      )    )    ;; do a RIBout    (if (and (= record "RI")(= sht 5))      (write-line (strcat "ribout "(cname rnd_name count)","                                   (cname rnd_name count))                              SCR_file      )    )    ;; Write MVI information     (write-line (strcat (cname rnd_name count) sufx) MVI_file)        ;; Counters    (setq index (1+ index))    (setq count (1+ count))  )  ;; End of repeat);;;*********************************************************************;;;;;; Supporting functions;;;;;;*********************************************************************;;;;;; Function to create the script headers;;;(defun header ()  (write-line "spercent -1" SCR_file)  (if (and scene (/= scene "None"))      (write-line (strcat "scene " scene) SCR_file)   )  (if bcolor    (write-line (strcat "backgroundcolor " bcolor) SCR_file)  )  (write-line "perspective on" SCR_file) ;;; turn perspective on  (if (/= Clens "Zoom")      ;;; set the lens length if not a zoom process     (write-line (strcat "lens " (rtos Clens 2 0)) SCR_file)               )  (if (and atkblk (= sht 5))  ;if this is a RenderMan process and we used the ATK block    (progn         (if (not ribname) (setq ribname "default"))          (write-line (strcat "rsbbegin " ribname) SCR_file) ;; start rib change      (write-line "ribformat on" SCR_file )       ;; make it a binary RIB      (if (/= routput "framebuffer")         (write-line (strcat "destination " routput) SCR_file)            )      (if pixsamp        (write-line (strcat "pixelsample " pixsamp) SCR_file)       )      (write-line "rsbend" SCR_file)                 ; end rib change    )  )  (if (= sht 5)    (write-line (strcat "setup " ribname) SCR_file)  ;;; Ribname to use  )  (if (< sht 5)    (progn      (if smooth        (write-line "smoothshading on" SCR_file) ; turn on smooth shading      )      (if ints                          ; turn on intersection checking        (write-line "intersection on" SCR_file)      )    )  ) );;;;;; End of the load, pop a howdy!;;;(Princ "\nPATH v1.01 - Loaded!")(princ)
  5.