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

📄 samp14.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>

#define OK 1
#define CANCEL 0
ProFileName   UserMsg;
void UsrModAngle();
void UsrOKAction(char *dialog,char *component,ProAppData data);
void UsrCancelAction(char *dialog,char *component,ProAppData data);
void UsrSliderAction(char *dialog,char *component,ProAppData data);
void UsrInputpanelAction(char *dialog,char *component,ProAppData data);
int UsrAngleGet(char *text,	int *angle);
ProError UserFullRegenerate ();
ProError UserSolidFullRegenerate (ProSolid solid, ProBoolean allow_fix);

/*--------------------------------------------------------------------*\Application global data\*--------------------------------------------------------------------*/static uiCmdAccessState TestAccessDefault(uiCmdAccessMode access_mode){    return (ACCESS_AVAILABLE);}/*===========================================================================*\Function : mainPurpose  : 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 UsrExample();
    int i, menu_id;
    ProError status;
    uiCmdCmdId	cmd_id;
	
	/*----------------------------------------------------------------*\
	消息文件
	\*----------------------------------------------------------------*/
	ProStringToWstring (UserMsg, "msg.txt");
	status = ProMessageDisplay (UserMsg, "USER %0s",	"Demo of using list dialog.\n");
	
	/*---------------------------------------------------------------------*\
    Add new button to the menu bar
	\*---------------------------------------------------------------------*/
    status = ProCmdActionAdd("MyCmd",
		(uiCmdCmdActFn)UsrModAngle,
		uiProe2ndImmediate, TestAccessDefault,
		PRO_B_TRUE, PRO_B_TRUE, &cmd_id);
	
    status = ProMenubarmenuPushbuttonAdd(
		"File", "MyCmd", "Modify Angle", "Modify Angle Dimension",
		"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);
	
    return (0);
	
}

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

/*====================================================================*\
FUNCTION : UsrModAngle() PURPOSE : Command to modify an angular
dimension using a slider
\*====================================================================*/
void UsrModAngle()
{
	ProError status;
	ProSelection *sel;
	int n_sel, angle;
	double value;
	ProName wname;
	ProCharName name;
	ProCharLine prompt;
	ProDimension dimension;
	ProDimensiontype dtype;
	while(1)
	{
	/*--------------------------------------------------------------------*\
	Select a feature or a dimension
		\*--------------------------------------------------------------------*/
		status = ProSelect("feature,dimension",1,
			NULL,NULL,NULL,NULL,&sel,&n_sel);
		if(status != PRO_TK_NO_ERROR || n_sel < 1)
			break; 
		
		status = ProSelectionModelitemGet(sel[0], &dimension);
		/*--------------------------------------------------------------------*\
		If it's a feature, display the dimensions
		\*--------------------------------------------------------------------*/
		if(dimension.type == PRO_FEATURE)
			status = ProFeatureParamsDisplay(sel[0], PRO_DIM_PARAM);
		else
		{
		/*--------------------------------------------------------------------*\
		Check that it's angular
			\*--------------------------------------------------------------------*/
			ProDimensionTypeGet(&dimension, &dtype);
			if(dtype != PRODIMTYPE_ANGLE)
				continue;
				/*--------------------------------------------------------------------*\
				Get the current value
			\*--------------------------------------------------------------------*/
			status = ProDimensionValueGet(&dimension, &value);
			angle = (int)value;
			/*--------------------------------------------------------------------*\
			Get the name and form a prompt string
			\*--------------------------------------------------------------------*/
			status = ProDimensionSymbolGet(&dimension, wname);
			ProWstringToString(name, wname);
			sprintf(prompt,"请输入%s的新值",name);
			/*--------------------------------------------------------------------*\
			Input the new angle using a dialog box with a slider
			\*--------------------------------------------------------------------*/
			if(!UsrAngleGet(prompt, &angle))
				continue;
				/*--------------------------------------------------------------------*\
				Set the new value and update the dim display
			\*--------------------------------------------------------------------*/
			value = (double)angle;
			if(ProDimensionValueSet(&dimension, value) != PRO_TK_NO_ERROR)
			{
				status = ProMessageDisplay(UserMsg, "USER %0s","USER Could not modify dimension");
				continue;
			}
			status = ProDimensionDisplayUpdate(&dimension);
		}
	}
	UserFullRegenerate();
}


