Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

the boolean operation error in UF

Status
Not open for further replies.

lugan2

Mechanical
Apr 10, 2013
42
0
0
GB
Hi all
I want to subtract a object(maybe a hole) from another object using UF_MODL_subtract_bodies. However, when I save the result part, the program fails and the gdb gives segmental fault. The code is list in below. It seems that the program fails when the subtracted part is inside of the other part. If the 'hole' is on the edge or only intersect with the other block, the result is ok. Is it because I was using wrong command to save the result parts? I tried both 'UF_PART_save( )' and 'UF_PART_save_all', they have the same result.
Anyone know why, please? Thanks!
Code:
int main()
{

UF_initialize();

tag_t part;
int english_units = 2;
char *part_name = "arm";
UF_PART_new(part_name, english_units, &part);
{
/* varibles for block*/
double blk_corner[ 3 ] = { 0.0, 0.0, 0.0 };
char *blk_edge_len[ 3 ] = { "20.0", "20.0", "20.0" };
tag_t blk_obj_id;
tag_t blk_body_id;
/* varibles for cylinder */
double cyl_origin[ 3 ] = { 5.0, 5.0, 0.0 };
char *cyl_height = "20.0";
char *cyl_diam = "10.0";//this will fail if diameter is less then 10, which means, if the cylinder is inside of the block
double cyl_direction[ 3 ] = { 0.0, 0.0, 1.0 };
tag_t cyl_obj_id;
tag_t cyl_body_id;

int num_result = 0;
tag_t *resulting_bodies = NULL;

/* create a block */
UF_MODL_create_block1( UF_NULLSIGN, blk_corner, blk_edge_len, &blk_obj_id );
UF_MODL_ask_feat_body( blk_obj_id, &blk_body_id );
/* creat a cylinder */
UF_MODL_create_cyl1( UF_NULLSIGN, cyl_origin, cyl_height, cyl_diam, cyl_direction, &cyl_obj_id );
UF_MODL_ask_feat_body( cyl_obj_id, &cyl_body_id );

/* doing boolen operation */
UF_MODL_subtract_bodies( blk_body_id, cyl_body_id, &num_result, &resulting_bodies );

if ( num_result > 0 )
{
UF_free( resulting_bodies );
resulting_bodies = NULL;
}

/* save the part */
UF_PART_save( );
/*
int count;
tag_t * part_list;
int * error_list ;
UF_PART_save_all (&count, &part_list,&error_list );
*/
}
UF_terminate();
}

 
Replies continue below

Recommended for you

It seems unlikely that your Linux/gcc++ will be answered here. I can only say that the above code compiles and executes in Windows/Visual Studio without any problems for any cyl_diam value I tried (0.1, 5, 10, 20, 30). So, I can only advice you to check that you are using a gcc++ version that is supported for your NX version (check in Release Notes - Caveats and Product Notes - Programming Tools - Product notes) and, if so, contact QTAC.
 
Thanks for your reply, Bleaker. This could be one of the reasons that the code fails. I will try to test it in the Windown/visual studio. Many thanks!
 
Hi Bleaker. Yes, exactly, exactly! It actually worked on the MSVS platform. I think it was due to the c++ compiler compatibility issue.

Many thanks!
Gan
 
Glad that helped. I had a similar problem when I tried to build an NX8 project under MSVS9 (NX8 just came out back then and was MSVC2010 only) - everything compiled and ran fine, but all the NXStrings were messed up. Took me almost a day to determine that the problem sat in front of the display and should have checked compiler compatibility for this new and shiny NX release before diving headlong into code. The lesson I took from this was - when all else fails, read the fascinating... well, release notes, at least. :)
 
Haha, Yes, I suppose I shouldn't neglect the 'lengthy' documentation/release notes they provided.... Anyway, this should be ringing my bell is a similar problem happens again[bigsmile]
 
Status
Not open for further replies.
Back
Top