private void HandleAddStlCommand(FileInfo project, FileInfo stl, string color, Status status) { var relativeStlPath = Path.GetRelativePath(project.DirectoryName, stl.FullName); var projectFile = ProjectFile.Load(project.FullName); var existingStl = projectFile.StlInfoList.Where(s => s.RelativePath == relativeStlPath); if (existingStl != null) { var stlInfo = new StlInfo() { Name = stl.Name, RelativePath = Path.GetRelativePath(project.DirectoryName, stl.FullName), Status = status, Color = color }; projectFile.StlInfoList.Add(stlInfo); projectFile.Save(project.FullName, true); Console.WriteLine("Added stl to project file."); } else { Console.WriteLine("Skipping - STL already in project!"); } }
private void LoadProjectFile() { var projectFileBytes = GetAttachment("/Metadata/3D2P.json"); if (projectFileBytes != null) { ProjectFile = ProjectFile.Load(projectFileBytes); } // If no 3D2P.json projectfile was found, // create a default one for unknown projects. else { ProjectFile = new ProjectFile { Name = "Unknown Project", Id = null, Status = Status.Unknown }; for (var i = 0; i < Meshes.Count; i++) { var mesh = Meshes[i]; var stlName = string.IsNullOrEmpty(mesh.Name) ? $"{i}.stl" : mesh.Name; stlName = stlName.EndsWith(".STL", System.StringComparison.OrdinalIgnoreCase) ? stlName : $"{stlName}.stl"; var stlInfo = new StlInfo { Name = stlName, Status = Status.Unknown, }; mesh.Name = stlName; ProjectFile.StlInfoList.Add(stlInfo); } } }