diff --git a/bin/meshroom_photogrammetry b/bin/meshroom_photogrammetry index c03e2018..0fdb7974 100755 --- a/bin/meshroom_photogrammetry +++ b/bin/meshroom_photogrammetry @@ -38,7 +38,7 @@ parser.add_argument('--cache', metavar='FOLDER', type=str, 'If not set, the default cache folder will be used: ' + meshroom.core.defaultCacheFolder) parser.add_argument('--save', metavar='FILE', type=str, required=False, - help='Save the configured Meshroom project to a file.') + help='Save the configured Meshroom graph to a project file. It will setup the cache folder accordingly if not explicitly changed by --cache.') parser.add_argument('--compute', metavar='', type=lambda x: bool(distutils.util.strtobool(x)), default=True, required=False, help='You can set it to to disable the computation.') @@ -130,13 +130,13 @@ if args.scale > 0: for node in graph.nodesByType('DepthMap'): node.downscale.value = args.scale -if args.save: - graph.save(args.save) - print('File successfully saved:', args.save) - # setup cache directory graph.cacheDir = args.cache if args.cache else meshroom.core.defaultCacheFolder +if args.save: + graph.save(args.save, fileLink=not bool(args.cache)) + print('File successfully saved: "{}"'.format(args.save)) + if not args.output: print('No output set, results will be available in the cache folder: "{}"'.format(graph.cacheDir)) diff --git a/meshroom/core/graph.py b/meshroom/core/graph.py index 2b7fe3e4..6ac38e4c 100644 --- a/meshroom/core/graph.py +++ b/meshroom/core/graph.py @@ -905,7 +905,7 @@ class Graph(BaseObject): def asString(self): return str(self.toDict()) - def save(self, filepath=None): + def save(self, filepath=None, fileLink=True): path = filepath or self._filepath if not path: raise ValueError("filepath must be specified for unsaved files.") @@ -929,7 +929,7 @@ class Graph(BaseObject): with open(path, 'w') as jsonFile: json.dump(data, jsonFile, indent=4) - if path != self._filepath: + if path != self._filepath and fileLink: self._setFilepath(path) def _setFilepath(self, filepath): @@ -939,7 +939,9 @@ class Graph(BaseObject): Args: filepath: the graph file path """ - assert os.path.isfile(filepath) + if not os.path.isfile(filepath): + self._unsetFilepath() + return if self._filepath == filepath: return @@ -951,6 +953,12 @@ class Graph(BaseObject): self.cacheDir = os.path.join(os.path.abspath(os.path.dirname(filepath)), meshroom.core.cacheFolderName) self.filepathChanged.emit() + def _unsetFilepath(self): + self._filepath = "" + self.name = "" + self.cacheDir = meshroom.core.defaultCacheFolder + self.filepathChanged.emit() + def updateInternals(self, startNodes=None, force=False): nodes, edges = self.dfsOnFinish(startNodes=startNodes) for node in nodes: