Question about exporting as an app and SaveData node

I am displaying an OBJ file which has a single textured mesh, the texture is accessed by the OBJ as an mtl file which in turn references the texture image.
I change the texture image and to get the obj to reflect that I create a new mtl file, saved using the SaveData node.
All works.

Until I save the composition as an application. The mtl file gets created in the directory the application resides but the OBJ file references the mtl file in the resources of the application package.

Solutions? Work-arounds?

From what I have read the url for the .mtl is encoded into the .obj so you’d have to parse and replace that url when reloading the obj. if possible.
Otherwise could you just use an image texture instead of the .mtl in the first instance?  

No, I think you misunderstand the problem.

I am using a texture, in the usual way the OBJ references the mtl file which in turn defines a material which specifies the texture image. That all works. I can change the mtl file to point to a different texture, I do this with the SaveData node. It works because the obj, mtl, and texture image are all located in the composition directory.

The problem comes when the composition is built into an application. The OBJ, (original) mtl, and texture image are in the resources of the package, but SaveData writes to the same location as the application (or to a location one chooses but for an application going to a third party machine that is a problem). Currently I change the OBJ reference to the mtl file to be in the users home directory and write my mtl file there also. But I hate it when applications write stuff randomly in my file system so would rather not do it myself.

One solution would seem for Vuo to provide a way of getting the path to the applications resources directory, but I don’t think there is a way of doing that currently.

Surely establishing the correct filepath/uri is something you can put in a shell or AppleScript? Does Vuo have a way of executing scripts? (qC had several 3rd party tools to do so).

Vuo can Execute Shell Command. Shell commands can normally can contain AppleScript, although when I recently played with this I hit some security permissions issues which stopped my script from working. Someone else may be able to get it to do so.

I think that the default path is the Resources directory (when the app is compiled), and the directory that the .vuo is running in [when app not compiled]

if there’s a way to execute a bundled shell script reliably then “pwd” terminal command returns the URL of current directory. Might need to set permissions of the script to be an executable with relevant admin permissions. (Be careful).
Put the URL into a text file and open the text file in Vuo.

macOS discourages modifying files within an app bundle. That’s one of the reasons they have code signing. You could get away with modifying an app exported from Vuo 2.2.1 or earlier since those aren’t code-signed, but that will not continue to work since the upcoming Vuo 2.3.0 will ad-hoc code-sign exported apps (mandatory on Apple Silicon).

Instead of saving files within an app bundle, the convention is to save them in ~/Library/Application Support/<app name>/.

But maybe you don’t need to re-save the .obj file? Instead could you use Change All Shaders or Change Shaders with Name? I mean, fetch the .obj once at the beginning, fetch the texture image each time it changes, and update the fetched scene accordingly?

2 Likes