📄 ug3dsection.c
字号:
place_pnt[1] = offsets[0] + 42.0; ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt); status = ProSecdimCreate(section, ent_id, pt_type, 1, PRO_TK_DIM_RAD, place_pnt, &ua_dim_id); ERROR_CHECK("ProSecdimCreate - 3", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\ Add dimension for lower arc\* =============================================================== */ ent_id[0] = lower_arc_id; pt_type[0] = PRO_ENT_WHOLE; place_pnt[0] = offsets[1] +42.0; place_pnt[1] = offsets[0] + 5.0; ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt); status = ProSecdimCreate(section, ent_id, pt_type, 1, PRO_TK_DIM_RAD, place_pnt, &la_dim_id); ERROR_CHECK("ProSecdimCreate - 4", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status;/* =============================================================== *\ Add section dimension between center line and left line\* =============================================================== */ c_ent_id[0] = ctr_line_id; c_ent_id[1] = lt_line_id; proj_pt_type[0] = PRO_ENT_WHOLE; proj_pt_type[1] = PRO_ENT_WHOLE; place_pnt[0] = offsets[1] - 2.0; place_pnt[1] = offsets[0] + 15.0; ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt); status = ProSecdimCreate(section, c_ent_id, proj_pt_type, 2, PRO_TK_DIM_LINE_LINE, place_pnt, &cl_dim_id); ERROR_CHECK("ProSecdimCreate - 5", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; status = ProSecdimValueSet(section, cl_dim_id, offsets[1]); ERROR_CHECK("ProSecdimValueSet", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; /* =============================================================== *\ Add section dimension between center line and left projection entity\* =============================================================== */ proj_ent_id[0] = ctr_line_id; proj_ent_id[1] = proj_ids[1]; proj_pt_type[0] = PRO_ENT_WHOLE; proj_pt_type[1] = PRO_ENT_WHOLE; place_pnt[0] = -2.0; place_pnt[1] = 15.0; ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt); status = ProSecdimCreate(section, proj_ent_id, proj_pt_type, 2, PRO_TK_DIM_LINE_LINE, place_pnt, &proj_dim_id[0]); ERROR_CHECK("ProSecdimCreate - 5", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; status = ProSecdimValueSet(section, proj_dim_id[0], 0.0); ERROR_CHECK("ProSecdimValueSet", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; /* =============================================================== *\ Add section dimension between bottom proj ent and bottom line\* =============================================================== */ proj_ent_id[0] = btm_line_id; proj_ent_id[1] = proj_ids[0]; proj_pt_type[0] = PRO_ENT_WHOLE; proj_pt_type[1] = PRO_ENT_WHOLE; place_pnt[0] = offsets[1] + 20.0; place_pnt[1] = offsets[0] - 3.0; ProUtil2DPointTrans(matrix_data.sec_trf, place_pnt, place_pnt); status = ProSecdimCreate(section, proj_ent_id, proj_pt_type, 2, PRO_TK_DIM_LINE_LINE, place_pnt, &proj_dim_id[1]); ERROR_CHECK("ProSecdimCreate - 6", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; status = ProSecdimValueSet(section, proj_dim_id[1], offsets[0]); ERROR_CHECK("ProSecdimValueSet", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; /* =============================================================== *\ Solve and regenerate the section \* =============================================================== */ status = ProSecerrorAlloc(&sec_errors); ERROR_CHECK("ProSecerrorAlloc", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR) return status; status = ProSectionSolve(section, &sec_errors); if (status != 0) { UserSecerrorPrint ( &sec_errors ); return status; } status = ProSectionRegenerate(section, &sec_errors); if (status != 0) { UserSecerrorPrint ( &sec_errors ); return status; } status = ProSelectionFree(&(matrix_data.sk_plane)); ERROR_CHECK("ProSelectionFree", "UserSectionBuild", status); free(temp1); free(temp2); temp1 = NULL; temp2 = NULL; return(status);}/* =============================================================== *\ Function: UserSelectSketchPlaneRefs Purpose: Select references for sketch plane and orientation plane\* =============================================================== */ProError UserSelectSketchPlaneRefs(ProSelection **sketch_refs){ ProSelection *sel; int num_sel; ProError status; if (temp1 == NULL) temp1 = (ProSelection *)calloc(2, sizeof(ProSelection)); ProStringToWstring(msgfile, "msg_ug3dsketch.txt"); status = ProMessageDisplay(msgfile, "USER Select sketch plane"); ERROR_CHECK("ProMessageDisplay", "UserSectionBuild", status); status = ProSelect("surface", 1, NULL, NULL, NULL, NULL, &sel, &num_sel); ERROR_CHECK("ProSelect", "UserSectionBuild", status); status = ProSelectionCopy(sel[0],&temp1[0]); ERROR_CHECK("ProSelectionCopy", "UserSectionBuild", status); status = ProMessageDisplay(msgfile, "USER Select top plane for orientation"); ERROR_CHECK("ProMessageDisplay", "UserSectionBuild", status); status = ProSelect("surface", 1, NULL, NULL, NULL, NULL, &sel, &num_sel); ERROR_CHECK("ProSelect", "UserSectionBuild", status); status = ProSelectionCopy(sel[0], &temp1[1]); ERROR_CHECK("ProSelectionCopy", "UserSectionBuild", status); *sketch_refs = temp1; return(status);}/* =============================================================== *\ Function: UserSelectProjectionEntities Purpose: Select projection entity references from existing geometry\* =============================================================== */ProError UserSelectProjectionEntities(ProSelection **proj_refs){ ProSelection *sel; int num_sel; ProError status; if (temp2== NULL) temp2= (ProSelection *)calloc(2, sizeof(ProSelection)); /* =============================================================== *\ Prompt user to select reference geometry \* =============================================================== */ ProStringToWstring(msgfile, "msg_ug3dsketch.txt"); status = ProMessageDisplay(msgfile, "USER Select first projection reference (bottom edge of sketch plane)"); ERROR_CHECK("ProMessageDisplay", "UserSectionBuild", status); status = ProSelect("edge", 1, NULL, NULL, NULL, NULL, &sel, &num_sel); ERROR_CHECK("ProSelect", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR || num_sel < 1) return(status); status = ProSelectionCopy(sel[0], &temp2[0]); ERROR_CHECK("ProSelectionCopy", "UserSectionBuild", status); status = ProMessageDisplay(msgfile, "USER Select second projection reference (left edge of sketch plane)"); ERROR_CHECK("ProMessageDisplay", "UserSectionBuild", status); status = ProSelect("edge", 1, NULL, NULL, NULL, NULL, &sel, &num_sel); ERROR_CHECK("ProSelect", "UserSectionBuild", status); if (status != PRO_TK_NO_ERROR || num_sel < 1) return(status); status = ProSelectionCopy(sel[0], &temp2[1]); ERROR_CHECK("ProSelectionCopy", "UserSectionBuild", status); *proj_refs = temp2; return(status);}ProError UserSelectOffsetDistances(double *offset_vals){ ProError status; ProStringToWstring(msgfile, "msg_ug3dsketch.txt"); status = ProMessageDisplay(msgfile, "USER Enter offset distance from first projection reference"); ERROR_CHECK("ProMessageDisplay", "UserSelectOffsetDistances", status); status = ProMessageDoubleRead(NULL, &offset_vals[0]); ERROR_CHECK("ProMessageDoubleRead", "UserSelectOffsetDistances", status); status = ProMessageDisplay(msgfile, "USER Enter offset distance from second projection reference"); ERROR_CHECK("ProMessageDisplay", "UserSelectOffsetDistances", status); status = ProMessageDoubleRead(NULL, &offset_vals[1]); ERROR_CHECK("ProMessageDoubleRead", "UserSelectOffsetDistances", status); return(status);}ProError UserCreateTrfMatrix(Matrix_data *m_data){ ProPoint3d origin; double sel_pnt[3], proj_sel_pnt[3], sel_vect[3]; double x_plane[3]; ProVector x, y, sk_plane_norm; ProVector d1[2], d2[2], norm; int status; ProMatrix inv_sk_mtrx; ProModelitem sk_modelitem; ProSurface sk_surf; ProUvParam sk_param; /* =============================================================== *\ Project point selected on sketch plane onto section\* =============================================================== */ ProUtilMatrixInvert(m_data->sk_mtrx, inv_sk_mtrx); status = ProSelectionUvParamGet(m_data->sk_plane, sk_param); ERROR_CHECK("ProSelectionUvParamGet", "UserCreateTrfMatrix", status); status = ProSelectionModelitemGet(m_data->sk_plane, &sk_modelitem); ERROR_CHECK("ProSelectionModelitemGet", "UserCreateTrfMatrix", status); status = ProGeomitemToSurface((ProGeomitem *)&sk_modelitem, &sk_surf); ERROR_CHECK("ProGeomitemToSurface", "UserCreateTrfMatrix", status); status = ProSurfaceXyzdataEval(sk_surf, sk_param, sel_pnt, d1, d2, norm); ERROR_CHECK("ProSurfaceXyzdataEval", "UserCreateTrfMatrix", status); ProUtilPointTrans(inv_sk_mtrx, sel_pnt, proj_sel_pnt); proj_sel_pnt[2] = 0.0; /* =============================================================== *\ Create x and y vectors of transformation matrix such that selected point on sketch plane is in first quadrant\* =============================================================== */ ProUtilLineLineX(m_data->x_axis, m_data->y_axis, origin); ProUtilVectorDiff(proj_sel_pnt, origin, sel_vect); sel_vect[2] = 0.0; ProUtilVectorNormalize(sel_vect, sel_vect); ProUtilVectorDiff(m_data->x_axis[0], m_data->x_axis[1], x); ProUtilVectorNormalize(x, x); ProUtilVectorDiff(m_data->y_axis[0], m_data->y_axis[1], y); ProUtilVectorNormalize(y, y); /* ========= Selected point should be in first quadrant ======= */ if ((ProUtilVectorDot(x,sel_vect)) < 0.0) ProUtilVectorScale(-1.0, x, x); if ((ProUtilVectorDot(y,sel_vect)) < 0.0) ProUtilVectorScale(-1.0, y, y);/* ========= Make sure surface normal is properly oriented ======= *//* ========= with respect to x and y ============================= */ ProUtilVectorCross(x, y, sk_plane_norm); ProUtilVectorTrans(m_data->sk_mtrx, sk_plane_norm, sk_plane_norm); ProUtilMatrixCopy(NULL, m_data->sec_trf); if ((ProUtilVectorDot(sk_plane_norm, m_data->sk_mtrx[2])) < 0.0) { ProUtilVectorCopy(y, m_data->sec_trf[0]); ProUtilVectorCopy(x, m_data->sec_trf[1]); ProUtilVectorCopy(NULL, m_data->sec_trf[2]); ProUtilVectorCopy(origin, m_data->sec_trf[3]); } else { ProUtilVectorCopy(x, m_data->sec_trf[0]); ProUtilVectorCopy(y, m_data->sec_trf[1]); ProUtilVectorCopy(NULL, m_data->sec_trf[2]); ProUtilVectorCopy(origin, m_data->sec_trf[3]); } m_data->sec_trf[2][2] = m_data->sec_trf[3][3] = 1.0;/* =============================================================== *\ Calculate rotation angle \* =============================================================== */ x_plane[0] = 1.0; x_plane[1] = x_plane[2] = 0.0; ProUtilVectorCross(x_plane, m_data->sk_mtrx[0], norm); ProUtilVectorCross(m_data->sec_trf[0], m_data->sec_trf[1], sk_plane_norm); m_data->angle = fabs(acos(ProUtilVectorDot(x_plane, m_data->sec_trf[0]))); if (ProUtilVectorDot(norm, sk_plane_norm) < 0.0) m_data->angle *= -1.0; return(status);}/*====================================================================*\FUNCTION: UserSectionReplacePURPOSE: Menu button action function for section replacement\*====================================================================*/ProError UserSectionReplace (){ ProError status; ProSelection* sel_array; int n_sels; ProFeature feat; ProElement sk_elem_tree; ProElempath sk_elem_path; ProElempathItem elem_path_data [3]; ProElement sk_elem; ProValue value; ProValueData value_data;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -