⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 samp3.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
字号:

/*load head file*/
#include<ProToolkit.h>#include<Pro2dEntdef.h>#include<ProANSI.h>#include<ProAnimate.h>#include<ProArray.h>#include<ProAsmcomp.h>#include<ProAsmcomppath.h>#include<ProAssembly.h>#include<ProAxis.h>#include<ProChamfer.h>#include<ProClCmd.h>#include<ProColor.h>#include<ProComm.h>#include<ProConst.h>#include<ProContour.h>#include<ProContourdata.h>#include<ProCore.h>#include<ProCsys.h>#include<ProCsysdata.h>#include<ProCurve.h>#include<ProCurvedata.h>#include<ProDatumdata.h>#include<ProDisplist.h>#include<ProDtmAxis.h>#include<ProDtmCrv.h>#include<ProDtmCrvSketch.h>#include<ProDtmCsys.h>#include<ProDtmPln.h>#include<ProEdge.h>#include<ProEdgedata.h>#include<ProElemId.h>#include<ProElement.h>#include<ProElempath.h>#include<ProExpldstate.h>#include<ProExtdata.h>#include<ProExtobj.h>#include<ProExtobjCB.h>#include<ProExtobjDisp.h>#include<ProExtobjRef.h>#include<ProExtobjSel.h>#include<ProExtrude.h>#include<ProFaminstance.h>#include<ProFamtable.h>#include<ProFeatForm.h>#include<ProFeatType.h>#include<ProFeature.h>#include<ProFixture.h>#include<ProFlatSrf.h>#include<ProForeignCurve.h>#include<ProGeomitem.h>#include<ProGeomitemdata.h>#include<ProGraphic.h>#include<ProGroup.h>#include<ProHardware.h>#include<ProImportfeat.h>#include<ProIntfData.h>#include<ProItemerr.h>#include<ProLayer.h>#include<ProLayerR19.h>#include<ProMaterial.h>#include<ProMdl.h>#include<ProMenu.h>#include<ProMenuBar.h>#include<ProMessage.h>#include<ProMfg.h>#include<ProMfgoper.h>#include<ProModFeat.h>#include<ProMode.h>#include<ProModelitem.h>#include<ProNcseq.h>#include<ProNcseqElem.h>#include<ProNote.h>#include<ProNotify.h>#include<ProObjects.h>#include<ProParameter.h>#include<ProParamval.h>#include<ProPart.h>#include<ProPattern.h>#include<ProPecktable.h>#include<ProPoint.h>#include<ProProcstep.h>#include<ProQuilt.h>#include<ProQuiltdata.h>#include<ProRelSet.h>#include<ProReplace.h>#include<ProRevolve.h>#include<ProRmdt.h>#include<ProRule.h>#include<ProSecConstr.h>#include<ProSecdim.h>#include<ProSecdimType.h>#include<ProSecerror.h>#include<ProSection.h>#include<ProSelection.h>#include<ProSheetmetal.h>#include<ProSimprep.h>#include<ProSimprepdata.h>#include<ProSizeConst.h>#include<ProSolid.h>#include<ProStdSection.h>#include<ProSurface.h>#include<ProSurfacedata.h>#include<ProSweep.h>#include<ProTool.h>#include<ProToolElem.h>#include<ProToolinput.h>#include<ProUICmd.h>#include<ProUtil.h>#include<ProValue.h>#include<ProVerstamp.h>#include<ProView.h>#include<ProWcell.h>#include<ProWchar.h>#include<ProWindows.h>#include<ProWorkspace.h>#include<ProWstring.h>
#include<UtilMatrix.h>
#include<UtilMath.h>

ProFileName   UserMsg;
ProError UserMaterial();

/*--------------------------------------------------------------------*\
Application data
\*--------------------------------------------------------------------*/
#define USER_MAX_BUFFER 20

