Esempio n. 1
0
BOOL CSDMdlAttrMatCheck::DoAction(void *pData, const CheckData &checkData) 
{
	ProError status;
	ProSolid pMdl = (ProSolid)pData;
	CString strMatName = checkData.checkRule.arrRuleContent[0];
	
	if (strMatName.CompareNoCase(L"null") == 0)
	{
		ProMaterial MdlMat;
		status = ProMaterialCurrentGet((ProSolid)pMdl,&MdlMat);
		status = ProMaterialDelete(&MdlMat);

		return TRUE;
	}

	CString strMatResPath;

	GetMainModulePath((HMODULE)theApp.m_hInstance, strMatResPath);

	strMatResPath = strMatResPath + L"Resource\\MaterialLib\\";

	ProPath mtl_file_path;
	ProPath current_dir;
    ProName mtl_name;

	wcsncpy_s(mtl_name, PRO_NAME_SIZE, (LPCTSTR)strMatName, _TRUNCATE);

	wcsncpy_s(mtl_file_path, PRO_PATH_SIZE, (LPCTSTR)strMatResPath, _TRUNCATE);

	ProDirectoryCurrentGet (current_dir);

	ProDirectoryChange (mtl_file_path);

	status = ProMaterialfileRead (pMdl, mtl_name);

	ProDirectoryChange (current_dir);

	if (status == PRO_TK_E_NOT_FOUND || status == PRO_TK_GENERAL_ERROR)
	{
		return FALSE;
	}

	ProMaterial Mat;
	Mat.part = pMdl;
	ProWstringCopy (mtl_name, Mat.matl_name, PRO_VALUE_UNUSED);

	status = ProMaterialCurrentSet (&Mat);

	return TRUE;
}
	void SetMaterial_to_CurrentMaterial( ProSolid in_part, const std::string &in_MaterialName ) 
													throw (isis::application_exception)
	{
		// Check if material exists
		if ( !MaterialExists(in_part, in_MaterialName) )
		{
			std::string TempError = "Function SetMaterial_to_CurrentMaterial(...) was passed a material name that does not exist in the model (i.e. argument in_part).  in_MaterialName: " +
				in_MaterialName;
			throw isis::application_exception(TempError.c_str());
		}

		ProMaterial material;
		ProName  materialName_wchar;
		ProStringToWstring(material.matl_name, (char *)in_MaterialName.c_str() );
		material.part = in_part;

		// Set material as the current material
		ProMaterialCurrentSet(&material);

	}