Home
Reply
Visitor
373860147
Posts: 3

save and restore SAT file

[ Edited ]

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

AR
Contributor
AR
Posts: 23

Re: save and restore SAT file

[ Edited ]

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)

Visitor
373860147
Posts: 3

Re: save and restore SAT file

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

AR
Contributor
AR
Posts: 23

Re: save and restore SAT file

I was talking about api_unlock_license(), but since you are getting a body created, this must have been called.

AR
Contributor
AR
Posts: 23

Re: save and restore SAT file

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");

Visitor
373860147
Posts: 3

Re: save and restore SAT file

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.

Regular Contributor
Vi2
Posts: 72

Re: save and restore SAT file

[ Edited ]

Try to open the file exactly in text mode: FILE *fp = fopen(filename,"wt");

Spatial Employee
Entity
Posts: 65

Re: save and restore SAT file

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