Parameter Get3DCoatParam( const CString& in_strName )
{
	CustomProperty pset = Get3DCoatProp();
	if (!pset.IsValid()) return CRef();
	
	Parameter param = pset.GetParameters().GetItem(in_strName);
	
	return param;
}
//*****************************************************************************
CustomProperty Get3DCoatProp()
{	
	//Application app;
	Model root = app.GetActiveSceneRoot();
	CustomProperty prop = root.GetProperties().GetItem(L"AppLink_3DCoat");
	if (!prop.IsValid())
	{
		prop = root.AddProperty( L"AppLink_3DCoat" );
	}
	return prop;
}
// Callback for the siOnActivateEvent event.
SICALLBACK siOnActivateEvent_OnEvent( CRef& in_ctxt )
{
	Context ctxt( in_ctxt );
	//Application().LogMessage(L"siOnActivateEvent_OnEvent called",siVerboseMsg);
	//Application().LogMessage(L"State: " + CString(ctxt.GetAttribute(L"State")),siVerboseMsg);

	bool bState = ctxt.GetAttribute(L"State");
	if(bState)
	{
		CustomProperty prop = app.GetActiveSceneRoot().GetProperties().GetItem(L"AppLink_3DCoat");
		if (prop.IsValid())
		{
			if(prop.GetParameter("bEvent").GetValue())
			{
				CString s_CoatLocation = prop.GetParameter(L"coatLocation").GetValue();
				CString exportPath = CUtils::BuildPath(s_CoatLocation, L"export.txt");
				CString objPath;

				std::ifstream fileref(exportPath.GetAsciiString());
				bool bfile = false;
				if(fileref.good())
				{
					std::string row;
					std::getline(fileref, row);
					objPath = row.c_str();
					bfile = true;
				}
				fileref.close();

				if(bfile)
				{				
					UIToolkit uitool = Application().GetUIToolkit();
					LONG out;
					uitool.MsgBox(L"Import file?", siMsgOkCancel|siMsgInformation|MB_APPLMODAL, L"", (LONG) out);
					if(out == siMsgOk)
					{
						app.LogMessage(L"Start Import!");
						CValueArray args(2);
						args[0] = objPath;
						args[1] = prop.GetParameterValue( L"bReplace" );
						CValue noret;
						app.ExecuteCommand( L"Coat3DImport", args, noret ) ;
					}
				}				
			}
		}
	}

// 	Return value is ignored as this event can not be aborted.
	return CStatus::OK;
}