Announcements

Starting in December, we will archive content from the community that is 10 years and older. This FAQ provides more information.

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

bohdan.sadovenko
Observer
Observer

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

bohdan.sadovenko
Observer
Observer

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?

0 Likes
Reply
229 Views
4 Replies
Replies (4)

regalir
Autodesk
Autodesk

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

 

0 Likes

bohdan.sadovenko
Observer
Observer

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

 

0 Likes

regalir
Autodesk
Autodesk

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.

0 Likes

bohdan.sadovenko
Observer
Observer
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?
0 Likes