Composition-relative addressing

QC's standard patches employ "composition-relative-addressing," meaning that files access with that patch can be accessed relative to the composition.

For example, if a composition is on the desktop, a path of "foo.jpg" will get "/Users/[current user]/Desktop/foo.jpg" transparently.

None of our path-using patches (including the ones smokris pioneered at http://softpixel.com/~smokris/widgets/quartzComposer/kinemePlugins/) employ this behavior [EDIT: we're transitioning over to this to be more consistent]. It doesn't appear to have an obvious solution (composition's path isn't provided in any of our currently-implemented QCPatch methods), but it can't be that hard to figure out.

Once it is figured out, time to update!

cwright's picture
How it's done

Some inspection has revealed the following:

The input path is expanded if ~ is the first character. There's an NSString method to do this.

The path is alias-resolved (apparently, there's a QC object that does this. Knowing that would have made Folder Movies so much easier :).

If both of the above fail to modify the path (?), we call [self _executionRuntime], which returns a QCPatchRuntime.

then we call [patchRuntime options], which returns an NSDictionary of our options.

then, we get objectForKey "runtime.resourcesPath", which contains the composition's path. We can prepend this to the path, and ta-da, composition-relative addressing.

franz's picture
bundle ?

will this work for files included within an app bundle ?

cwright's picture
I don't know....

From the testing I did, it worked out something like this:

runtime.resourcesPath was defined anytime the composition was run inside QC. it was undefined any time the composition was loaded inside safari or quicktime.

It would be interesting to test this inside of a bundle; I have not done any testing in that sort of setup, but getting that information would be really helpful. Do apple's patches function 'normally' when inside bundles?

tobyspark's picture
check spark titler for non-kineme implementation

check the spark titler for how to do this for a qc in an app bundle without requiring the kineme node installed on the system. there's one line of cocoa that passes the resource folder path to the qc patch when the app initialises.

http://web.mac.com/tobyspark/iWeb/tobyzstuff/tobyzblog/DFA61EFE-A914-452...

bernardo's picture
Re: check spark titler for non-kineme implementation

yes but will the plugin patch know where is placed the composition where it is working on?

can you elaborate on this?

i want to save a file inside the directory where the composition is saved