/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){    return (ACCESS_AVAILABLE);}/*===========================================================================*\  Function : main  Purpose  : Test the ProToolkitMain() function. main is optional function.\*===========================================================================*/main(argc, argv)int  argc;char **argv;{    ProToolkitMain(argc, argv);    return(0);}/*====================================================================*\FUNCTION : user_initialize()PURPOSE  : Pro/DEVELOP standard initialize - define menu button\*====================================================================*/int user_initialize(    int argc,			    char *argv[],    wchar_t errbuf[80]){
    int i, menu_id;
    ProError status;
    uiCmdCmdId	cmd_id;

	/*----------------------------------------------------------------*\
	消息文件
	\*----------------------------------------------------------------*/
	ProStringToWstring (UserMsg, "msg.txt");
	status = ProMessageDisplay (UserMsg, "USER %0s", "Demo of displaying material.\n");

	/*---------------------------------------------------------------------*\
	    Add new button to the menu bar
	\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd("MyCmd",
	(uiCmdCmdActFn)UserMaterial,
	uiProe2ndImmediate, TestAccessDefault,
	PRO_B_TRUE, PRO_B_TRUE, &cmd_id);

    status = ProMenubarmenuPushbuttonAdd(
	"File", "MyCmd", "Display Material", "Display material information",
	"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);

    return (0);

}

/*====================================================================*\
FUNCTION : user_terminate()
PURPOSE  : To handle any termination actions
\*====================================================================*/
void user_terminate()
{

}


/*====================================================================*\
FUNCTION: UserMaterial()
PURPOSE: Read a material from file, create a new material, and
compute mass properties for both materials.
\*====================================================================*/
ProError UserMaterial ()
{
	FILE *fp;
	ProMdl part;
	ProMdlType mdl_type;
	ProCharLine err_str, msg_str;
	ProName w_mdl_name, w_matl_name, w_new_matl_name;
	ProCharName mdl_name, matl_name, str;
	ProCharName new_matl_name = "new_material";
	ProMaterial matl, new_matl;
	ProMaterialdata matl_data, new_matl_data;
	ProMassProperty mass_prop;
	int status;
	ProFileName new_matl_file;


	/*--------------------------------------------------------------------*\
	Check to make sure you have a part.
	\*--------------------------------------------------------------------*/
	status = ProMdlCurrentGet(&part);
	status = ProMdlTypeGet (part, &mdl_type);
	if (mdl_type != PRO_PART)
	{
	ProMessageDisplay (UserMsg, "USER %0s",
	"错误:当前模型不是一个零件.");
	return (-1);
	}

	/*--------------------------------------------------------------------*\
	Get the material name from the user.
	\*--------------------------------------------------------------------*/
	status = ProMessageDisplay (UserMsg, "USER %0s",
	"请输入一个材料名.");
	status = ProMessageStringRead (USER_MAX_BUFFER, w_matl_name); 
	if(status == PRO_TK_MSG_USER_QUIT)
	{
	ProMessageDisplay (UserMsg, "USER %0s",
	"需要材料名称才能继续,失败.");
	return (status);
	}
	ProWstringToString (matl_name, w_matl_name);

	/*--------------------------------------------------------------------*\
	Read the material from the file.
	\*--------------------------------------------------------------------*/
	status = ProMaterialfileRead (part, w_matl_name);
	if (status != PRO_TK_NO_ERROR)
	{
	sprintf (err_str, "打开材料文件 %s%s 失败.",
	matl_name, ".mat");
	ProMessageDisplay (UserMsg, "USER %0s", err_str);
	return (status);
	}

	/*--------------------------------------------------------------------*\
	Get the current material properties. (The following function
	calls are easier than reading the text of the material file.)
	\*--------------------------------------------------------------------*/
	status = ProMaterialCurrentGet (part, &matl);
	status = ProMaterialDataGet (&matl, &matl_data);

	/*--------------------------------------------------------------------*\
	Compute the mass properties.
	\*--------------------------------------------------------------------*/
	status = ProSolidMassPropertyGet (part, NULL, &mass_prop);
	sprintf (msg_str, "使用材料 %s 的零件质量 : %6.2e\n", matl_name,
	mass_prop.mass);
	ProMessageDisplay (UserMsg, "USER %0s", msg_str);

	/*--------------------------------------------------------------------*\
	Create a new material that is identical to matl_name, but with a
	slightly higher density. Set to be the current material.
	\*--------------------------------------------------------------------*/
	ProStringToWstring (w_new_matl_name, new_matl_name);
	status = ProMaterialCreate (part, w_new_matl_name, &new_matl_data,
	&new_matl);
	new_matl_data = matl_data;
	new_matl_data.mass_density = matl_data.mass_density * 1.10;
	status = ProMaterialDataSet (&new_matl, &new_matl_data);
	status = ProMaterialCurrentSet (&new_matl);
	sprintf (msg_str, "当前材料设置为 %s.", new_matl_name);
	ProMessageDisplay (UserMsg, "USER %0s", msg_str);

	/*--------------------------------------------------------------------*\
	Write the new material to a file.
	\*--------------------------------------------------------------------*/
	strcat (new_matl_name, ".mat");
	ProStringToWstring (new_matl_file, new_matl_name);
	status = ProMaterialfileWrite (&new_matl, new_matl_file);
	sprintf (msg_str, "新材料已存入文件 %s", new_matl_name);
	ProMessageDisplay (UserMsg, "USER %0s", msg_str);

	/*--------------------------------------------------------------------*\
	Compute the mass properties with the new material.
	\*--------------------------------------------------------------------*/
	status = ProSolidMassPropertyGet (part, NULL, &mass_prop);
	sprintf (msg_str, "使用材料 %s 的零件质量 : %6.2e\n", new_matl_name,
	mass_prop.mass);
	ProMessageDisplay (UserMsg, "USER %0s", msg_str);
	return (0);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -