iCAx开思网

标题: 【求助】proe开发 套用tkuse实例遇到的问题 [打印本页]

作者: NOCTURE    时间: 2003-5-23 15:00
标题: 【求助】proe开发 套用tkuse实例遇到的问题
套用tkuse中建section的例子编程中却出现:
error C2440: 'return' : cannot convert from 'const int' to 'enum ProErrors'
                   Conversion to enumeration type requires an explicit cast
                   (static_cast, C-style cast or function-style cast)
因基础太差百思不得其解,请高手指点!
作者: NOCTURE    时间: 2003-5-23 15:18
十万火急,求大家帮忙!!!
作者: zjcbhy    时间: 2003-5-23 20:20
可不可以将你出错的程序段贴出,这样方便大家看看。
作者: NOCTURE    时间: 2003-5-23 23:41
就是下面这一段(tkuse中sections那一张的例子)我才可能是需要一个“显性类型转换”?恳请大家指点。
ProError ProDemoSectCreate(
               double width, /* (In) The rectangle width */
                           double height, /* (In) The rectangle height */
                           double bite_radius, /* (In) The radius of the bite */
                           double bite_height, /* (In) The height of the bite */
                          &nbsproUtilCname name, /* (In) The sketch name */
                          &nbsproBoolean alloc, /* (In) mem Alloc specifier */
                          &nbsproSection *p_section) /* (In/Out) The section handle for the sketch */
{
 &nbsproError status, solve_status;
   &nbsproSection section;
    ProName wname;
    Pro2dArcdef arc;
    Pro2dLinedef line;
    int bottom_id, right_id, top_id,  
    left_top_id,left_bottom_id, arc_id;
    int width_dim, height_dim, bite_height_dim,
    bite_radius_dim;
    ProSectionPointType pnt_types[2];
    Pro2dPnt point;
    int n_errors, e;
    ProWSecerror errors;
    ProMsg wmsg;
    char msg[PRO_PATH_SIZE];
    int dims[2];
/*-----------------------------------------------------------*\
Check that the dimensions are possible.
\*-----------------------------------------------------------*/
    if (width < EPSM6 || height < EPSM6)
    return (-1);
    if (bite_height <= bite_radius)
    return (-1);
    if (bite_height + bite_radius > height)
    return (-1);
    if (bite_radius >= width)
    return (-1);
/*-----------------------------------------------------------*\
Allocate the handle for the 2-D section.
\*-----------------------------------------------------------*/
    if (alloc == PRO_B_TRUE)
  {
    status = ProSection2DAlloc ([$section)]
  }
  else
    section = *p_section;
/*-----------------------------------------------------------*\
Set the name of the section.
\*-----------------------------------------------------------*/
  ProStringToWstring (wname, name);
    status = ProSectionNameSet (section, wname);
/*-----------------------------------------------------------*\
         Set the ?epsilon value.设定截面的最小值
\*-----------------------------------------------------------*/
    status = ProSectionEpsilonSet (section, 0.5);
/*-----------------------------------------------------------*\
Add a straight-line entity for the bottom of the rectangle.
\*-----------------------------------------------------------*/
    line.type = PRO_2D_LINE;
    line.end1[0] = 0.0;
    line.end1[1] = 0.0;
    line.end2[0] = width + 0.1;
    line.end2[1] = 0.0;
    status = ProSectionEntityAdd (section, (Pro2dEntdef*)[$line, &bottom_id)]
/*-----------------------------------------------------------*\
...right
\*-----------------------------------------------------------*/
    line.type = PRO_2D_LINE;
    line.end1[0] = width + 0.1;
    line.end1[1] = 0.0;
    line.end2[0] = width;
    line.end2[1] = height;
    status = ProSectionEntityAdd (section,  
    (Pro2dEntdef*)[$line, &right_id)]
/*-----------------------------------------------------------*\
...top
\*-----------------------------------------------------------*/
     line.type = PRO_2D_LINE;
     line.end1[0] = width;
     line.end1[1] = height;
     line.end2[0] = 0.0;
     line.end2[1] = height;
     status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,  
     [$top_id)]
/*-----------------------------------------------------------*\
...left above the bite
\*-----------------------------------------------------------*/
    line.type = PRO_2D_LINE;
    line.end1[0] = 0.0;
    line.end1[1] = bite_height - bite_radius;
    line.end2[0] = 0.0;
    line.end2[1] = 0.0;
    status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,  
    [$left_top_id)]
/*-----------------------------------------------------------*\
...left below the bite
\*-----------------------------------------------------------*/
    line.type = PRO_2D_LINE;
    line.end1[0] = 0.0;
    line.end1[1] = height;
    line.end2[0] = 0.0;
    line.end2[1] = bite_height + bite_radius;
    status = ProSectionEntityAdd (section, (Pro2dEntdef*)&line,  
    [$left_bottom_id)]
/*-----------------------------------------------------------*\
Add an arc entity for the bite itself.
\*-----------------------------------------------------------*/
    arc.type = PRO_2D_ARC;
    arc.center[0] = 0.0;
    arc.center[1] = bite_height;
    arc.start_angle = PI * 1.5; /* 270 degrees counterclockwise
                                 from the X axis */
    arc.end_angle = PI / 2.0; /* 90 degrees counterclockwise
                                 from the X axis */
    arc.radius = bite_radius;
    status = ProSectionEntityAdd (section, (Pro2dEntdef*)&arc,  
    [$arc_id)]
