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

📄 ug3dsection.c

📁 Pro.TOOLKIT.Wildfire插件设计.配套光盘-141M.zip
💻 C
📖 第 1 页 / 共 4 页
字号:
  ProSection sect_handle;  ProFeatureCreateOptions options [] = {PRO_FEAT_CR_DO_NOT_DISPLAY};  int n_opts = 1;  ProErrorlist redef_errs;    elem_path_data [0].type = PRO_ELEM_PATH_ITEM_TYPE_ID;  elem_path_data [0].path_item.elem_id = PRO_E_STD_SECTION;  elem_path_data [1].type = PRO_ELEM_PATH_ITEM_TYPE_ID;  elem_path_data [1].path_item.elem_id = PRO_E_SKETCHER;    status = ProSelect ("feature", 1, NULL, NULL, NULL, NULL, &sel_array, &n_sels);  ERROR_CHECK ("ProSelect", "UserSectionReplace",  status);  if (status != PRO_TK_NO_ERROR)	return status;  status = ProSelectionModelitemGet (sel_array [0], &feat);  ERROR_CHECK ("ProSelectionModelitemGet", "UserSectionReplace",  status);  /*--------------------------------------------------------------------*\		Find the sketch handle from the feature handle.  \*--------------------------------------------------------------------*/  status = ProFeatureElemtreeCreate (&feat, &sk_elem_tree);  ERROR_CHECK ("ProFeatureElemtreeCreate()", "UserSectionReplace",  status);    status = ProElempathAlloc (&sk_elem_path);  ERROR_CHECK ("ProElempathAlloc()", "UserSectionReplace",  status);    status = ProElempathDataSet (sk_elem_path, elem_path_data, 2);  ERROR_CHECK ("ProElempathDataSet()", "UserSectionReplace",  status);    status = ProElemtreeElementGet (sk_elem_tree, sk_elem_path,                                   &sk_elem);  ERROR_CHECK ("ProElemtreeElementGet()", "UserSectionReplace",  status);    ProElempathFree (&sk_elem_path);    status = ProElementValueGet (sk_elem, &value);  ERROR_CHECK ("ProFeatureElemValueGet()", "UserSectionReplace",  status);    status = ProValueDataGet (value, &value_data);  ERROR_CHECK ("ProValueDataGet()", "UserSectionReplace",  status);    sect_handle = (ProSection) value_data.v.p;  /*--------------------------------------------------------------------*\		Replace the section entity  \*--------------------------------------------------------------------*/  status = UserSectionCircleToEllipseReplace (sect_handle);  ERROR_CHECK ("UserSectionCircleToEllipseReplace", "UserSectionReplace",  status);  if (status == PRO_TK_NO_ERROR)  {	status = ProFeatureRedefine (NULL,                                    &feat,                                   sk_elem_tree,                                   options,                                    n_opts,                                   &redef_errs);	ERROR_CHECK ("ProFeatureRedefine()", "UserSectionReplace",  status);	ProWindowRepaint (-1);  }   return (1);}/*====================================================================*\FUNCTION: UserSectionCircleToEllipseReplacePURPOSE:  Replace a circular sketch entity with ellipse entity\*====================================================================*/ProError UserSectionCircleToEllipseReplace (ProSection sect_handle){  ProError status;  ProBoolean is_proj;  ProIntlist id_array;  int array_size, i, replace_id;  Pro2dEntdef* ent_def;    Pro2dEllipsedef ellipse_def;  Pro2dCircledef* circle_def;  int project_1 = -1;  int project_2 = -1;  int circle_id = -1;  int ellipse_id;  int ent_ids [2];  ProSectionPointType pnt_types [2];  Pro2dPnt place_pnt = {0.0, 0.0};  int dim_id;    ProWSecerror sec_errs; /*--------------------------------------------------------------------*\	Get existing entities (needed to do the replacement)\*--------------------------------------------------------------------*/  status = ProSectionEntityIdsGet (sect_handle, &id_array, &array_size);  ERROR_CHECK ("ProSectionEntityIdsGet()", "UserSectionCircleToEllipseReplace", status);    for (i = 0; i < array_size; i++)    {      status = ProSectionEntityGet (sect_handle, id_array[i], &ent_def);   	  if (ent_def->type == PRO_2D_LINE)	  {		/*--------------------------------------------------------------------*\			Check for reference entity		\*--------------------------------------------------------------------*/		status = ProSectionEntityIsProjection (sect_handle, id_array [i], &is_proj);				if (!is_proj)			return /*PRO_TK_UNAV_SEC;*/13;		else		{			if (project_1 == -1)				project_1 = id_array [i];			else if (project_2 == -1)				project_2 = id_array [i];			else				return /*PRO_TK_UNAV_SEC;*/14;		}	  }	  else if (ent_def->type == PRO_2D_CIRCLE)	  {		circle_id = id_array [i];		circle_def = (Pro2dCircledef*)ent_def;	  }			  else		return /*PRO_TK_UNAV_SEC;*/15;    }  if (project_1 == -1 || project_2 == -1 || circle_id == -1)	  return /*PRO_TK_UNAV_SEC;*/16;  ProArrayFree ((ProArray*)&id_array); /*--------------------------------------------------------------------*\	Add the new entity (ellipse)\*--------------------------------------------------------------------*/  ellipse_def.type = PRO_2D_ELLIPSE;  memcpy (ellipse_def.origin, circle_def->center, sizeof (Pro2dPnt));  ellipse_def.x_radius = circle_def->radius * 1.2;  ellipse_def.y_radius = circle_def->radius * 0.8;    status = ProSectionEntityAdd (sect_handle, (Pro2dEntdef*)&ellipse_def, &ellipse_id);              ERROR_CHECK ("ProSectionEntityAdd()", "UserSectionCircleToEllipseReplace", status);/*--------------------------------------------------------------------*\	Manually dimension to new entity to the reference entities	 -- The replacement process will remove projected entities not currently in use.	 -- Adding dimensions from the replacement ellipse to the projected entities	       forces the entities to remain.\*--------------------------------------------------------------------*/  ent_ids [0] = project_1;  ent_ids [1] = ellipse_id;   pnt_types [0] = PRO_ENT_WHOLE;  pnt_types [1] = PRO_ENT_CENTER;      status = ProSecdimCreate (sect_handle, ent_ids, pnt_types, 2, PRO_TK_DIM_LINE_POINT, place_pnt, &dim_id);  ERROR_CHECK ("ProSecdimCreate()", "UserSectionCircleToEllipseReplace", status);  ent_ids [0] = project_2;  status = ProSecdimCreate (sect_handle, ent_ids, pnt_types, 2, PRO_TK_DIM_LINE_POINT, place_pnt, &dim_id);  ERROR_CHECK ("ProSecdimCreate()", "UserSectionCircleToEllipseReplace", status); /*--------------------------------------------------------------------*\	Perform the replacement\*--------------------------------------------------------------------*/  status = ProSectionEntityReplace (sect_handle, circle_id,                                     ellipse_id);  ERROR_CHECK ("ProSectionEntityReplace()", "UserSectionCircleToEllipseReplace", status);/*--------------------------------------------------------------------*\	Finish up dimensioning (x- and y- radius dimensions)\*--------------------------------------------------------------------*/  status = ProSectionAutodim (sect_handle, &sec_errs);  ERROR_CHECK ("ProSectionAutodim()", "UserSectionCircleToEllipseReplace", status);  if ( status != PRO_TK_NO_ERROR )    {      UserSecerrorPrint (  &sec_errs );      return status;     }  status = ProSectionRegenerate (sect_handle, &sec_errs);  ERROR_CHECK ("ProSectionRegenerate()", "UserSectionCircleToEllipseReplace", status);  if ( status != PRO_TK_NO_ERROR )    {      UserSecerrorPrint (  &sec_errs );    }  return (status);}/* =============================================================== *\   Function: UserSectionPointBuild(ProSection section, ProSelection *sketch_refs)   Purpose:  Creates a 3D Section consisting of Points\* =============================================================== */ProError UserSectionPointBuild(ProSection section, ProSelection *sketch_refs){  int 		status, i, num_errors, err_counter, proj_ids[2];  int 		point_id;   double 	offsets[2];  char 		msg[PRO_PATH_SIZE];  ProMsg 	wmsg;  Matrix_data 	matrix_data;  ProSelection 	*proj_ents;  ProWSecerror 	sec_errors;  Pro2dPointdef point;  Pro2dLinedef  *btm_linedef, *left_linedef;    ProStringToWstring(msgfile, "msg_ug3dsketch.txt");  /* =============================================================== *\   	Obtain projection entity handles as ProSelection structures\* =============================================================== */  status = UserSelectProjectionEntities(&proj_ents);  ERROR_CHECK("UserSelectrojectionEntities", "UserSectionPointBuild", status);/* =============================================================== *\    Project reference edges onto section\* =============================================================== */  for (i = 0; i < 2; i++)    {      status = ProSectionEntityFromProjection(section, proj_ents[i], &proj_ids[i]);      ERROR_CHECK("ProSectionEntityFromProjection", "UserSectionPointBuild", 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", "UserSectionPointBuild", 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", "UserSectionPointBuild", 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);    status = ProSelectionCopy(sketch_refs[0], &(matrix_data.sk_plane));  ERROR_CHECK("ProSelectionCopy", "UserSectionPointBuild", status) ;    status = UserCreateTrfMatrix(&matrix_data);  ERROR_CHECK("UseCreateTrfMatrix", "UserSectionPointBuild", status);/* =============================================================== *\          Obtain offset values from projection entities\* =============================================================== */    status = UserSelectOffsetDistances(offsets);  ERROR_CHECK("UserSelectOffsetDistances", "UserSectionPointBuild", status);  /* =============================================================== *\     Add the required point(s)     Currently only one point is added      This may be extended to add any number of points\* =============================================================== */    point.type    = PRO_2D_POINT;  point.pnt[0] = 100;   point.pnt[1] = 100;     ProUtil2DPointTrans(matrix_data.sec_trf, point.pnt, point.pnt );   status = ProSectionEntityAdd (section, (Pro2dEntdef*)&point, &point_id);  ERROR_CHECK("UserSectionPointBuild - 1", "UserSectionPointBuild", status);/* =============================================================== *\   	Dimension, Solve and regenerate the section\* =============================================================== */  status = ProSecerrorAlloc(&sec_errors);  ERROR_CHECK("ProSecerrorAlloc", "UserSectionPointBuild", status);    status = ProSectionAutodim(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", "UserSectionPointBuild", status);    free(temp1);  free(temp2);  temp1 = NULL;  temp2 = NULL;     return(status);}/* Purpose : To print the Section errors and then free memory */ ProError UserSecerrorPrint ( ProWSecerror *section_errors ){  ProError status;   ProMsg error_message;  char error_message_s[PRO_PATH_SIZE];  int error_count;   int n_sec, error_id;     status = ProSecerrorCount ( section_errors, &n_sec );   ERROR_CHECK (" ProSecerrorCount", "UserSecerrorPrint", status );     printf("Number of errors in ProWSecerror = %d \n",n_sec );     if ( status == PRO_TK_NO_ERROR )    {      for ( error_count = 0; error_count < n_sec; error_count++ )	{

⌨️ 快捷键说明

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