Maya Mdl Compiler

Stieffers

Newbie
Joined
Apr 5, 2005
Messages
47
Reaction score
0
After becoming extremely frustarted with studiomdl.exe I decided to completely streamline the process from within Maya. So I coded a little MEL application that allows you to run studiomdl.exe without the need for a command line. I thought I'd share it with everyone, since I'm so generous.. :D Note: If your window is scaled oddly, go to your settings and under Interface uncheck "Remember Size and Position". Here's a screeny of what it looks like, obviously with my custom config button set.

MdlCompile_01.gif


If you want to set your own custom config, which is quite easy, scroll down to the bottom of the script. Fill in the parathesized values with your own. Disclude the parenthese from your actual values. Here is the source for the script. Bear in mind that I have only tested and run this on my system under Maya 6.5 Complete. Post any questions or comments here. Anyway, enjoy!

Code:
//---------------------------------------------------------
//  Purpose: Compile mdl's for Half-Life 2 within Maya.
//  Author:  Stieffers - [email protected]
//  Version: v1.0.2	Date: 12-19-05
//-----------------------------------------------------------
	/*if ( `window -ex $myWindow`)
	{
		print ( "// Window deleted.\n" );
		deleteUI $myWindow;
	}*/

	string $myWindow = `window -wh 532 118 -t "Compile Model" -s false`;
	columnLayout;
		rowLayout -columnWidth 1 55 -columnWidth 2 20 -columnWidth 3 275 -columnWidth 4 85  -height 23 -numberOfColumns 5 -width 180;
			text -label "Qc Path: " -align "right";
			textField -w 20 -text "C:" text_Qc_01;
			textField -w 275 -enable false -text "\\Program Files\\Valve\\Steam\\Steamapps\\SourceMods\\" text_Qc_02; // Double slashes nessecary.
			textField -w 85 -text "(Mod)_src" text_Qc_03;
			textField -w 90 -enable false -text "\\model_sources\\" text_Qc_04; // Again, double slashes nessecary.
			setParent ..;
		rowLayout -columnWidth 1 55 -numberOfColumns 2;
			text -label "Qc File: " -align "right";
			textField -w 470 -text "(Filename).qc" text_filename_01;
			setParent ..;
		rowLayout -columnWidth 1 55 -columnWidth 2 20 -columnWidth 3 209 -columnWidth 4 151  -height 23 -numberOfColumns 5 -width 180;
			text -label "StudioMdl: " -align "right";
			textField -w 20 -text "C:" text_studio_01;
			textField -w 209 -enable false -text "\\Program Files\\Valve\\Steam\\Steamapps\\" text_studio_02; // Again, double slashes nessecary.
			textField -w 151 -text "(Email)" text_studio_03;
			textField -w 90 -enable false -text "\\source_sdk\\bin\\" text_studio_04; // Again, double slashes nessecary.
			setParent ..;
		separator -w 532;
		rowLayout -columnWidth 1 100 -numberOfColumns 2;
			button -label "SourceForts" -al "center" -width 100 -c proc_setCustom -aop true;
			button -label "Compile" -al "center" -width 425 -c proc_main;
			setParent ..;
	
	showWindow $myWindow;
	
	// Run studiomdl.exe and compile the model.
	proc proc_main ()
	{
		$pathQc = `textField -q -text text_Qc_01` 
			+ `textField -q -text text_Qc_02` 
			+ `textField -q -text text_Qc_03`
			+ `textField -q -text text_Qc_04`
			+ `textField -q -text text_filename_01`;
		$pathStudio = `textField -q -text text_studio_01`
			+ `textField -q -text text_studio_02`
			+ `textField -q -text text_studio_03`
			+ `textField -q -text text_studio_04`
			+ "studiomdl.exe";		
		
		// Console output.
		print ( "\n-PATHS---------------------------\n" );
		print ( $pathStudio + "\n" );
		print ( $pathQc + "\n\n" );
		
		// Open a command prompt.
		string $run = `system ( "cmd.exe" )`;
		print $run;
		
		// Change the directory and then run studiomdl.exe
		string $run = `system ( "dir \"" + $pathStudio + "\"" )`;
		print $run;		
		string $run = `system ( "studiomdl.exe " + "\"" + $pathQc +"\"" )`;
		print $run;
		
		/* -This is all junk, but I don't feel like retyping it so I'm just ganna keep it incase I need it.
		// Real system run: Run studiomdl.exe and then the qc file path behind it.
		string $run = `system ( "cd C:/Windows/system32/cmd.exe" )`;
		print $run;
		
		string $run = `system ( "dir \"C:/Program Files/valve/steam/steamapps/[email protected]/sourcesdk/bin/\"" )`;
		print $run;
		
		string $run = `system ( "C:/Temp/studiomdl.exe" )`;
		print $run;
		
		string $run = `system ( "" + " " + $pathQc )`;
		print $run;
		
		// Temp system run.
		string $run = `system ( "start \"C:/Program Files/valve/steam/steamapps/[email protected]/sourcesdk/bin/studiomdl.exe -sf_cactus.qc\"" )`;
		print $run;
		*/
	}
	
	// Set some of the text fields with default values that correspond with SourceForts
	proc proc_setCustom ()
	{
		// Console output.
		print ( "\n-CONFIG: (Config Name)-----------------\n" );
		print ( "(Mod Name)_src\n" );
		print ( "(Email Address)\n\n" );
		
		// Update the text field values.
		textField -e -text "(Mod Name.. Again)_src" text_Qc_03;      // Ex: textField -e -text "sourceforts_src" text_Qc_03;
		textField -e -text "(Email Address.. Again)" text_studio_03; // Ex: textField -e -text "[email protected]" text_studio_03;
	}
 
Back
Top