×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

the boolean operation error in UF

the boolean operation error in UF

the boolean operation error in UF

(OP)
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 --> c++

 
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();
}

RE: the boolean operation error in UF

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.

RE: the boolean operation error in UF

(OP)
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!

RE: the boolean operation error in UF

(OP)
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

RE: the boolean operation error in UF

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. smile

RE: the boolean operation error in UF

(OP)
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 againbigsmile

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources