commandPort in Maya, python and Unity

Hello there,
I am trying to build a tool that will send data from Unity to Maya.
So in Unity, if I select a bunch of fbx then I press a button, it will write data in a text file containing the absolute path of each fbx I selected.
Now in Maya, it will read that text file and batch import all the fbx into my scene. Then I can modify my object. Click a button and it will batch export the fbx into their rightful place back in Unity.

The part in Maya is done (It’s still basic and need more works…). I can read the text file and batch import and batch export the fbx
The part in Unity is done. Unity write the objects’ path into a text file.

The problem is the link between the two.
From what I understand I have to use the commandPort but I can’t get it to work.
I can print a string. But I can’t execute a function that I made. (the batch import function in this case)

Anyone knows what’s wrong ?

A good working example of using the comamndPort to execute code can be found in:

1 Like

I found out why it wasn’t working. It was a stupid mistake on my part :scream:

Thanks for the example. I’ll definitely check it out later !