home *** CD-ROM | disk | FTP | other *** search
Wrap
'This script makes a movie of any object created in CorelCAD using Corel PHOTO-PAINT ' '************************************************************************************************ '********************* MOVIE SCRIPT ********************************************** '************************************************************************************************ '************************************************************************************************ 'April 6, 1996 ' ' This script creates a movie (AVI file) out of any object created in CorelCAD. The object is ' rotated around X degrees in Y steps, at each step, the object is rendered, then exported as ' a bitmap (BMP file). These BMP files combine to make the movie in Corel PhotoPaint. ' ' The best way to run the script is to use the static view. You must set a rotation point for the ' object to be rotated about. The easiest way to get a well centered movie is to define the center of ' gravity of your object (found under engineering properties) as a rotation point. Use Zoom commands to ' get the best preview (what your movie will look like). ' ' The user defines: ' - File name of movie file(*.AVI) to be created ' - Axis to revolve object around (X,Y,or Z) ' - Number of degrees to rotate around ' - Whether all objects or only selected objects are rotated ' - Coordinate to revolve object around ' (center of gravity would work, use Tools:Measure:Engineering Properties) ' - Number of steps (# of bitmaps to be exported from a 360 Degree rotation) ' - Type of rendering desired ' - Color of object to be rendered ' 'Written by Dave Climie (U of W), ⌐ 1995-96 Corel Corporation. All rights reserved. 'Modified by Dave Mckeen, ⌐ 1995-96 Corel Corporation. All rights reserved. '************************************************************************************************ '************************************************************************************************ '************************ DECLARATIONS ********************************************* '************************************************************************************************ '************************************************************************************************ DECLARE SUB MoviePreview(DontZoom%,NumSteps%,x#,y#,z#,XorYorZ%,Ang#,RotatePart%) DECLARE SUB DoChangeColor(RotatePart%) 'Changes color of object if user wants. DIM Angle$ 'user enters an angle DIM Ang# 'converted from a string to a number DIM i% DIM LastSlashPos% 'stores the position of the last backslash file name string DIM PosPeriod% DIM MovieName$ DIM PathBitMap$ 'Stores the pathname to which the bitmap files will be stored DIM NumSteps% 'Defines the # of bitmaps to be saved from a 360 Degree rotation DIM AngleEachStep# 'Defines angle drawing will rotate each time DIM StepArray$(8) 'Gives the user a choice for # of steps DIM StepNum% 'Defines the # in array , selection for # of steps (default 20) DIM ShadeNum% DIM ShadeType$(8) DIM ErrorVar% 'Used to make sure user enters a correct path name DIM XCoord$,YCoord$,ZCoord$ 'Variables used to store point of rotation (string) DIM X#,Y#,Z# 'Variables used to store point of rotation (value) DIM XorYorZ% 'Stores 1 if user wants rotate around X-axis, etc... DIM DontZoom% 'false if the user wants to use zoom to fit for the view to render 'If true, view zoom is not changed, but user must enter coords for ' point of rotation. Dim RotatePart% ' false if the user wants to rotate all objects, true for selected only Dim NumOb& 'TLK IS THE ONE '************************************************************************************************ '************************************************************************************************ REM Warns the user he/she needs photoPaint BEGIN DIALOG TLK 302, 103, "Movie Maker" TEXT 8, 6, 292, 18, "This script uses CorelCAD and Corel PHOTO-PAINT 6 to generate a movie file of a rotating model. Corel PHOTO-PAINT 6 must be installed on your system for the script to function." TEXT 8, 32, 292, 16, "This script will generate a large movie file (*.AVI) and a single bitmap file (*.BMP), which will both be placed in a user-defined directory." TEXT 9, 53, 157, 8, "Click NEXT to proceed or CANCEL to exit the Script." PUSHBUTTON 207, 83, 44, 16, "Next >>>" CANCELBUTTON 251, 83, 44, 16 TEXT 8, 65, 263, 11, "Please allow about 30 minutes for the completion of a movie." END DIALOG Return = DIALOG(TLK) 'Runs the dialog box' If Return = 2 then STOP ' If the user presses ESC, the script gets cancelled ShadeType(1) = "Hidden Line View" ShadeType(2) = "Flat Shading" ShadeType(3) = "Gouraud Shading" ShadeType(4) = "Phong Shading" ShadeType(5) = "Preview" ShadeType(6) = "Full Render" ShadeType(7) = "Ray Traced Preview" ShadeType(8) = "Ray Traced Render" ShadeNum = 3 StepArray(1) = 5 StepArray(2) = 10 StepArray(3) = 15 StepArray(4) = 20 StepArray(5) = 30 StepArray(6) = 40 StepArray(7) = 50 StepArray(8) = 60 StepNum = 4 DontZoom = 0 XCoord$="0" YCoord$="0" ZCoord$="0" XorYorZ = 2 Angle = "360" MovieName = "C:\" RotatePart = 0 START: DONECOLORCHANGE: BEGIN DIALOG StartDia 346, 155, "Movie Information" TEXTBOX 64, 6, 113, 13, MovieName$ TEXTBOX 80, 28, 26, 14, Angle$ OPTIONGROUP RotatePart% OPTIONBUTTON 20, 43, 70, 9, "&Rotate all objects" OPTIONBUTTON 20, 56, 95, 8, "&Rotate selected objects" OPTIONGROUP DontZoom% OPTIONBUTTON 13, 84, 158, 8, "&Static view (recommended) - Set rotation point" OPTIONBUTTON 13, 112, 132, 11, "&Use fit to view for each frame" TEXTBOX 33, 97, 22, 13, XCoord$ TEXTBOX 73, 97, 22, 13, YCoord$ TEXTBOX 111, 97, 22, 13, ZCoord$ OPTIONGROUP XorYorZ% OPTIONBUTTON 132, 34, 40, 9, "&X-Axis" OPTIONBUTTON 132, 44, 40, 10, "&Y-Axis" OPTIONBUTTON 132, 56, 40, 9, "&Z-Axis" LISTBOX 188, 14, 58, 74, StepArray$, StepNum% LISTBOX 262, 14, 74, 74, ShadeType$, ShadeNum% PUSHBUTTON 191, 108, 48, 14, "A&ll" PUSHBUTTON 239, 108, 48, 14, "S&elected" PUSHBUTTON 287, 108, 48, 14, "&Out" PUSHBUTTON 139, 135, 48, 13, "&Change Color" PUSHBUTTON 190, 135, 48, 13, "&Preview" OKBUTTON 242, 135, 48, 13 CANCELBUTTON 293, 135, 48, 13 TEXT 6, 8, 56, 8, "&File name (*.AVI): " TEXT 24, 99, 8, 8, "X:" TEXT 63, 99, 8, 8, "Y:" TEXT 102, 99, 6, 8, "Z:" GROUPBOX 124, 20, 52, 51, "Rotation axis" GROUPBOX 5, 73, 172, 56, "Rotation Origin" TEXT 16, 31, 60, 8, "&Angle of rotation:" GROUPBOX 6, 20, 114, 51, "Rotation" GROUPBOX 182, 3, 70, 91, "Number of frames" GROUPBOX 257, 3, 84, 91, "Rendering type" GROUPBOX 182, 97, 159, 32, "Zoom" END DIALOG return = DIALOG(StartDia) 'Runs the dialog box If return = 2 then stop 'If the user presses ESC, cancels the script If return = 6 then DoChangeColor (RotatePart) Goto DoneColorChange ENDIF X=VAL(XCoord) Y=VAL(YCoord) Z=VAL(ZCoord) If (VAL(Angle) = 0) then ErrorVar = True else Ang = Val(Angle) endif NumSteps = VAL(StepArray(StepNum)) AngleEachStep = Ang/NumSteps WithObject "CorelCAD.Automation.1" If return = 3 then .ZoomToAll goto start endif If return = 4 then .ZoomToSelected goto start endif If return = 5 then .ZoomOut goto start endif END Withobject If return = 7 then MoviePreview DontZoom,NumSteps,X,Y,Z,XorYorZ,Ang,RotatePart Goto Start ENDIF ErrorVar = False MovieName = LTRIM(MovieName) MovieName = RTRIM(MovieName) MovieName = UCASE(MovieName) If ((ASC(LEFT(MovieName,1)) < ASC("A")) OR (ASC(LEFT(MovieName,1))) > ASC("Z")) then ErrorVar = True If NOT(ASC(MID(MovieName,2,1))=ASC(":")) then ErrorVar = True If NOT(ASC(MID(MovieName,3,1))=ASC("\")) then ErrorVar = True If (ASC(Right(MovieName,1)) = ASC("\")) then ErrorVar = True If NOT((Right(MovieName,4))=".AVI") then MovieName=MovieName & ".AVI" PosPeriod = 0 If ErrorVar=False then For i%=1 to Len(MovieName) If Mid(MovieName,i,1)="\" then LastSlashPos=i If Mid(MovieName,i,1)="." then if posPeriod <> 0 then ErrorVar=true 'Error if we have more than one period else PosPeriod=i 'stores the position of the period in PosPeriod endif endif Next i PathBitMap = LEFT(MovieName,LastSlashPos) ENDIF If (PosPeriod <>0) and UCASE(right(MovieName,4)) <> ".AVI" then ErrorVar = True REM ErrorVar = FALSE '*** TAKE OUT REM IF YOU WANT TO OVERIDE ERROR TRAP *** If ErrorVar = true then BEGIN DIALOG ErrorVarDia 296, 94, "Error" TEXT 22, 8, 188, 19, "Corel Script has detected that your pathname entry is invalid. Please verify, and change accordingly." GROUPBOX 22, 33, 143, 43, "Examples " OKBUTTON 184, 52, 40, 15 CANCELBUTTON 226, 52, 40, 15 TEXT 32, 46, 48, 8, "c:\movie.avi" TEXT 97, 46, 48, 8, "D:\Widget" TEXT 34, 61, 112, 8, "c:\Corel\CAD\Rotating Coil.AVI" END DIALOG ret = DIALOG(ErrorVarDia) If ret = 2 then STOP MovieName = "C:\" Angle = "360" Goto Start ENDIF WITHOBJECT PAINT .setvisible -1 .FileNew 1000,700,1,85,85,0,-1,1,0,0,0,0,255,255,255,0 END WITHOBJECT WITHOBJECT "CorelCAD.Automation.1" If RotatePart = 1 then Total& = .gettotalnumberobjects() .Group .applyName "Rotating These" NumOb = 2 NumOb = .CountObject ("Rotating These") If (NumOb = 0) then MESSAGE "You have no objects selected. Objects must be selected for partial rotations. Try again." stop endif endif For i%=1 to NumSteps .setvisible -1 If ShadeNum = 1 then .HideEntireView TRUE,False,False,False Else .ShadeEntireView TRUE, FALSE, ShadeNum-2, FALSE Endif .FileExport PathBitMap & "BitMapForMovie.BMP",769,1000,700, 85, 85, 4 If RotatePart = 0 then .SelectAll else For j%=1 to Total .selectnext CurrentName$ = .GetName() If CurrentName = "Rotating These" then goto blah next j blah: .selectnext .selectprevious endif Select Case XorYorZ Case 0 .RotateXaxis 0,AngleEachStep,X,Y,Z Case 1 .RotateYaxis 0,AngleEachStep,X,Y,Z Case 2 .RotateZaxis 0,AngleEachStep,X,Y,Z End Select If DontZoom = 1 then .ZoomToAll END WITHOBJECT WITHOBJECT PAINT .setvisible -1 .MovieInsertFile PathBitMap & "BitMapForMovie.BMP",0,0,0,0,0,i,0 END WITHOBJECT Next i WITHOBJECT "CorelCAD.Automation.1" If RotatePart = 0 then .SelectAll else For j%=1 to Total .selectnext CurrentName$ = .GetName() If CurrentName = "Rotating These" then goto blah2 next j blah2: .selectnext .selectprevious .ungroup endif Select Case XorYorZ Case 0 .RotateXaxis 0,360-Ang,X,Y,Z Case 1 .RotateYaxis 0,360-Ang,X,Y,Z Case 2 .RotateZaxis 0,360-Ang,X,Y,Z End Select .wireframe END WITHOBJECT WITHOBJECT PAINT .MovieDeleteFrame 1,1 For j%=1 to NumSteps .MovieGotoFrame j .ImageConvert 4, 2, 100, 0, 0, 0, 0 Next j .MovieRewind .fileSave MovieName,1536,0 'This has no compression, compression didnt seem to change file size END WITHOBJECT ' ( i tried all settings) '************************************************************************************************ '************************************************************************************************ '************************************************************************************************ SUB MoviePreview(DontZoom%,NumSteps%,X#,Y#,Z#,XorYorZ%,Ang#,RotatePart%) DIM AngleEach# DIM NumObj& AngleEach = Ang/NumSteps WithObject "CorelCAD.Automation.1" If RotatePart = 0 then .SelectAll else .group .ApplyName "Rotating These" NumObj = .countObject ("Rotating These") If NumObj = 0 then MESSAGE "You have no objects selected. Objects must be selected for partial rotations. Try again." stop endif endif For i%=1 to NumSteps Select Case XorYorZ Case 0 .RotateXaxis 0,AngleEach,X,Y,Z Case 1 .RotateYaxis 0,AngleEach,X,Y,Z Case 2 .RotateZaxis 0,AngleEach,X,Y,Z End Select If DontZoom = 1 then .zoomToAll Next i Select Case XorYorZ Case 0 .RotateXaxis 0,360-Ang,X,Y,Z Case 1 .RotateYaxis 0,360-Ang,X,Y,Z Case 2 .RotateZaxis 0,360-Ang,X,Y,Z End Select If RotatePart = 0 then .UnGroup ' *********************MARKER************************************************ If RotatePart = 1 then .UnGroup End WithObject END SUB '************************************************************************************************ '************************************************************************************************ '************************************************************************************************ SUB DoChangeColor(RotatePart%) DIM ColorChoice% DIM Color$(7) DIM Red%,Green%,Blue% ColorChoice = 1 Color(1)="Red" Color(2)="Orange" Color(3)="Yellow" Color(4)="Green" Color(5)="Blue" Color(6)="Indigo" Color(7) ="Violet" BEGIN DIALOG ColorDlg 97, 115, "CHANGE COLOR" GROUPBOX 4, 6, 83, 85, "Colors Available" LISTBOX 15, 20, 62, 67, Color$, ColorChoice% OKBUTTON 14, 96, 34, 14 CANCELBUTTON 49, 96, 34, 14 END DIALOG RET% = DIALOG(ColorDlg) If RET = 2 then goto Done: WithObject "CorelCAD.Automation.1" If RotatePart = 0 then .SelectAll Select Case ColorChoice Case 1 .ChangeColor 255, 0, 51 Case 2 .ChangeColor 255, 153, 0 Case 3 .ChangeColor 255, 255, 0 Case 4 .ChangeColor 51, 255, 0 Case 5 .ChangeColor 0, 0, 255 Case 6 .ChangeColor 0, 255, 255 Case 7 .ChangeColor 51, 0, 102 END SELECT End WithObject DONE: END SUB '**************************************************************************************************************** '**************************************************************************************************************** '**************************************************************************************************************** '****************************************************************************************************************