Using ptexBake command with Xgen.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I have been looking into the Xgen python code, in order to write a script that makes sure that after importing an xgen collection, file textures get connected correctly to the xgen maps (mainly connected to custom attributes), and that the ptex gets automatically baked out.
As part of this process, I want to emulate what the "start 3dpaint" and "Bake ptex textures to disk" buttons do in the xgen editor. After trawling through the xgen python code, I have found that the crucial line of code (in C:\Program Files\Autodesk\Maya2017\plug-ins\xgen\scripts\xgenm\ui\widgets\xgExpressionUI.py inside the ptexBaker class, stop() function):
cmds.ptexBake( inMesh=curMesh, outPtex=ptexBaker.g_OutputDir, bakeTexture=curFile[0], tpu=ptexBaker.g_Tpu )
There doesn't seem to be any documentation for the ptexBake command, which makes it a lot harder to figure out why I get this error when I try to run it with, what I am confident are, the correct arguments that the ptexBaker class would pass it:
# Error: RuntimeError: file <string> line 2: XGen: Failed to create //<network_path_to_user_here>/maya/xgen/collections/anteater_col/anteater_descr_01/paintmaps/custom_color_color_map/not_just_any_plane.ptx PtexWriter::edit error: header doesn't match existing file, conversions not currently supported #
I should perhaps add that the path and .ptx file already exist when running this, I am trying to overwrite it. It also, interestingly enough, breaks the scene so that even if I do click on the "bake ptex" button, it no longer allows me to save (it did before I ran the above command), and I get this error:
// Error: XGen: Trouble closing ptx file. Can't write to ptex file: //<network_path_to_user_here>/maya/xgen/collections/anteater_col/anteater_descr_01/paintmaps/custom_color_color_map/not_just_any_plane.ptx Permission denied //
So my question is - is there some flag in the ptexBake command that needs to be set in order to be able to write to the file? Or is there some other command that I can run beforehand that will either close the file or give me the permissions necessary? There doesn't seem to be anything of the sort in the above mentioned xgen function. I tried looking at the Ptex C++ source code, but I don't know C++ well enough to find anything useful.
Thanks!