[Python][SDK] Create Property not working?

[Python][SDK] Create Property not working?

Anonymous
Not applicable
682 Views
1 Reply
Message 1 of 2

[Python][SDK] Create Property not working?

Anonymous
Not applicable

Hi,

 

I am attempting to use the 2019.0 python sdk to read and write a property to the scene of an fbx file. However, after much digging and testing, I am fearing the worst, that it may not be implemented correctly.

 

This is by no means final code,

 

def set_data_to_file(file_name, data):
    """Get data from scene.
    Usage:
    set_data_to_file(r"C:\temp\no_data.fbx", "{'data':1}")
    """
    lSdkManager, lScene = FbxCommon.InitializeSdkObjects()
    lResult = FbxCommon.LoadScene(lSdkManager, lScene, file_name)

    if not lResult:
        print("An error occurred while loading the scene...")
    else:
        p1 = lScene.FindProperty('MyCustomProp')
        if p1.IsValid() == False:
			p1 = FbxCommon.FbxProperty.Create(lScene, FbxCommon.FbxPropertyString, str('MyCustomProp'))
			FbxCommon.SaveScene(lSdkManager, lScene, file_name, pFileFormat=0)
			
    lSdkManager.Destroy()
    

However I am seemingly running into an error on the Create call.

 

TypeError: arguments did not match any overloaded call:
  FbxProperty.Create(FbxProperty, FbxDataType, str, str pLabel="", bool pCheckForDup=True): argument 1 has unexpected type 'FbxScene'
  FbxProperty.Create(FbxObject, FbxDataType, str, str pLabel="", bool pCheckForDup=True): argument 2 has unexpected type 'sip.wrappertype'

 

 

Even if I attempt to create a property on a regular scene node i get this...

 

TypeError: arguments did not match any overloaded call:
  FbxProperty.Create(FbxProperty, FbxDataType, str, str pLabel="", bool pCheckForDup=True): argument 1 has unexpected type 'FbxNode'
  FbxProperty.Create(FbxObject, FbxDataType, str, str pLabel="", bool pCheckForDup=True): argument 2 has unexpected type 'sip.wrappertype'

Am I implementing correctly? Can anyone confirm if this is working or not? If not, any ideas on a work around?

 

 

Regards.

 

 

0 Likes
683 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable

Ok, I found something that works, so this is for anyone who finds this in 5 years time.

p1 = FbxCommon.FbxProperty.Create(lScene, (fbx.FbxDataType()).Create(str('eFbxString'), 18), str('MyCustomProp'))

This was another lovely journey of 'guess the syntax' in Autodesk python sdk's.

0 Likes