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

📄 ug3dsection.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 4 页
字号:
/*****************************************************************************\FILE    : Ug3DSection.cPURPOSE : Pro/TOOLKIT User Guide Examples related to 3d sectionsHISTORY..DATE      BUILD   AUTHOR    MODIFICATIONS04-Dec-97 H-02-02 Philippe  $$1    Created from old userguide code10-Dec-97 H-03-31 Philippe  $$2    add includes30-Dec-97 H-03-33 KS	    $$3	   Initialized trf matrix to NULL 	02-Mar-99 I-03-03 jeff      $$4    Wrapped PI's define inside ifndef29-May-02 J-03-27 JCN       $$5    Added section replacement08-Jul-02 J-03-29 SMK       $$6    Added UserSectionPointBuild27-Jul-02 J-03-30 SMK       $$7    Added initialization for static variables10-Aug-02 J-03-31 SMK       $$8    Added Sweep section creation18-Sep-02 J-03-34 JCN       $$9    Added UserUtilItemSelect utility24-Sep-02 J-03-34+ JCN      $$10   Set message file in some utilities06-Oct-03 K-01-16 JCN       $$11   Added include\*****************************************************************************/#include <ProToolkit.h>#include <ProMdl.h>#include <ProElement.h>#include <ProFeature.h>#include <ProFeatType.h>#include <ProFeatForm.h>#include <ProModFeat.h>#include <ProExtrude.h>#include <ProSection.h>#include <ProSelection.h>#include <ProStdSection.h>#include <ProSecdim.h>#include <ProUtil.h>#include <TestError.h>#include <math.h>#include <UtilMath.h>/*---------------------------External Functions------------------------------*/extern void ProUtil2DPointTrans();extern double *ProUtilLineLineX();/*--------------------------Globlal Definition ------------------------------*/typedef struct mtrx_data{ 	ProVector x_axis[2];	ProVector y_axis[2];	ProMatrix sec_trf; 	ProMatrix sk_mtrx; 	ProSelection sk_plane;	double angle;}Matrix_data;static wchar_t msgfile[PRO_NAME_SIZE];ProSelection *temp2 = NULL;ProSelection *temp1 = NULL;#ifndef PI# define PI 3.141592#endif/* --------------------------Function Prototypes ----------------------------*/ProError UserSelectSketchPlaneRefs(ProSelection **sketch_refs);ProError UserSelectProjectionEntities(ProSelection **proj_refs);ProError UserSelectOffsetDistances(double *offset_vals);ProError UserCreateTrfMatrix(Matrix_data *m_data);ProError UserSecerrorPrint ( ProWSecerror *section_errors ); ProError UserSweepSectionAdd ( ProSection ); ProError UserSweepSpineAdd ( ProSection , ProSelection * ); ProError UserSectionCircleToEllipseReplace (ProSection sect_handle);/* =============================================================== *\   Function: UsetUtilItemSelect   Purpose: Selection utility for feature create examples\* =============================================================== */ProError UserUtilItemSelect (char* filter_string, char* message,								int* id, ProType* type){	ProError err;	ProSelection* sels;	ProModelitem item;	int n_sels;	err = PRO_TK_GENERAL_ERROR;    do 	{		ProMessageDisplay (msgfile, message);		err = ProSelect (filter_string, 1, NULL, NULL, NULL, NULL, &sels, &n_sels);		if (err == PRO_TK_USER_ABORT || err == PRO_TK_PICK_ABOVE)				return err;	} while (err != PRO_TK_NO_ERROR);	err = ProSelectionModelitemGet (sels[0], &item);	*id = item.id;	*type = item.type;	return PRO_TK_NO_ERROR;	}/* =============================================================== *\   Function: UserSectionBuild(ProSection section, ProSelection *sketch_refs)   Purpose: Creates 3D section \* =============================================================== */ProError UserSectionBuild(ProSection section, ProSelection *sketch_refs){  ProSelection *proj_ents;  int status, i, num_errors, err_counter, proj_ids[2];  int ctr_line_id, rt_line_id, lt_line_id, top_line_id, btm_line_id;  int upper_arc_id, lower_arc_id, ent_id[1], c_ent_id[2], proj_ent_id[2];  int ll_dim_id, tl_dim_id, ua_dim_id, la_dim_id, cl_dim_id, proj_dim_id[2];  ProWSecerror sec_errors;  Pro2dLinedef line;  Pro2dClinedef c_line;  Pro2dLinedef *left_linedef, *btm_linedef;  ProSectionPointType pt_type[1], proj_pt_type[2];  Pro2dArcdef arc;  Pro2dPnt place_pnt;  ProMsg wmsg;  char msg[PRO_PATH_SIZE];  double offsets[2];  Matrix_data matrix_data;  ProStringToWstring(msgfile, "msg_ug3dsketch.txt");/* =============================================================== *\   	Obtain projection entity handles as ProSelection structures\* =============================================================== */  status = UserSelectProjectionEntities(&proj_ents);  ERROR_CHECK("UserSelectrojectionEntities", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\    Project reference edges onto section\* =============================================================== */  for (i = 0; i < 2; i++)    {      status = ProSectionEntityFromProjection(section, proj_ents[i], &proj_ids[i]);      ERROR_CHECK("ProSectionEntityFromProjection", "UserSectionBuild", status);      if (status != PRO_TK_NO_ERROR) return status;    }/* =============================================================== *\    Create section csys from edges, and obtion transformation 	matrix between sketch plane csys and section csys\* =============================================================== */  status = ProSectionEntityGet(section, proj_ids[0], (Pro2dEntdef **)&btm_linedef);  ERROR_CHECK("ProSectionEntityGet", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;  for (i = 0; i < 2; i++)    {      matrix_data.x_axis[0][i] = btm_linedef->end1[i];      matrix_data.x_axis[1][i] = btm_linedef->end2[i];      matrix_data.x_axis[i][2] = 0.0;     }	  status = ProSectionEntityGet(section, proj_ids[1], (Pro2dEntdef **)&left_linedef);  ERROR_CHECK("ProSectionEntityGet", "UserSectionBuild", status);  if ( status != PRO_TK_NO_ERROR )    return status; 	  for (i = 0; i < 2; i++)    {      matrix_data.y_axis[0][i] = left_linedef->end1[i];       matrix_data.y_axis[1][i] = left_linedef->end2[i];      matrix_data.y_axis[i][2] = 0.0;     }  status = ProSectionLocationGet(section, matrix_data.sk_mtrx);  ERROR_CHECK("ProSectionLocationGet", "UserCreateTrfMatrix", status);  if (status != PRO_TK_NO_ERROR) return status;  status = ProSelectionCopy(sketch_refs[0], &(matrix_data.sk_plane));  ERROR_CHECK("ProSelectionCopy", "UserSectionBuild", status) ;  if (status != PRO_TK_NO_ERROR) return status;  status = UserCreateTrfMatrix(&matrix_data);  ERROR_CHECK("UseCreateTrfMatrix", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   	Obtain offset values from projection entities\* =============================================================== */  status = UserSelectOffsetDistances(offsets);  ERROR_CHECK("UserSelectOffsetDistances", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add center line ...\* =============================================================== */  c_line.type = PRO_2D_CENTER_LINE;  c_line.end1[0] = 0.0;  c_line.end1[1] = 0.0;  c_line.end2[0] = 0.0;  c_line.end2[1] = 1.0;  ProUtil2DPointTrans(matrix_data.sec_trf, c_line.end1, c_line.end1);  ProUtil2DPointTrans(matrix_data.sec_trf, c_line.end2, c_line.end2);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&c_line, &ctr_line_id);  ERROR_CHECK("UserSectionEntityAdd - 1", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;		/* =============================================================== *\   		Add left vertical line ...\* =============================================================== */  line.type = PRO_2D_LINE;  line.end1[0] = offsets[1];  line.end1[1] = offsets[0];  line.end2[0] = offsets[1];  line.end2[1] = offsets[0] + 50.0;  ProUtil2DPointTrans(matrix_data.sec_trf, line.end1, line.end1);  ProUtil2DPointTrans(matrix_data.sec_trf, line.end2, line.end2);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&line, &lt_line_id);  ERROR_CHECK("UserSectionEntityAdd - 1", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add top line ...\* =============================================================== */  line.type = PRO_2D_LINE;  line.end1[0] = offsets[1];  line.end1[1] = offsets[0] + 50.0;  line.end2[0] = offsets[1] + 25.0;  line.end2[1] = offsets[0] + 50.0;  ProUtil2DPointTrans(matrix_data.sec_trf, line.end1, line.end1);  ProUtil2DPointTrans(matrix_data.sec_trf, line.end2, line.end2);	  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&line, &top_line_id);  ERROR_CHECK("UserSectionEntityAdd - 2", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add upper arc ...\* =============================================================== */  arc.type = PRO_2D_ARC;  arc.center[0] = offsets[1] + 40.0;   arc.center[1] = offsets[0] + 50.0;  arc.start_angle =  PI + matrix_data.angle;  arc.end_angle = 1.5*PI + matrix_data.angle;  arc.radius = 15.0;  ProUtil2DPointTrans(matrix_data.sec_trf, arc.center, arc.center);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&arc, &upper_arc_id);  ERROR_CHECK("UserSectionEntityAdd - 3", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add right vertical line ...\* =============================================================== */  line.type = PRO_2D_LINE;  line.end1[0] = offsets[1] + 40.0;  line.end1[1] = offsets[0] + 35.0;  line.end2[0] = offsets[1] + 40.0;  line.end2[1] = offsets[0] + 10.0;  ProUtil2DPointTrans(matrix_data.sec_trf, line.end1, line.end1);  ProUtil2DPointTrans(matrix_data.sec_trf, line.end2, line.end2);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&line, &rt_line_id);  ERROR_CHECK("UserSectionEntityAdd - 4", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add lower arc ...\* =============================================================== */  arc.type = PRO_2D_ARC;  arc.center[0] = offsets[1] + 40.0;   arc.center[1] = offsets[0];  arc.start_angle = 0.5*PI + matrix_data.angle;  arc.end_angle = PI + matrix_data.angle;   arc.radius = 10.0;  ProUtil2DPointTrans(matrix_data.sec_trf, arc.center, arc.center);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&arc, &lower_arc_id);  ERROR_CHECK("UserSectionEntityAdd - 5", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add bottom line ...\* =============================================================== */  line.type = PRO_2D_LINE;  line.end1[0] = offsets[1] + 30.0;  line.end1[1] = offsets[0];  line.end2[0] = offsets[1];  line.end2[1] = offsets[0];  ProUtil2DPointTrans(matrix_data.sec_trf, line.end1, line.end1);  ProUtil2DPointTrans(matrix_data.sec_trf, line.end2, line.end2);  status = ProSectionEntityAdd(section, (Pro2dEntdef*)&line, &btm_line_id);  ERROR_CHECK("UserSectionEntityAdd - 6", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   		Add dimension for left line\* =============================================================== */  ent_id[0] = lt_line_id;  pt_type[0] = PRO_ENT_WHOLE;  place_pnt[0] = offsets[1] - 2.0;  place_pnt[1] = offsets[0] + 25.0;  ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt);  status = ProSecdimCreate(section, ent_id, pt_type, 1, PRO_TK_DIM_LINE, place_pnt, &ll_dim_id);   ERROR_CHECK("ProSecdimCreate - 1", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   	Add dimension for top line\* =============================================================== */  ent_id[0] = top_line_id;  pt_type[0] = PRO_ENT_WHOLE;  place_pnt[0] = offsets[1] + 13.0;  place_pnt[1] = offsets[0] + 52.0;  ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt);  status = ProSecdimCreate(section, ent_id, pt_type, 1, PRO_TK_DIM_LINE, place_pnt, &tl_dim_id);   ERROR_CHECK("ProSecdimCreate - 2", "UserSectionBuild", status);  if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\   	Add dimension for upper arc\* =============================================================== */  ent_id[0] = upper_arc_id;  pt_type[0] = PRO_ENT_WHOLE;  place_pnt[0] = offsets[1] + 42.0;

⌨️ 快捷键说明

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