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: 

FbxObject argument passed to MayaExt_ExportTranslated in my FBX extension causes access violation

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
450 Views, 2 Replies

FbxObject argument passed to MayaExt_ExportTranslated in my FBX extension causes access violation

I'm using Maya 2013 SP1 x64 along with version 2013.3 x64 of the FBX Maya plugin, FBX SDK and FBX Extensions SDK. My extension is a straight-up copy of MayaExtensionPlugin_Example and resides in Autodesk/FBX/FBX Extensions SDK/2013.3/plugins/. I've compiled it successfully with Debug|x64. The code was unchanged and identical to the example. What the example is supposed to do is add custom data when exporting FBXs, in the MayaExt_ExportEnd function, which worked perfectly.

Now I've changed the original example minimally, to use the MayaExt_ExportTranslated function to check if the MObject argument passed to it is an MFnDagNode, and then check if its name contains a specific string. If it does, I add an attribute to the FbxObject passed to the function.


void MayaExt_ExportTranslated(FbxObject* pFbxObject, MObject& pMayaObject)
{
bool bIsGround = false;
if( pMayaObject.isNull() == false )
{
if( pMayaObject.hasFn( MFn::kDagNode ) == true )
{
const MFnDagNode fnDagNode( pMayaObject );
const std::string nodeName = fnDagNode.name().asChar();

bIsGround = nodeName.find( "Ground" ) != std::string::npos;
}
}

if( bIsGround )
{
const FbxDataType dataType = FbxDataType::Create( "KString", eFbxString );
assert( dataType.Valid() == true );

FbxProperty prop = FbxProperty::Create( pFbxObject, dataType, "IsGround" );
assert( prop.IsValid() == true );

prop.Set( true );
}
}


The scene I am exporting contains only a polygon sphere, whose transform node is named "Ground".
Additionally, the compiled DLL is copied to Maya2013/bin/plug-ins/FBX and I attach a debugger (Visual Studio 2010) to maya.exe prior to exporting my scene.

When exporting the FBX, I choose the MotionBuilder preset and then change Binary to ASCII.

The node name is successfully retrieved from pMayaObject, and correct.
When bIsGround == true, I get an unhandled exception in maya.exe: 0xC0000005 'Access violation reading location 0x0000000000000004.' on the line that creates the FbxProperty, which causes Maya to crash. Look in the attachments for a screenshot of the values in pFbxObject.

This also causes the crash:

void MayaExt_ExportTranslated(FbxObject* pFbxObject, MObject& pMayaObject)
{
const bool bIsNode = pFbxObject->Is< FbxNode >();
}


and so does this:

void MayaExt_ExportTranslated(FbxObject* pFbxObject, MObject& pMayaObject)
{
FbxScene* const pFbxScene = pFbxObject->GetScene();
}


The memory locations are just different.

I've spent many hours just trying to figure this out. I can probably just move my code to run in the MayaExt_ExportEnd function, but this problem is really bugging me.
Have I completely misunderstood something about how the ExportTranslated function works?
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Hello AlexanderSZ,

For the types of problems you are describing, you should post your question on the FBX SDK Beta forum site. To do this, click the link below for instructions.

http://area.autodesk.com/forum/autodesk-fbx/fbx-sdk/reporting-problems-or-requesting-features/

Best Regards,
Carlos
Message 3 of 3
Anonymous
in reply to: Anonymous

For anyone looking for this in the future, I found the solution.

 

The correct signature for MayaExt_ExportTranslated is actually :

 

void MayaExt_ExportTranslated(FbxObject** pInputFbxObjectMObjectpMayaObject)

 

Note the double star meaning pointer to pointer, so it looks the same as the signature of MayaExt_ExportProcess.

 

All the documentation and samples are wrong, this worked for me and fixed the crashes I had.

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

Post to forums  

Autodesk Design & Make Report