home *** CD-ROM | disk | FTP | other *** search
Wrap
/* CMD: ½CurveToMotion */ /* By Brett Evan Hester 13032 Copenhill Rd. Dallas, Tx. 75240-5302 */ MacrosName = "CurveToMotion" /* Macro Type: */ /* CREATES * MOTIONS * LAYER NEEDED * WARNING! * REMEMBERS */ /* Description: */ Info1A = "!Curve To Motion © Information 1 of 2" Info1B = "" Info1C = "@This macro asks the user to create a curve, via " Info1D = "@the 'Sketch' button. It will then convert, and " Info1E = "@save, the given curve into a motion file. " Info1F = "" Info1G = "þ This macro will move to an empty layer. The " Info1H = " previously current layer will be in the BKG. " Info1I = "¤ Any layers previously in the BKG will still be" Info1J = " in the background. " Info1K = "þ Select 'Sketch' and draw a curve. " Info1L = "¤ Then press RETURN or select 'Make'. " Info1M = "þ A Menu will appear asking or saying if this " Info1N = " curve is acceptable to be saved. " Info2A = "!Curve To Motion © Information 2 of 2" Info2B = "@ Plug-Ins and Go! © " Info2C = " Hester and associates" Info2D = " 13032 Copenhill Road " Info2E = " Dallas, Texas 75240 " Info2F = "@Special Thanks to: " Info2G = "Arnie Cachelin Henry Ribron Mark J. Holland " Info2H = "J. Phil Kelso Terry Wester Steven K. Simms " Info2I = "Kevin DeRita Greg Glaser William S. Hawes" Info2J = "NewTek © Commodore © INOVAtronics © " Info2K = "" Info2L = "@This macro represents a lot of time & hard work." Info2M = "@Encourage people to create new ones and not kill" Info2N = "@that possibility by stealing those that are out." /* -------------------------------------------------------------------- */ /* Start Error Detection (See End) */ SIGNAL ON ERROR SIGNAL ON SYNTAX /* Address LightWave */ VT3DLib = ADDLIB("LWModelerARexx.port",0) ADDRESS "LWModelerARexx.port" /* Add Support Functions */ SupportLib = "rexxsupport.library" IF POS(SupportLib , SHOW('L')) = 0 THEN IF ~ADDLIB(SupportLib , 0 , -30 , 0) THEN DO CALL Notify(1,"!Can't find "SupportLib) CALL Exiting END /* -------------------------------------------------------------------- */ IF SHOW(CLIP,"Stage") = 0 THEN CALL SETCLIP("Stage","1") Stage = GETCLIP("Stage") /* -------------------------------------------------------------------- */ /* >>>>>>>>>>>>>> STAGE ONE <<<<<<<<<<<<<<< */ If Stage = 1 THEN DO CALL SETCLIP("Stage","2") PARSE SOURCE TempA TempB CurveToMotionMacro TempD TempE TempF ADDRESS COMMAND "C:RUN C:RX "||CurveToMotionMacro ADDRESS CALL Exiting END /* -------------------------------------------------------------------- */ /* >>>>>>>>>>>>>> STAGE TWO <<<<<<<<<<<<<<< */ IF Stage = 2 THEN DO CALL SETCLIP("Stage") /* -------------------------------------------------------------------- */ /* Reading Global Macro Preferences */ BEHDefaultFilePath = "Sys:" BEHSettingsSavedTo = "T:" BEHSpeechAndSound = "1" IF (EXISTS("S:PlugInPrefs")) THEN DO IF (~OPEN(PlugInPrefs, "S:PlugInPrefs", 'R')) THEN BREAK IF (READLN(PlugInPrefs) ~= "PlugInPrefs") THEN BREAK BEHDefaultFilePath = READLN(PlugInPrefs) BEHSettingsSavedTo = READLN(PlugInPrefs) BEHSpeechAndSound = READLN(PlugInPrefs) CALL CLOSE PlugInPrefs END /* -------------------------------------------------------------------- */ /* Recalling Macro Settings */ ReqStart = "0" ReqSpace = "1" FilePath = "Motions" PrefsFileName = BEHSettingsSavedTo||MacrosName||".PLUG" IF (EXISTS(PrefsFileName)) THEN DO IF (~OPEN(PrefsFile, PrefsFileName, 'R')) THEN BREAK IF (READLN(PrefsFile) ~= MacrosName) THEN BREAK ReqStart = READLN(PrefsFile) ReqSpace = READLN(PrefsFile) FilePath = READLN(PrefsFile) CALL CLOSE PrefsFile END /* -------------------------------------------------------------------- */ /* Empty Layer Setup */ CL = CurLayer() BL = CurBLayer() Empty = EmptyLayers() IF (WORDS(Empty) < 1) THEN DO CALL Notify(1,"!Sorry!","!Need an empty layer","for this operation.") CALL Exiting END EL = WORD(Empty, 1) /* -------------------------------------------------------------------- */ /* For Information Window */ BEHInfo = 1 /* For Coming Back to Main Menu after Info Window */ DO WHILE BEHInfo /* -------------------------------------------------------------------- */ /* User Interface */ CALL Req_Begin("Curve to Motion © by Brett Hester") CALL Req_AddControl("Draw a",'T',"curve on the current") CALL Req_AddControl("empty layer",'T',"with the 'Sketch' tool...") CALL Req_AddControl("",'T',"") CALL Req_AddControl("NOTE: The curve",'T',"cannot have more than 19 points.") ReqA = Req_AddControl("",'CH', "Information") CALL Req_SetVal(ReqA, 0) OKorCancel = Req_Post() ; IF OKorCancel = 0 THEN CALL Exiting BEHInfo = Req_GetVal(ReqA) CALL Req_End() IF BEHInfo = 1 THEN CALL InformationWindows END /* -------------------------------------------------------------------- */ CALL SetLayer(EL) CALL SetBLayer(CL BL) CALL Cut() /* Clearing the buffer */ OKorCancel = 1 DO WHILE OKorCancel = 1 Box = BoundingBox() PARSE var Box NumOfPnts X1 X2 Y1 Y2 Z1 Z2 IF NumOfPnts > 0 THEN DO IF CurLayer() = EL THEN DO IF NumOfPnts = 1 THEN DO OKorCancel = Notify(2,"!Sorry!","Please, create the curve via the 'Sketch' tool.","","@þ OK will allow you to draw another curve.","@þ CANCEL will exit this macro. ") IF OKorCancel = 1 THEN CALL Cut() IF OKorCancel = 0 THEN CALL Exiting END IF NumOfPnts >= 20 THEN DO OKorCancel = Notify(2,"!Sorry!","The maximum number of points","along the curve must be less than 20.","","@þ OK will allow you to draw another curve.","@þ CANCEL will exit this macro. ") IF OKorCancel = 1 THEN CALL CUT() IF OKorCancel = 0 THEN CALL Exiting END IF NumOfPnts < 20 THEN DO YesOrNo = Notify(3,"!Continue?","Is the curve you created acceptable?","","@þ YES will continue towards saving a motion file.","@þ NO will allow you to draw another curve. ") IF YesOrNo = 1 THEN OKorCancel = 0 IF YesOrNo = 0 THEN DO OKorCancel = 1 CALL CUT() END END END IF CurLayer() ~= EL THEN DO OKorCancel = Notify(2,"!Sorry!","Please do not leave the empty layer.","","@þ OK will return you to the empty layer ","@ and allow you to draw another curve. ","","@þ CANCEL will exit this macro. ") IF OKorCancel = 1 THEN DO CALL SetLayer(EL) CALL SetBLayer(CL BL) END IF OKorCancel = 0 THEN CALL Exiting END END END /* -------------------------------------------------------------------- */ /* For Information Window */ BEHInfo = 1 /* For Coming Back to Main Menu after Info Window */ DO WHILE BEHInfo = 1 /* -------------------------------------------------------------------- */ /* User Interface */ CALL Req_Begin("Curve to Motion © by Brett Hester") CALL Req_AddControl("Key Frames = Total",'T',"Number of Points =" NumOfPnts) ReqA = Req_AddControl("Starting Frame",'N',0) ReqB = Req_AddControl("Frame Spacing",'N',0) ReqC = Req_AddControl("",'CH', "Information") CALL Req_SetVal(ReqA, ReqStart) CALL Req_SetVal(ReqB, ReqSpace) CALL Req_SetVal(ReqC, 0) OKorCancel = Req_Post() ; IF OKorCancel = 0 THEN CALL Exiting ReqStart = Req_GetVal(ReqA) ReqSpace = Req_GetVal(ReqB) BEHInfo = Req_GetVal(ReqC) CALL Req_End() IF BEHInfo = 1 THEN CALL InformationWindows IF ReqStart < 0 THEN ReqStart = 0 ReqStart = TRUNC(ABS(ReqStart)) IF ReqSpace = 0 THEN ReqSpace = 1 ReqSpace = TRUNC(ABS(ReqSpace)) END CALL FileRequester /* -------------------------------------------------------------------- */ /* Saving Settings */ IF (OPEN(PrefsFile, PrefsFileName, 'W')) THEN DO CALL WRITELN(PrefsFile, MacrosName) CALL WRITELN(PrefsFile, ReqStart) CALL WRITELN(PrefsFile, ReqSpace) CALL WRITELN(PrefsFile, FilePath) CALL CLOSE PrefsFile END /* -------------------------------------------------------------------- */ /* Saving the Motion File */ NumberOfPoints = XFrm_Begin() IF OPEN(MotionFile,FileReq,'W') THEN DO CALL WRITELN(MotionFile,"LWMO") CALL WRITELN(MotionFile,"1") /* magic # */ CALL WRITELN(MotionFile,"9") /* Channels */ IF ReqStart = 0 THEN CALL WRITELN(MotionFile,NumberOfPoints) IF ReqStart ~= 0 THEN CALL WRITELN(MotionFile,NumberOfPoints+1) END ELSE DO CALL Notify(1,"!Sorry!","Unable to save motion file.") CALL Exiting END DO i = 1 to NumberOfPoints PARSE value XFrm_GetPos(i) with X Y Z . IF i = 1 THEN Frame = ReqStart IF i > 1 THEN Frame = Frame + ReqSpace IF i = 1 THEN DO IF ReqStart ~= 0 THEN DO CALL WRITELN(MotionFile,X Y Z "0.0 0.0 0.0 1.0 1.0 1.0") CALL WRITELN(MotionFile,"0 0 0.0 0.0 0.0") END END CALL WRITELN(MotionFile,X Y Z "0.0 0.0 0.0 1.0 1.0 1.0") CALL WRITELN(MotionFile,Frame "0 0.0 0.0 0.0") END CALL XFrm_End CALL CLOSE(MotFile) CALL Notify(1,"!Curve to Motion ©","","@Motion file" FileReq "saved.","") CALL Exiting END /* -------------------------------------------------------------------- */ /* File Requester */ FileRequester: FileReq = GetFileName("-- Save Motion Path --", FilePath) IF FileReq = "(none)" THEN CALL Exiting /* Extracting File Name and Path */ FileReqLength = LENGTH(FileReq) FileDivider = LASTPOS("/",FileReq) IF FileDivider = 0 THEN FileDivider = LASTPOS(":",FileReq) FileNameLength = FileReqLength - FileDivider FilePath = STRIP(LEFT(FileReq, FileDivider),"T","/") FileName = RIGHT(FileReq, FileNameLength) CALL VerifyFilename RETURN /* -------------------------------------------------------------------- */ /* Verifying the file name */ VerifyFilename: IF EXISTS(FilePath) = 0 THEN DO OKorCancel = Notify(3,"!Sorry!",'Directory "'||FilePath||'" not found.',"@Create NEW directory?") IF OKorCancel = 1 THEN CALL MAKEDIR(FilePath) END IF EXISTS(FileReq) = 1 THEN DO DirOrFile = STATEF(FileReq) PARSE var DirOrFile DirOrFile . IF DirOrFile = "DIR" THEN DO CALL Notify(1,"!Sorry!",'@"'||FileReq||'" is not a valid filename.') CALL FileRequester END IF DirOrFile = "FILE" THEN DO OKorCancel = Notify(3,"!Warning!","A file with that name already exists.",'@Overwrite "'||FileReq||'" ?') IF OKorCancel = 0 THEN CALL FileRequester END END RETURN /* -------------------------------------------------------------------- */ /* Ending */ Exiting: IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port") EXIT RETURN /* -------------------------------------------------------------------- */ /* Information Windows */ InformationWindows: OKorCancel = Notify(2, Info1A, Info1B, Info1C, Info1D, Info1E, Info1F, Info1G, Info1H, Info1I, Info1J, Info1K, Info1L, Info1M, Info1N) IF OKorCancel = 1 THEN CALL Notify(1, Info2A, Info2B, Info2C, Info2D, Info2E, Info2F, Info2G, Info2H, Info2I, Info2J, Info2K, Info2L, Info2M, Info2N) RETURN /* -------------------------------------------------------------------- */ /* Error Handling */ SYNTAX: ERROR: ErrCode = RC ErrLine = SIGL ErrInfo = ERRORTEXT(ErrCode) Err1 = "!Sorry!" Err2 = "An Error has been detected" Err3 = "@þ Macro - " Err4 = "@þ Line Number - " Err5 = "@þ Error Code - " Err6 = "@þ Error Description -" Err7 = "@¤ Please Inform - " Err8 = ' "Error Notice" ' Err9 = " 13032 Copenhill Rd." Err10 = " Dallas, TX. 75240 " Call Notify(1,Err1,Err2,Err3,MacrosName,Err4,ErrLine,Err5,ErrCode,Err6,ErrInfo,Err7,Err8,Err9,Err10) /* -------------------------------------------------------------------- */ /* Advanced Error Handling */ CALL SETCLIP("ErrorMacro",MacrosName) CALL SETCLIP("ErrorLine",ErrLine) CALL SETCLIP("ErrorCode",ErrCode) CALL SETCLIP("ErrorDesc",ErrInfo) PARSE SOURCE TempA TempB ErrFile TempC TempD TempE CALL SETCLIP("ErrorFile",ErrFile) /* -------------------------------------------------------------------- */ IF (VT3DLib) THEN CALL REMLIB("LWModelerARexx.port") EXIT