Home
Reply
Contributor
bdharris
Posts: 6

Error in saving .sat file - results in empty or unfinished(?) files

Hi,

I've run into a problem with a simple application which I have been unable to solve using documentation and previously posted threads on the subject. I am trying to load two .sat files, subtract them, and then save the "blank" to an output .sat file. I kept getting 1KB size files when using subtract, so to narrow down the problem, I took out the subtract code to test my save code. Even opening a .sat file and immediately saving it to a new file results in files that cannot be loaded in the RADF viewer - even with the same file size as the original file. This means I have two problems: 1) Saving a file somehow results in unloadable file, and 2)my Boolean subtract is probably not coded properly to save the "blank" from the operation - I think this is probably in the fact that I lose the "target" object out of the target entity list during boolean and need to add it back in before saving?

Here's my code:

Note: my function do_sub simply calls api_subtract in a new scope, and check_result is my own function that prints error data and where it happened in my own code.

Note2: this code compiles and runs with no errors - hence my confusion.

Note3: I already tried opening the out file as "wt" instead of "w." Both result in unreadable files.

 

//header stuff, initialization, unlock, etc taken out for brevity...

//argv[0] = ACIS_test, argv[1] = <target>, argv[2] = <tool>, argv[3] = <output>
        if (argc != 4) {printf("Error: not enough arguments. Use acis_test <target> <tool> <output>\n");}
//target ENTITY_LIST & target_entity_list = ENTITY_LIST::ENTITY_LIST(); char * target_key = argv[1]; FILE * target_fileptr = fopen(target_key, "r"); if (target_fileptr) { result = api_restore_entity_list(target_fileptr, TRUE, target_entity_list); fclose(target_fileptr); check_result(result, "loading target"); } else printf("Failed to load target file.\n"); //tool ENTITY_LIST & tool_entity_list = ENTITY_LIST::ENTITY_LIST(); char * tool_key = argv[2]; FILE * tool_fileptr = fopen(tool_key, "r"); if (target_fileptr) { result = api_restore_entity_list(tool_fileptr, TRUE, tool_entity_list); fclose(tool_fileptr); check_result(result, "loading tool"); } else printf("Failed to load tool file.\n"); //save stuff char * out_key = argv[3]; FileInfo fileinfo; fileinfo.set_units(1.0); fileinfo.set_product_id("xxxxxx"); //not really xxxx, changed for identifying information result = api_set_file_info((FileId | FileUnits), fileinfo); check_result(result, "setting file info"); result = api_set_int_option("sequence_save_files", 1); check_result(result, "setting file info (int option)"); AcisOptions *ao = NULL; //boolean (tool, "blank" (target), AcisOptions) BODY *tool = (BODY*)(tool_entity_list[0]); BODY *target = (BODY*)(target_entity_list[0]); // do_sub commented out so as to test api_save_entity_list //result = do_sub(tool, target, ao); //check_result(result, "api_subtract"); //save FILE * out_file = fopen(out_key, "w"); if (out_file) { result = api_save_entity_list(out_file, TRUE, target_entity_list); fclose(out_file); check_result(result, "saving output"); } else printf("Error opening out_file");

//stop modeller, terminate components, etc...

 

Spatial Moderator
rbagley
Posts: 126

Re: Error in saving .sat file - results in empty or unfinished(?) files

can you read the newly saved file in the acis3dt.exe that is in your ACIS installation?

Regular Contributor
Vi2
Posts: 72

Re: Error in saving .sat file - results in empty or unfinished(?) files

Try to define translation mode of opening files to "rt" instead of "r", i.e. in text mode.

Contributor
bdharris
Posts: 6

Re: Error in saving .sat file - results in empty or unfinished(?) files

I did as Vi2 said and was subsequently able to open the output files in acis3dt.exe. I think (not sure) that I'm saving to a later version than that which my RADF viewer was built with. Also, the boolean problem is solved.

Thanks for your help!