/*-----------------------------------------------------------*\
Add a dimension for the width (the length of the top
entity).
\*-----------------------------------------------------------*/
    point[0] = width/2.0;
    point[1] = height + 10.0;
    pnt_types[0] = PRO_ENT_WHOLE;
    status = ProSecdimCreate (section, &top_id, pnt_types, 1,  
    PRO_TK_DIM_LINE, point, [$width_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the height (the length of the
right entity).
\*-----------------------------------------------------------*/
    point[0] = width + 1.0;
    point[1] = height/2.0;
    pnt_types[0] = PRO_ENT_WHOLE;
    status = ProSecdimCreate (section, &right_id, pnt_types, 1,  
    PRO_TK_DIM_LINE, point, [$height_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the height of the bite.
\*-----------------------------------------------------------*/
    point[0] = -1.0;
    point[1] = bite_height/2.0;
    dims[0] = bottom_id;
    dims[1] = arc_id;
    pnt_types[0] = PRO_ENT_WHOLE;
    pnt_types[1] = PRO_ENT_CENTER;
    status = ProSecdimCreate (section, dims, pnt_types, 2,  
    PRO_TK_DIM_LINE_POINT, point, [$bite_height_dim)]
/*-----------------------------------------------------------*\
Add a dimension for the radius of the bite.
\*-----------------------------------------------------------*/
    point[0] = bite_radius + 1.0;
    point[1] = bite_height;
    pnt_types[0] = PRO_ENT_WHOLE;
    status = ProSecdimCreate (section, &arc_id, pnt_types, 1,  
    PRO_TK_DIM_RAD, point, [$bite_radius_dim)]
/*-----------------------------------------------------------*\
Claim memory for the error structure.
\*-----------------------------------------------------------*/
    status = ProSecerrorAlloc ([$errors)]
/*-----------------------------------------------------------*\
Solve the section.
\*-----------------------------------------------------------*/
    solve_status = ProSectionSolve (section, [$errors)]
/*-----------------------------------------------------------*\
If the solve failed, report error messages and exit.
\*-----------------------------------------------------------*/
    if (solve_status != PRO_TK_NO_ERROR)
  {
    status = ProSecerrorCount ([$errors, &n_errors)]
    for (e = 0; e < n_errors; e++)
    {
      status = ProSecerrorMsgGet (errors, e, wmsg);
            ProWstringToString (msg, wmsg);
            printf ("Error %d message : %s\n",e, msg);
    }
    return (-1);
  }
  status = ProSecerrorFree ([$errors)]
/*-----------------------------------------------------------*\
Save the section.
\*-----------------------------------------------------------*/
    status = ProMdlSave (section);
/*-----------------------------------------------------------*\
Return the section handle
\*-----------------------------------------------------------*/
    *p_section = section;
    return (0);
}
作者: zjcbhy    时间: 2003-5-24 08:28
错误出在哪条语句上?
作者: NOCTURE    时间: 2003-5-24 11:24
就是那些"return(-1)""return(0)"的地方。
好像说我的返还值类型不对,可原来给出的例子就是这样的呀::?::?::?::?
作者: zjcbhy    时间: 2003-5-24 11:33
将return(0)换成return(PRO_TK_NO_ERROR)
将return(1)换成return(PRO_TK_GENERAL_ERROR)
试试
作者: NOCTURE    时间: 2003-5-24 12:05
compile时没有问题,可在rebuide时出现了如下问题
  
Linking...
LINK : warning LNK4075: ignoring /INCREMENTAL due to /FORCE specification Creating library Debug/section.lib and object Debug/section.exp
section.obj : error LNK2001: unresolved external symbol "enum ProErrors __cdecl ProDemoSectCreate(void)" (?ProDemoSectCreate@@YA?AW4ProErrors@@XZ)
Debug/section.dll : warning LNK4088: image being generated due to /FORCE option; image may not run
  
section.dll - 1 error(s), 2 warning(s)
原文中是分几步一段一段地介绍函数的,其中ProSectionSolve()的介绍中出现了if (status != PRO_TK_NO_ERROR)
       return(-1);
这种情况。而在最后的范例中却是把各步集成了一个函数,出现了上述问题。
作者: NOCTURE    时间: 2003-5-24 17:57
再回头看看例子,我发现这一段我始终没搞明白
*************************************************
The following code fragment shows a call to ProSectionSolve()
and an analysis of the errors produced.
*********************************************
ProWSecerror  errors;
int                  n_errors, e;
ProError          status;
ProMsg            wmsg;
char               msg[PRO_PATH_SIZE];
int                 ent_id;
ProSecerrorAlloc ([$errors)]
status = ProSectionSolve (section, [$errors)]
if (status != PRO_TK_NO_ERROR)
{
   &nbsproSecerrorCount ([$errors, &n_errors)]
    for (e = 0; e < n_errors; e++)
   {
     &nbsproSecerrorMsgGet (errors, e, wmsg);
     &nbsproWstringToString (msg, wmsg);
     &nbsproSecerrorItemGet (errors, e, [$ent_id)]
      printf ("%s: Problem ID, %d\n", msg, ent_id);
    }
ProSecerrorFree ([$errors)]
return (-1);                 这里的“-1”到底表示什么意思?指什么? ::?
}
请指教!!!
作者: lxf999999    时间: 2003-8-5 16:11
因为在运行之前有个注册
#indefine ok 1
#indefine cancel 0
它就表示了这个动作
无需其他
作者: lxf999999    时间: 2003-8-5 16:13
转换出错了,一个是整形,一个是枚举
改一下属性
或者你的库文件少了




欢迎光临 iCAx开思网 (https://www.icax.org/) Powered by Discuz! X3.3