// Explicit Activation
// This entry point is used to activate the application explicitly, as in
// "File->Execute UG/Open->User Function..."
extern "C" DllExport void ufusr( char *parm, int *returnCode, int rlen )
{int irc = 0;
char *message = "Select Object";
UF_UI_selection_options_t opts;
UF_UI_mask_t mask;
int response;
tag_t *object;
int unhighlight=0;
char buffer[133];
char error[133];
/* Initialize the API environment */
int errorCode = UF_initialize();
if ( 0 == errorCode )
{
/* TODO: Add your application code here */
opts.other_options = 0;
opts.reserved = NULL;
opts.num_mask_triples = 1;
opts.mask_triples = [$mask]
/* set up selectable type, subtype, solid type */
opts.mask_triples->object_type = UF_solid_type;
opts.mask_triples->object_subtype = UF_solid_face_subtype;
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE;
/* set selection scope to be work part */
opts.scope = UF_UI_SEL_SCOPE_WORK_PART;
int type = 2;
int unit = 3;
int accuracy = 1;
int count = 0;
/* Terminate the API environment */
errorCode = UF_terminate();
}
/* Print out any error messages */
 rintErrorMessage( errorCode );
}
// Unload Handler
// This function specifies when to unload your application from Unigraphics.
// If your application registers a callback (from a MenuScript item or a
// User Defined Object for example), this function MUST return
// "UF_UNLOAD_UG_TERMINATE".
extern "C" int ufusr_ask_unload( void )
{
return( UF_UNLOAD_UG_TERMINATE );
}
/* PrintErrorMessage
**
** Prints error messages to standard error and the Unigraphics status
** line. */
static void PrintErrorMessage( int errorCode )
{
if ( 0 != errorCode )
{
/* Retrieve the associated error message */
char message[133];
UF_get_fail_message( errorCode, message );
/* Print out the message */
UF_UI_set_status( message );
// Construct a buffer to hold the text.
ostrstream error_message;
// Initialize the buffer with the required text.
error_message << endl
<< "Error:" << endl
<< message
<< endl << endl << ends;
// Write the message to standard error
cerr << error_message.str();
}
}作者: suiyubing 时间: 2005-6-4 08:45
为什么没有人回应呢,这个代码看上去挺多的,其实也没有几句阿,肯请大家帮忙看一下呀,谢谢了作者: 深夜摔键盘 时间: 2005-6-4 09:49
你的选择器用的不对啊。
tag_t * objects Input Array of solid or sheet body identifiers,
Solid bodies for analysis type 1,
Sheet bodies for analysis types 2 and 3
int num_objs Input Number of objects
int type Input Type of 3D Analysis
1 = Solid Bodies
2 = Thin Shell - Sheet Bodies
3 = Bounded by Sheet Bodies
int units Input Units of mass and length
1 = Pounds and inches
2 = Pounds and feet
3 = Grams and centimeters
4 = Kilograms and meters
double density Input Density - Mass per unit volume (Mass per unit area for thin
shell). Not used for solid body analysis; for solid bodies
the densities of the solid bodies are used in the analysis
and the density of the combined set of bodies is output
in the mass properties array (mass_props[46]).
int accuracy Input 1 = Use Accuracy
2 = Use Relative Tolerances
double acc_value[ 11 ] Input [0] = Accuracy value between 0.0 and 1.0
if accuracy = 1
[1-10] not used if accuracy = 1
[0] = Relative Tolerance for Area if accuracy = 2
[1] = Relative Tolerance for Volume
[2-4] = Relative Tolerances for First Moments (centroidal)
[5-7] = Relative Tolerances for Moments of Inertia
(centroidal)
[8-10]= Relative Tolerances for Products of Inertia
(centroidal)
double mass_props[ 47 ] Output Mass properties
[0] = Surface Area
[1] = Volume (0.0 For Thin Shell)
[2] = Mass
[3-5] = Center Of Mass (COFM), WCS
[6-8] = First Moments (centroidal)
[9-11] = Moments Of Inertia, WCS
[12-14] = Moments Of Inertia (centroidal)
[15] = Spherical Moment Of Inertia
[16-18] = Inertia Products, WCS
[19-21] = Inertia Products (centroidal)
[22-30] = Principal Axes, WCS
[31-33] = Principal Moments (centroidal)
[34-36] = Radii Of Gyration, WCS
[37-39] = Radii Of Gyration (centroidal)
[40] = Spherical Radius Of Gyration
[41-45] = Unused
[46] = Density
double statistics[ 13 ] Output Errors are Estimates of the Relative Tolerances
achieved if accuracy = 2; otherwise
+/- range errors are given
[0] = Error For Surface Area
[1] = Error For Volume
[2] = Error For Mass
[3] = Radius Of Error Sphere
[4] = Error For Moment XC
[5] = Error For Moment YC
[6] = Error For Moment ZC
[7] = Error For Moment Of Inertia XC
[8] = Error For Moment Of Inertia YC
[9] = Error For Moment Of Inertia ZC
[10] = Error For Product Of Inertia XCYC
[11] = Error For Product Of Inertia YCZC
[12] = Error For Product Of Inertia XCZC 作者: jjf1120 时间: 2005-6-23 16:45
我要求的是实体上任一个面的面积,不求它的表面积,我用ug自带的例子只能求出实体的表面积,修改代码以后,报错说是没有这种type类型,请问这个函数可以求实体上任一面的面积吗?可以求一个封闭曲线构成的区域的面积吗?我已经试了一天了,修改了选择器,也修改过了type值,就是求不出结果,能不能给我一个参考的例子,谢谢,我的邮箱是:jjf1120@163.com