automating import/save as

Posted By: Carlos3DGS

automating import/save as - 11/28/12 15:58

Is there any way to create some sort of batch process for med?
I have around 500 *.obj files and selecting "import wavefront obj", then "save as" 500 times is a pain in the arse...

If it is not possible in med, do you guys know any free program that can do this?
I have tried a few programs that supposedly can do this but with no sucess. I tried "ModelConvertterX" but apparently it needs some flight simulator x files that are not free to download. I also tried "3D Object Converter" but the mdl batch feature is disabled for non registered users, so that program is not an option either.

Anyone know how to automate the process through MED or can point me to any free program capable of obj to mdl batch conversion?
Posted By: lemming

Re: automating import/save as - 11/28/12 22:52

I don't know a software to do this, but what about using Autohotkey and sending keystrokes to MED?
Posted By: Carlos3DGS

Re: automating import/save as - 11/29/12 14:16

thanks for that! Great idea!!!
I have downloaded and installed it, but I have no experience with this program.

I have created what the program would be in lite-c
Code:
void main()
{
	STRING* model_obj = "";
	STRING* model_mdl = "";
	int count;

	for(count=1;count<=482;count++)
	{
	   //BUILD IMPORT AND EXPORT FILENAME STRINGS
		str_cpy(model_obj,"EarthHEX");
		if(count<10)
		{
			str_cat(model_obj,"00");
		}
		else if(count<100)
		{
			str_cat(model_obj,"0");
		}
		str_cat(model_obj,str_for_int(NULL,count));
		if(count==1||count==17||count==33||count==49||count==65||count==81||count==97||count==113||count==129||count==145||count==161||count==177)
		{
			str_cat(model_obj,"p");
		}
		str_cpy(model_mdl,model_obj);
		str_cat(model_obj,".obj");
		str_cat(model_mdl,".mdl");
		
		//IMPORT OBJ
		keys_import_obj();
		insert model_obj text; //<------------
		keys_import_finalize();
		
		//EXPORT MDL
		keys_export_mdl();
		insert model_mdl text; //<------------
		keys_export_finalize();
	}
}



any help on the lines "insert model_obj text;" and "insert model_mdl text;" would be great.


also the keystroke functions I am not sure how to make it in this program, but they would look something like this:
Click to reveal..
void keys_import_obj()
{
ALT
F
I
M
M
M
M
M
M
ENTER
}

void keys_import_finalize()
{
ENTER
ENTER
}

void keys_export_mdl()
{
ALT
F
A
}

void keys_export_finalize()
{
ENTER
}


any help with this would be great
Posted By: Carlos3DGS

Re: automating import/save as - 11/29/12 17:07

I finally understood all the syntax and how the program works...
The above Lite-c example is finally done and working in AutoHotkey Script language:
Code:
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#Warn  ; Recommended for catching common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

;Comment initialize variables
count := 1
model :=

;Comment wait wile selecting MED window
Sleep 10000 ;Comment 10 seconds


;Comment the start of the loop
Loop
{


;Comment open "import obj" menu by pressing "ALT f i m m m m m m ENTER"
Send {Alt}fimmmmmm{enter}
Sleep, 300  ;Comment 1/4th of a second


;Comment insert obj file name
Send EarthHEX
if count < 10
Send 0
if count < 100
Send 0
model = %count%
Loop, parse, model
{
    Send %A_LoopField%
}
if (count=1||count=17||count=33||count=49||count=65||count=81||count=97||count=113||count=129||count=145||count=161||count=177)
Send p
SendRaw .
Send obj


;Comment finalize import pressing "ENTER" twice
Send {enter}
Sleep, 250  ;Comment 1/4th of a second
Send {enter}
Sleep, 250  ;Comment 1/4th of a second


;Comment open "save as mdl" menu by pressing "ALT f a"
Send {Alt}fa
Sleep, 250  ;Comment 1/4th of a second


;Comment insert mdl file name
Send EarthHEX
if count < 10
Send 0
if count < 100
Send 0
model = %count%
Loop, parse, model
{
    Send %A_LoopField%
}
if (count=1||count=17||count=33||count=49||count=65||count=81||count=97||count=113||count=129||count=145||count=161||count=177)
Send p
SendRaw .
Send mdl


;Comment finalize "save as mdl" by pressing "ENTER"
Send {enter}
Sleep, 250  ;Comment 1/4th of a second


;Comment loop back to the start of loop or stop loop
count++

if count > 482
break
}


Thankyou very much for showing me this program! I can now start automating anything I want in any program!
And using alt+tab commands... tedious workflow between different programs can be automated too!
(for example load a .wing file in wings3d, export as .obj from wings3d, alt+tab to med, import .obj in med, save as .mdl from med, alt+tab back to wings3d, repeat a million times withought ever having to browse through menus, files, press a key or click the mouse...)
I love it!!! Thanks a million times!!!
© 2024 lite-C Forums