/*====================================================================*\
FUNCTION : UsrOKAction() PURPOSE : Action function for the OK button
\*====================================================================*/
void UsrOKAction(
				 char *dialog,
				 char *component,
				 ProAppData data)
{
	int status;
	status = ProUIDialogExit(dialog, OK);
}
/*====================================================================*\
FUNCTION : UsrCancelAction() PURPOSE : Action function for the CANCEL
button
\*====================================================================*/
void UsrCancelAction(
					 char *dialog,
					 char *component,
					 ProAppData data)
{
	int status;
	status = ProUIDialogExit(dialog, CANCEL);
}
/*====================================================================*\
FUNCTION : UsrSliderAction() PURPOSE : Callback for movement of the
slider
\*====================================================================*/
void UsrSliderAction(
					 char *dialog,
					 char *component,
					 ProAppData data)
{
	ProName wstr;
	ProCharName str;
	int status;
	int *angle = (int*)data;
	/*--------------------------------------------------------------------*\
	Get the new value
	\*--------------------------------------------------------------------*/
	status = ProUISliderIntegerGet(dialog,component,angle);
	/*--------------------------------------------------------------------*\
	Set the input panel to the same value
	\*--------------------------------------------------------------------*/
	sprintf(str,"%d",*angle);
	ProStringToWstring(wstr, str);
	status = ProUIInputpanelValueSet(dialog,"InputPanel",wstr);
}
/*====================================================================*\
FUNCTION : UsrInputpanelAction() PURPOSE : Callback for input to the
input panel
\*====================================================================*/
void UsrInputpanelAction(
						 char *dialog,
						 char *component,
						 ProAppData data)
{
	wchar_t *wstr;
	ProCharName str;
	int status;
	int *angle = (int*)data;
	/*--------------------------------------------------------------------*\
	Get the current value as an integer
	\*--------------------------------------------------------------------*/
	status = ProUIInputpanelValueGet(dialog,component,&wstr);
	ProWstringToString(str, wstr);
	*angle = atoi(str);
	/*--------------------------------------------------------------------*\
	Set the slider to the same value
	\*--------------------------------------------------------------------*/
	status = ProUISliderIntegerSet(dialog,"Slider",*angle);
}


/*====================================================================*\
FUNCTION : UsrAngleGet() PURPOSE : Input an angle using a dialog with a
slider
\*====================================================================*/
int UsrAngleGet(char *text,
				/* Text of the prompt displayed on the dialog */
				int *angle)
{
	int status;
	int error;
	ProName wstr;
	ProCharName str;
	ProLine wline;
	/*--------------------------------------------------------------------*\
	Load the dialog from the resource file
	\*--------------------------------------------------------------------*/
	status=ProUIDialogCreate("angle","dlg13");
	/*--------------------------------------------------------------------*\
	Set the prompt as the text of the Label component
	\*--------------------------------------------------------------------*/
	ProStringToWstring(wline,text);
	status = ProUILabelTextSet("angle","Prompt",wline);
	/*--------------------------------------------------------------------*\
	Set the OK and Cancel callbacks
	\*--------------------------------------------------------------------*/
	status = ProUIPushbuttonActivateActionSet("angle","OK",UsrOKAction,NULL);
	status = ProUIPushbuttonActivateActionSet("angle","Cancel",UsrCancelAction,NULL);
	/*--------------------------------------------------------------------*\
	Set the slider action and initial value
	\*--------------------------------------------------------------------*/
	status = ProUISliderUpdateActionSet("angle","Slider",UsrSliderAction, angle);
	status = ProUISliderIntegerSet("angle","Slider",*angle);
	/*--------------------------------------------------------------------*\
	Set the input panel action and initial value
	\*--------------------------------------------------------------------*/
	status = ProUIInputpanelActivateActionSet("angle","InputPanel",
		UsrInputpanelAction,angle);
	sprintf(str,"%d",*angle);
	ProStringToWstring(wstr, str);
	status = ProUIInputpanelValueSet("angle","InputPanel",wstr);
	/*--------------------------------------------------------------------*\
	Display and activate the dialog
	\*--------------------------------------------------------------------*/
	status = ProUIDialogActivate("angle",&error);
	/*--------------------------------------------------------------------*\
	Dispose of the dialog
	\*--------------------------------------------------------------------*/
	status = ProUIDialogDestroy("angle");
	return(error==OK?1:0);
}


/*====================================================================*\
FUNCTION: UserFullRegenerate()
PURPOSE:  Fully regenerates the current model - allow fix model on failure
\*====================================================================*/
ProError UserFullRegenerate ()
{
	ProError status;
	ProMdl model;
	ProMdlType type;
	
	status = ProMdlCurrentGet (&model);
	if (status != PRO_TK_NO_ERROR)
		return PRO_TK_GENERAL_ERROR;
	
	status = ProMdlTypeGet (model, &type);
	
	if (type != PRO_MDL_PART && type != PRO_MDL_ASSEMBLY)
		return PRO_TK_GENERAL_ERROR;
	
	UserSolidFullRegenerate (model, PRO_B_TRUE);
	
	return PRO_TK_NO_ERROR;
}
/*====================================================================*\
FUNCTION: UserSolidFullRegenerate()
PURPOSE:  Fully regenerates the indicated model - 
prompt for fix model on failure
\*====================================================================*/
ProError UserSolidFullRegenerate (ProSolid solid, ProBoolean allow_fix)
{
	ProError status;
	
	int regeneration_flags = PRO_REGEN_FORCE_REGEN;
	
	/*--------------------------------------------------------------------*\
	Add the "Can fix" flag to the regeneration options
	\*--------------------------------------------------------------------*/
	if (allow_fix)
		regeneration_flags |= PRO_REGEN_CAN_FIX;
	
	status = ProSolidRegenerate (solid, regeneration_flags);
	
	return PRO_TK_NO_ERROR;
}

⌨️ 快捷键说明

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