Does anyone know why I can't create objects using python's win32com to interact with MFiles - desktop version. I managed to create program that can reed info from MFiles (properties and documents), but I can't create objects.
Error that I keep getting is:
File "C:\Users\markof\AppData\Local\Temp\gen_py\3.8\B9C079AA-92DD-4FB4-A0E0-AA3198955B45x0x1x0.py", line 17604, in CreateNewObject
ret = self._oleobj_.InvokeTypes(5, LCID, 1, (9, 0), ((3, 1), (9, 1), (9, 49), (9, 49)),ObjectType
TypeError: The Python instance can not be converted to a COM object
import win32com.client
mfiles = win32com.client.DispatchEx("MFilesAPI.MFilesClientApplication")
vault_connection = mfiles.GetVaultConnection("MD Vault")
m_vault = vault_connection.BindToVault("00000", True, True)
#Create property definitions
oPropertyValues = win32com.client.DispatchEx("MFilesAPI.PropertyValues")
# Add 'Name and Title' property by creating a new PropertyValue object.
# The PropertyValue object encapsulates the metadata information (PropertyDef)
# and the actual value (TypedValue).
oPropertyValue1 = win32com.client.DispatchEx("MFilesAPI.PropertyValue")
oPropertyValue1.PropertyDef = 0
oPropertyValue1.TypedValue.SetValue(1, "DemoObject")
oPropertyValues.Add(0, oPropertyValue1)
# Add 'Class' property
oPropertyValue2 = win32com.client.DispatchEx("MFilesAPI.PropertyValue")
oPropertyValue2.PropertyDef = 100
oPropertyValue2.TypedValue.SetValue(9,1)
oPropertyValues.Add(1, oPropertyValue2)
# Add 'Single file' property
oPropertyValue3 = win32com.client.DispatchEx("MFilesAPI.PropertyValue")
oPropertyValue3.PropertyDef = 22
oPropertyValue3.TypedValue.SetValue(8, True)
oPropertyValues.Add(2, oPropertyValue3)
# Add source file.
oSourceFiles = win32com.client.DispatchEx("MFilesAPI.SourceObjectFiles")
oSourceFile1 = win32com.client.DispatchEx("MFilesAPI.SourceObjectFile")
oSourceFile1.SourceFilePath = "test.txt"
oSourceFile1.Title = "test"
oSourceFile1.Extension = "txt"
oSourceFiles.Add(0, oSourceFile1)
# Create new object.
oObjectVersionAndProperties = m_vault.ObjectOperations.CreateNewObject(0, oPropertyValues, oSourceFiles)
