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

📄 samp11.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>int MiscAction();
ProFileName   UserMsg;

#define OK 1
#define CANCEL 0

void list_OKAction(char *dialog, char *component, ProAppData data);
void list_CancelAction(char *dialog, char *component, ProAppData data);
ProError UserUIListImplement ();

/*--------------------------------------------------------------------*\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 UsrExample();
    int i, menu_id;
    ProError status;
    uiCmdCmdId	cmd_id;

/*----------------------------------------------------------------*\
消息文件
\*----------------------------------------------------------------*/
	ProStringToWstring (UserMsg, "msg.txt");
	ProMessageDisplay (UserMsg, "USER %0s",
	"Demo of using list dialog.");

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

    status = ProMenubarmenuPushbuttonAdd(
	"File", "MyCmd", "List Parts", "List all parts of the drawings",
	"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);

    return (0);

}

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

}


/*==================================================================*\
  	FUNCTION : list_OKAction()
  	PURPOSE  : Action function for the "OK" button
\*==================================================================*/
void list_OKAction(char *dialog, char *component, ProAppData data)
{
  ProError status;

  status = ProUIDialogExit(dialog, OK);

}
/*==================================================================*\
  	FUNCTION : list_CancelAction()
  	PURPOSE  : Action function for the "Cancel" button
\*==================================================================*/
void list_CancelAction(char *dialog, char *component, ProAppData data)
{
  ProError status;

  status = ProUIDialogExit(dialog, CANCEL);

}



/*===========================================================================*\
  FUNCTION: UserUIListImplement
  PURPOSE:  demonstrates how to use the UI ListNames and ListLabel 
            Set functions
\*===========================================================================*/
ProError UserUIListImplement ()
{
  ProError                status;
  ProDrawing              drawing;
  ProSolid                *solids;
  ProLine                 wline;
  wchar_t                 **model_names;
  int                     i, exit_status, num; 
  char                    **strings, type;
  char                    *list_dialog = "dlg10";
  char                    *list_comp = "ug_uilist_comp";
  char                    *list_txtarea = "ug_uilist_txtarea";
  char                    *list_pbok = "ug_uilist_ok";
  char                    *list_pbcancel = "ug_uilist_cancel";

  /*-------------------------------------------------*\
    Get current drawing
  \*-------------------------------------------------*/
  status = ProMdlCurrentGet ((ProMdl*)&drawing);


  /*-------------------------------------------------*\
    Get the models that make the drawing
  \*-------------------------------------------------*/
  status = ProDrawingSolidsCollect(drawing, &solids);


  /*-------------------------------------------------*\
    Allocate memory for the char and wchar string arrays
  \*-------------------------------------------------*/
  if (status == PRO_TK_NO_ERROR)
    {
      status = ProArraySizeGet ((ProArray)solids, &num);


      status = ProArrayAlloc (num, sizeof(wchar_t *), 1, 
			      (ProArray *)&model_names);


      status = ProArrayAlloc(num, sizeof(char *), 1, (ProArray *)&strings);

      
      /*-------------------------------------------------*\
	Allocate memory for the char and wchar strings
      \*-------------------------------------------------*/
      for (i=0; i<num; i++)
        {
	  model_names[i] = (wchar_t *)calloc(PRO_NAME_SIZE, sizeof(wchar_t));
	  strings[i] = (char *)calloc(PRO_NAME_SIZE, sizeof(char));

	  /*-------------------------------------------------*\
	    Get the names of the models that makeup the drawing
	  \*-------------------------------------------------*/
	  status = ProMdlNameGet ((ProMdl)solids[i],  model_names[i]);


	  /*-------------------------------------------------*\
	    convert widestrings to strings
	  \*-------------------------------------------------*/
	  ProWstringToString(strings[i], model_names[i]);
        }

      /*-------------------------------------------------*\
	Create and set the pushbutton activate actions
      \*-------------------------------------------------*/
      status = ProUIDialogCreate (list_dialog, list_dialog); 
 

      status = ProUIPushbuttonActivateActionSet (list_dialog, list_pbok,  
						 list_OKAction, NULL); 


      status = ProUIPushbuttonActivateActionSet (list_dialog, list_pbcancel,  
						 list_CancelAction, NULL); 


      /*-------------------------------------------------*\
	Populate the list with the model names after activating
	the dialog and destroy the dialog when done
      \*-------------------------------------------------*/

      status = ProUIListNamesSet (list_dialog, list_comp, num, strings); 


      status = ProUIListLabelsSet (list_dialog, list_comp, num, model_names); 


      ProStringToWstring(wline, 
		 "These are the names of the parts\nthat makeup the drawing");
 
      status = ProUITextareaValueSet(list_dialog, list_txtarea, wline);
      

      status = ProUIDialogActivate (list_dialog, &exit_status);


      status = ProUIDialogDestroy (list_dialog);
      
      /*-------------------------------------------------*\
	Free memory
      \*-------------------------------------------------*/
      
      status = ProArrayFree ((ProArray*)&solids);

      status = ProArrayFree((ProArray *)&model_names);
      
      status = ProArrayFree((ProArray *)&strings);
      
    }

    return(PRO_TK_NO_ERROR);
}

⌨️ 快捷键说明

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