- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
save and restore SAT file
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-16-2010 11:54 PM - edited 11-16-2010 11:55 PM
hi,
i'm a rookie of ACIS. Learning from a book i try the code below to save a entity in a sat file,but i find the created .sat file is 0KB.Nothing in it!
i am puzzled by this problem.
Look forward to your support.
the code:
void save_ent(char* filename,ENTITY* ent)
{
FileInfo info;
info.set_product_id("swust");
info.set_units(1.0);
api_set_file_info(FileId|FileUnits,info);
FILE *fp = fopen(filename,"w");
if (fp!=NULL)
{
ENTITY_LIST* savelist = new ENTITY_LIST;
savelist->add(ent);
api_save_entity_list(fp,TRUE,*savelist);
delete savelist;
}
else
{
printf("can not open it\n");
}
fclose(fp);
}
int main()
{
api_start_modeller(0);
api_initialize_constructors();
BODY *pris;
api_make_prism(100,150,200,7,pris);
save_ent("save.sat",pris);
api_terminate_constructors();
api_stop_modeller();
system("pause");
return 0;
}
Re: save and restore SAT file
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-17-2010 12:22 AM - edited 11-17-2010 12:22 AM
Are you calling unlock before saving?
Can you check if pris is created, by checking outcome of api_make_prism.( or check its not null, initialize it with null first)
Re: save and restore SAT file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-17-2010 01:09 AM
thank you for your help.
the pointer was not null when i was debugging the program.
could you explain the "unlock"? i dou't know it's effect
Re: save and restore SAT file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-17-2010 03:35 AM
I was talking about api_unlock_license(), but since you are getting a body created, this must have been called.
Re: save and restore SAT file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-17-2010 07:49 PM
Can you check the result of api_make_prism and api_save_entity_list and see if they are ok?
Something like outcome result = api_make_prism(..)
if ( !result.ok() )
printf("make prism failed");
Re: save and restore SAT file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-18-2010 06:41 PM
I have tried your solution,and the result showed that the prism had been made up successfully.
I think there must be some error else in the program that makes the failed of the produceing.
Re: save and restore SAT file
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-19-2010 12:07 AM - edited 11-19-2010 12:08 AM
Try to open the file exactly in text mode: FILE *fp = fopen(filename,"wt");
Re: save and restore SAT file
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-19-2010 12:34 PM
Hello AR,
You were correct about the need to call api_unlock_license(). Modeling operations will succeed without doing so, I believe, but definitely not save or restore.
John

