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

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

/*------------------------- Global Data -----------------------------*/
typedef struct tree_element_data
{
  ProElement    tree;
  ProElement    parent_element;
  ProElemId     elem_id;
  ProValueData  value_data;
} ProTreeElemdata;

ProFileName   UserMsg;

/*---------------------- Function Prototypes -------------------------*/
int ProDemoBaseExtrudeProtrCreate();

/*------------------------- External Data ----------------------------*/
ProError ProDemoSectCreate();

ProError ProTestFeatElemAdd (ProTreeElemdata *elem);

/*--------------------------------------------------------------------*\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]){
    ProError status;
    uiCmdCmdId	cmd_id;

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

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

    status = ProMenubarmenuPushbuttonAdd(
	"File", "MyCmd", "Create Extrusion Feature", "Create Extrusion Feature",
	"File.psh_exit", PRO_B_TRUE, cmd_id, UserMsg);

    return (0);

}

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

}

/*===============================================================*\
FUNCTION : ProDemoBaseExtrudeProtrCreate
PURPOSE  : Demonstrates the creation of the extruded protrusion
           base feature.
\*===============================================================*/
int ProDemoBaseExtrudeProtrCreate()
{
    ProTreeElemdata         elem;
    ProErrorlist            errors;
    ProMdl                  model;
    ProModelitem            model_item;
    ProSelection            model_sel;
    ProFeature              feature;
    ProFeatureCreateOptions opts[1];
    ProElempath             path;
    ProElempathItem         path_items[2];
    ProSection              section;
    ProAsmcomppath          comp_path;
    ProAsmcomppath          *p_comp_path = NULL;
    ProElement              parent_elem;
    ProValue                value;
    double                  width;
    double                  height;
    double                  bite_radius;
    double                  bite_height;
    char                    name[PRO_NAME_SIZE];
    ProBoolean              alloc;
    ProError		    status;
    ProSelection * 	    sketch_selection;
    ProSelection * 	    selection_array;
    int 		    n_select; 


/*---------------------------------------------------------------*\
    Allocate the element tree.
\*---------------------------------------------------------------*/
    status = ProElementAlloc (PRO_E_FEATURE_TREE, &(elem.tree));

/*---------------------------------------------------------------*\
    Add the feature type element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_FEATURE_TYPE;
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_FEAT_PROTRUSION;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the feature form element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_FEATURE_FORM; 
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_EXTRUDE;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the feature solid/surface/cut element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_EXT_SURF_CUT_SOLID_TYPE; 
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_EXT_FEAT_TYPE_SOLID;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the feature addition/removal material element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_REMOVE_MATERIAL; 
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_EXT_MATERIAL_ADD;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the feature thin element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_FEAT_FORM_IS_THIN; 
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_EXT_FEAT_FORM_NO_THIN;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the standard section element to the tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_STD_SECTION;
    elem.value_data.type = -1;
    elem.value_data.v.i = -1;
    status = ProTestFeatElemAdd (&elem);

/*---------------------------------------------------------------*\
    Add the section depth elements to the element tree.
\*---------------------------------------------------------------*/
    elem.parent_element = elem.tree;
    elem.elem_id = PRO_E_STD_EXT_DEPTH;
    elem.value_data.type = -1;
    elem.value_data.v.i = -1;
    status = ProTestFeatElemAdd (&elem);

    elem.elem_id = PRO_E_EXT_DEPTH_FROM;
    elem.value_data.type = -1;
    elem.value_data.v.i = -1;
    status = ProTestFeatElemAdd (&elem);
    parent_elem = elem.parent_element;
    elem.elem_id = PRO_E_EXT_DEPTH_FROM_TYPE;
    elem.value_data.type = PRO_VALUE_TYPE_INT;
    elem.value_data.v.i = PRO_EXT_DEPTH_FROM_BLIND;
    status = ProTestFeatElemAdd (&elem);
    elem.parent_element = parent_elem;
    elem.elem_id = PRO_E_EXT_DEPTH_FROM_VALUE;
    elem.value_data.type = PRO_VALUE_TYPE_DOUBLE;
    elem.value_data.v.d = 50.0;
    status = ProTestFeatElemAdd (&elem);


    status = ProMdlCurrentGet (&model);
    if ( status != PRO_TK_NO_ERROR ) return ( status );
    status = ProMdlToModelitem( model, &model_item ); 
    status = ProSelectionAlloc (p_comp_path, &model_item,
          &model_sel);

    status = ProMessageDisplay ( UserMsg, "Select a Sketched Datum Curve Feature");
    printf ( "Please Select a Sketched Datum Curve Feature \n");

    status = ProSelect ( "feature", 1, NULL, NULL, NULL, NULL, 
		      &sketch_selection, &n_select );

    if ( n_select <= 0 ) return -1;

    status = ProArrayAlloc ( n_select, sizeof (ProSelection), 
                1, ( ProArray *)&selection_array ); 

    status = ProSelectionCopy ( sketch_selection[0], &selection_array[0] ); 

/*---------------------------------------------------------------*\
    Create the protrusion using the section of the selected feature
\*---------------------------------------------------------------*/

    opts[0] = PRO_FEAT_CR_DEFINE_MISS_ELEMS;
    status = ProFeatureSketchedCreate ( model_sel, elem.tree, 
                opts, 1, selection_array, 
                &feature, &errors );

/*---------------------------------------------------------------*\
    Free up the allocated memory.
\*---------------------------------------------------------------*/
    status = ProElementFree (&elem.tree);

    return (status);
}

/*===============================================================*\
FUNCTION : ProTestFeatElemAdd
PURPOSE  : Adds a generic feature element to the element tree.
\*===============================================================*/
ProError ProTestFeatElemAdd (ProTreeElemdata *elem)
{
    ProValue    value;
    ProElement  element;
    ProError    status;
    if (elem->value_data.type != -1)
    {
        status = ProValueAlloc (&value);
        status = ProValueDataSet (value, &elem->value_data);
    }
    status = ProElementAlloc (elem->elem_id, &element);

    if (elem->value_data.type != -1)
    {
        status = ProElementValueSet (element, value);
    }
    status = ProElemtreeElementAdd (elem->parent_element, NULL, element);
    elem->parent_element = element;
    return (status);
}

⌨️ 快捷键说明

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