Start a new topic

P3D export code

hello, I'm looking for the paramBlock export number for a p3d export if possible.

Sure, it is:


awesome, thank you!

any guidance on setting the paramblocks for the export options? 

Hmm, It looks like the p3d export was never fully upgraded for scripting. IT was given a GUID, but none of the other elements necessary. In short, with the latest build, there is no way to execute it via script.

ah ok. I appreciate you looking into it 

This is somewhat working, it opens the file in the path provided, inputs the texture path info, and the Mission Editor display name.

the properties tab is checked, none of the inputs change. ie classification, no changes ....

i have to click on ok manually it creates a .p3d file but unable to write the .config file

import os, glob, re, sys, mgapilib, locale, time, timeit, math, operator, decimal,sys

from mgapilib import *

from cmath import *

from math import *

from operator import *

from decimal impord *

mgInit (none,None)

def MakeP3DName (filename):

    dbFileName = mgRec2Filename (db)

    baseName, ext = os.path.splitext (dbFileName)

    p3dFileName = baseName + ".p3d"

    return p3dFileName

def ExportP3D(db):

    paramBlock = mgGetParamBlockDbExporter ("31191D7A-45E8-4E39-A80B-7EF6ADC3BACD")

    mgParamSetBool (paramBlock, "Write VBS2 Properties", MG_TRUE)

    mgParamSetBool (paramBlock, "Write Model Configuration File", MG_TRUE)

    mgParamSetString (paramBlock, "Classification", "house")

    mgParamSetString (paramBlock, "Damage Type", "building")

    mgParamSetString (paramBlock, "Map Icon", "building")

    mgParamSetString (paramBlock, "Placement, "horizontal")

    mgParamSetString (paramBlock, "Shadow Source, "none")

    mgParamSetString (paramBlock, "Texture Path", "S:\user_path")

    mgParamSetString (paramBlock, "Configuration File Path", "S:\user_path")

    mgParamSetString (paramBlock, "Total Mass", "1500")

    mgParamSetString (paramBlock, "Armor", "5")

    mgParamSetString (paramBlock, "Damage Type", "building")

    mgParamSetString (paramBlock, "Mission Editor Display Name", "p3dFileName")

    mgExportDb (db, p3dFileName, "31191D7A-45E8-4E39-A80B-7EF6ADC3BACD", MG_NULL, paramBlock)

status, folder = mgPromptDialogFile ( None, "Select Directory to Process", None)

status, folder = mgPromptDialogFolder (None, "Select Directory to Process", None)

for filename in glob.glob( os.path.join(folder, '*.flt') ):

    db = mgOpenDb (filename)

    print " Processing ", filename

    MakeP3DName (db)

    p3dFileName = MakeP3DName (db)

    ExportP3D (db)

    mgWriteDb (db)

    mgCloseDb (db)

print " Finished Converting Models to P3D"












This is exactly what you would have needed to do if the tool was upgraded to allow scripting. It looks like the paramBlock is not getting used and the tool is not executing without a dialog. One thing you can try if you don't mind the dialog popping up is to set the tool up with the parameters you want to use before running the script. If you run the enter the desired values by hand and OK the tool, the values you used on the last run will be set as default on the next run. This only really helps if you are running it many times with the same parameters though.

yeah, i am trying to convert over 2000 files. clicking ok for each would kill a day or two

Login to post a comment