Scripting – Importing models without popping up PPGs


The ImportModel command pops up a PPG when it imports a model.

Since there is no OM equivalent of ImportModel, if you don’t want the pop-up PPG, you have to either turn off autoinspect in your script, or use the undocumented SIImportModel command. (SOme commands have a “SI” equivalent that doesn’t require any UI interaction or pop up any PPGs.)

If you want more info on SIImportModel (like what are the arguments), run this Python in the script editor:

Application.EditCommand("SIImportMOdel")

Here’s a way to turn off autoinspect using a Python decorator:

def no_autoinspect(func):
	def wrapper(*arg):
		Application.Preferences.SetPreferenceValue("Interaction.autoinspect", False)
		res = func(*arg)
		return res
	return wrapper


@no_autoinspect
def importmodels():
	Application.ImportModel("C:\\Users\\blairs\\Documents\\MyProject\\Models\\dodecahedron.emdl", "", "", "", "", "", "")

importmodels()

More about decorators:
https://xsisupport.wordpress.com/2011/01/27/python-decorators/
http://www.xsiblog.com/archives/357