Community
FBX Forum
Welcome to Autodesk’s FBX Forums. Share your knowledge, ask questions, and explore popular FBX topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

There is no possibility to cancel importing via FBX SDK while using FbxImporter

4 REPLIES 4
Reply
Message 1 of 5
bohdan.sadovenko
245 Views, 4 Replies

There is no possibility to cancel importing via FBX SDK while using FbxImporter

Currently I'm trying to add possibility to cancel importing big files during import via FBX SDK.

If I'm understand correctly I can cancel import operation via FbxProgress::Cancel. But there is no possibility to set up progress for FbxImporter - in public interface I see only a method for setting FbxProgressCallback.

 

But from the other hand I see that FbxReader has both methods (for setting progress and setting progress callback). Am I right that similar method for setting FbxProgress to FbxImporter should be available too? 

 

Or I should user appropriate FbxReaders if I want to have possibility to cancel operation?

4 REPLIES 4
Message 2 of 5
regalir
in reply to: bohdan.sadovenko

If I remember correctly, you just need to set the ProgressCallback function. The Importer have an internal FbxProgress class and will "hook" the callback to it. Your callback then need to return false when you want to 'Abort'. In the example below, the ProgressCallback instructs the importer to stop reading the incoming Fbx file when the pPercent value hits 50% (or above):

FbxImporter* importer = FbxImporter::Create(manager, "");
importer->SetProgressCallback(ProgressCallback);

bool ProgressCallback(void* pArgs, float pPercent, const char* pStatus)
{
    FBX_UNUSED(pArgs);
    FBXSDK_printf(pStatus && strlen(pStatus) > 0 ? "\r%0.2f%% (%s)" : "\r%0.2f%%%s", pPercent, pStatus);
    return (pPercent < 50.0f) ? true : false;
}

 

Message 3 of 5

At first I thought in the same way - but even if I will always return false import will succeed

With next callback method import won't be cancelled and everything from the file will be imported:

bool progress_callback(void*, const float, const char*)
{
    return false;
}

 

Message 4 of 5
regalir
in reply to: bohdan.sadovenko

I think I see what is going on.

The "cancel" functionality via the progress callback have been implemented for the FBX version 7.x. Previous versions (6.x and 5.x) have a much too old internal data structure to correctly interrupt the reading process. Even with version 7.x, you can still read some data until the return value of the progress is examined. At that moment, though, I guarantee that the reading process returns without any further processing.

Message 5 of 5
bohdan.sadovenko
in reply to: regalir

And another small question.
What will be if any exception will be thrown from progress callback?

Is it ok to throw exceptions in this callback method and catch it somewhere on the user side?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report