-
Notifications
You must be signed in to change notification settings - Fork 1
Maya integration: fixed merge conflict #53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
|
|
||
| import sys | ||
| import os | ||
| from pxr import Gf, Kind, Sdf, Usd, UsdGeom, UsdShade | ||
| import time | ||
|
|
||
| def create_variant_set(prim: Usd.Prim, variant_set_name: str, variants: list) -> Usd.VariantSet: | ||
| variant_set = prim.GetVariantSets().AddVariantSet(variant_set_name) | ||
| for variant in variants: | ||
| variant_set.AddVariant(variant) | ||
|
|
||
|
|
||
| return variant_set | ||
|
|
||
| def add_sub_layer(sub_layer_path, root_layer): | ||
| sub_layer = Sdf.Layer.CreateNew(sub_layer_path) | ||
| # You can use standard python list.insert to add the subLayer to any position in the list | ||
| root_layer.subLayerPaths.append(sub_layer.identifier) | ||
| return sub_layer | ||
|
|
||
| def CreateNewUSD(a): | ||
|
|
||
| print(sys.version) | ||
| print("Creating new USD Assets list .. .. ..") | ||
| print(a) | ||
|
|
||
| raw_s = r'{}'.format(a) | ||
| last_name = raw_s.split("\\")[-2] | ||
| print(last_name) | ||
|
|
||
|
|
||
| MainName = last_name.split("_")[0]+".usda" | ||
| MainName_material = last_name.split("_")[0]+"_material.usda" | ||
| MainName_model = last_name.split("_")[0]+"_model.usda" | ||
| MainName_lod0 = last_name.split("_")[0]+"_lod0.usda" | ||
| MainName_lod1 = last_name.split("_")[0]+"_lod1.usda" | ||
| MainName_lod2 = last_name.split("_")[0]+"_lod2.usda" | ||
|
|
||
| MainDir = a+ MainName | ||
| MainDir_material = a+MainName_material | ||
| MainDir_model = a+ MainName_model | ||
|
|
||
| MainDir_lod0 = a+ MainName_lod0 | ||
| MainDir_lod1 = a+ MainName_lod1 | ||
| MainDir_lod2 = a+ MainName_lod2 | ||
|
|
||
|
|
||
|
|
||
| print(MainDir) | ||
| print(MainDir_material) | ||
| print(MainDir_model) | ||
| #stage_material = Usd.Stage.CreateNew(MainDir_material) | ||
| #stage_model = Usd.Stage.CreateNew(MainDir_model) | ||
| #stage_material.GetRootLayer().Save() | ||
| #stage_model.GetRootLayer().Save() | ||
|
|
||
|
|
||
| stage_Main = Usd.Stage.CreateNew(MainDir) | ||
| default_prim: Usd.Prim = UsdGeom.Xform.Define(stage_Main, Sdf.Path("/World")).GetPrim() | ||
| stage_Main.SetDefaultPrim(default_prim) | ||
|
|
||
|
|
||
|
|
||
| sub_layer1= add_sub_layer(MainDir_material, stage_Main.GetRootLayer()) | ||
| sub_layer2= add_sub_layer(MainDir_model, stage_Main.GetRootLayer()) | ||
|
|
||
|
|
||
| #stage_Main.GetRootLayer().Save() | ||
|
|
||
| usda = stage_Main.GetRootLayer().ExportToString() | ||
| print(usda) | ||
|
|
||
| # Check to see if the sublayer is loaded | ||
| loaded_layers = stage_Main.GetRootLayer().GetLoadedLayers() | ||
| assert sub_layer1 in loaded_layers | ||
| assert sub_layer2 in loaded_layers | ||
|
|
||
| stage_Main.GetRootLayer().Save() | ||
|
|
||
|
|
||
| # three LODS | ||
|
|
||
| stage_LOD0 = Usd.Stage.CreateNew(MainDir_lod0) | ||
| stage_LOD1 = Usd.Stage.CreateNew(MainDir_lod1) | ||
| stage_LOD2 = Usd.Stage.CreateNew(MainDir_lod2) | ||
|
|
||
| default_prim_model2 = UsdGeom.Xform.Define(stage_LOD0, Sdf.Path("/World")).GetPrim() | ||
| stage_LOD0.SetDefaultPrim(default_prim_model2) | ||
| stage_LOD0.GetRootLayer().Save() | ||
|
|
||
| default_prim_lod1= UsdGeom.Xform.Define(stage_LOD1, Sdf.Path("/World")).GetPrim() | ||
| default_prim_lod2= UsdGeom.Xform.Define(stage_LOD2, Sdf.Path("/World")).GetPrim() | ||
|
|
||
|
|
||
| stage_LOD1.SetDefaultPrim(default_prim_lod1) | ||
| stage_LOD2.SetDefaultPrim(default_prim_lod2) | ||
|
|
||
| stage_LOD1.GetRootLayer().Save() | ||
| stage_LOD2.GetRootLayer().Save() | ||
|
|
||
|
|
||
|
|
||
|
|
||
| stage_model = Usd.Stage.Open(MainDir_model) | ||
|
|
||
| default_prim_model = UsdGeom.Xform.Define(stage_model, Sdf.Path("/World")).GetPrim() | ||
| stage_model.SetDefaultPrim(default_prim_model) | ||
| stage_model.GetRootLayer().Save() | ||
| variants = ["LOD0", "LOD1", "LOD2"] | ||
|
|
||
| model_varset = create_variant_set(default_prim_model, "model", variants) | ||
|
|
||
| model_varset.SetVariantSelection('LOD0') | ||
| with model_varset.GetVariantEditContext(): | ||
| default_prim_model.GetReferences().AddReference(MainDir_lod0) | ||
|
|
||
| model_varset.SetVariantSelection('LOD1') | ||
| with model_varset.GetVariantEditContext(): | ||
| default_prim_model.GetReferences().AddReference(MainDir_lod1) | ||
|
|
||
| model_varset.SetVariantSelection('LOD2') | ||
| with model_varset.GetVariantEditContext(): | ||
| default_prim_model.GetReferences().AddReference(MainDir_lod2) | ||
|
|
||
|
|
||
| stage_model.GetRootLayer().Save() | ||
|
|
||
| try: | ||
| raise KeyboardInterrupt # Simulating a keyboard interrupt | ||
| except KeyboardInterrupt: | ||
| input("Press Enter to exit...") | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| a = sys.argv[1] | ||
| CreateNewUSD(a) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
|
|
||
| import sys | ||
| import os | ||
| import psutil | ||
|
|
||
| cwd = os.getcwd() | ||
|
|
||
| def writeToDir(a): | ||
| cwd = os.getcwd() | ||
| newFileDir = cwd+"\\..\\dcc\\maya\\dir.txt" | ||
| open(newFileDir, 'w').close() | ||
| f = open(newFileDir, "w") | ||
| f.write(a) | ||
| f.close() | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| def check_if_process_running(process_name): | ||
| for process in psutil.process_iter(['name']): | ||
| if process .info['name'] == process_name: | ||
| return True | ||
| return False | ||
|
|
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| a = sys.argv[1] | ||
| check = check_if_process_running("maya.exe") | ||
| if not check: | ||
| os.system("start maya.exe") | ||
|
|
||
| #print(check) | ||
| writeToDir(a) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this needs to be set for each user..? |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| C:\Users\Han Wang\Documents\Griddle\newassets_87146859\ |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ import { DownloadedEntry, Version } from '../../types/ipc'; | |
| import { getAuthToken } from './authentication'; | ||
| import fetchClient from './fetch-client'; | ||
| import store, { griddleFrontendStore } from './store'; | ||
|
|
||
| import { spawn } from 'child_process'; | ||
| // TODO: clean up error handling here + in message-handlers | ||
|
|
||
| export function getDownloadFolder() { | ||
|
|
@@ -78,6 +78,29 @@ export async function openFolder(asset_id: string) { | |
| shell.openPath(path.join(getDownloadFolder(), stored.folderName)); | ||
| } | ||
|
|
||
| export async function openMaya(asset_id: string) { | ||
| const stored = getDownloadedVersionByID(asset_id); | ||
| if (!stored) return; | ||
|
|
||
| const myPath = path.join(getDownloadFolder(), stored.folderName) | ||
| const pythonPath = path.join(__dirname,"../../../dcc/maya/MayaMiddleScript.py") | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we know if this works on an actual build? like are the python scripts actually included in the bundle?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. All the dcc files will be stored under the new folder |
||
| const cmd = `python ${pythonPath} "${myPath}`; | ||
| // replace with your command | ||
| const childProcess = spawn(cmd, [], { | ||
| shell: true, | ||
| }); | ||
|
|
||
| childProcess.stdout.on('data', (data) => { | ||
| console.log(data.toString()); | ||
| }); | ||
|
|
||
| childProcess.stderr.on('data', (data) => { | ||
| console.error(data.toString()); | ||
| }); | ||
|
|
||
| //shell.openPath(path.join(getDownloadFolder(), stored.folderName)); | ||
| } | ||
|
|
||
| async function zipFolder(sourceFolder: string, zipFilePath: string): Promise<void> { | ||
| return new Promise((resolve, reject) => { | ||
| const output = createWriteStream(zipFilePath); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ import { | |
| downloadVersion, | ||
| getDownloadedVersions, | ||
| openFolder, | ||
| openMaya, | ||
| unsyncAsset, | ||
| } from './lib/local-assets'; | ||
|
|
||
|
|
@@ -43,6 +44,10 @@ const messageHandlers: MessageHandlers = { | |
| await openFolder(asset_id); | ||
| return { ok: true }; | ||
| }, | ||
| 'assets:open-Maya': async (_, { asset_id}) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should probably change casing to "open-maya" to match other call names but not super important |
||
| await openMaya(asset_id); | ||
| return { ok: true }; | ||
| }, | ||
| 'auth:get-auth-token': async () => { | ||
| return { authToken: getAuthToken() }; | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,19 @@ export default function Metadata() { | |
| asset_id: asset.id, | ||
| }); | ||
| }; | ||
| const onOpenMayaClick = async () => { | ||
| if (!asset) return; | ||
|
|
||
| const downloaded = downloadedVersions?.find(({ asset_id }) => asset_id === asset.id); | ||
| if (!downloaded) return; | ||
|
|
||
| await window.api.ipc('assets:open-Maya', { | ||
| asset_id: asset.id, | ||
| semver: downloaded.semver, | ||
| }); | ||
| }; | ||
|
|
||
|
|
||
|
|
||
| if (!asset) { | ||
| return ( | ||
|
|
@@ -264,6 +277,15 @@ export default function Metadata() { | |
| <MdFolderOpen /> | ||
| Open | ||
| </button> | ||
|
|
||
| <button | ||
| className="btn btn-ghost btn-sm flex w-full flex-row flex-nowrap items-center justify-start gap-2 text-sm font-normal" | ||
| onClick={onOpenMayaClick} | ||
| > | ||
| <MdFolderOpen /> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Icon or layout should be different to clarify different actions |
||
| Open In Maya | ||
| </button> | ||
|
|
||
| <Link | ||
| className="btn btn-outline btn-primary mt-2 w-full justify-start" | ||
| to={{ pathname: `/update-asset`, search: `?id=${asset.id}` }} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does "maya.exe" work for mac or linux?