3df loading working mostly

This commit is contained in:
Lars Brubaker 2022-01-04 18:10:08 -08:00
parent d191517b50
commit fa28bca56f
10 changed files with 19 additions and 16 deletions

View file

@ -998,7 +998,7 @@ namespace MatterHackers.MatterControl
Object3D.AssetsPath = ApplicationDataStorage.Instance.LibraryAssetsPath;
this.Library = new LibraryConfig();
this.Library.ContentProviders.Add(new[] { "stl", "obj", "amf", "mcx" }, new MeshContentProvider());
this.Library.ContentProviders.Add(new[] { "stl", "obj", "3mf", "amf", "mcx" }, new MeshContentProvider());
this.Library.ContentProviders.Add("gcode", new GCodeContentProvider());
this.Library.ContentProviders.Add(new[] { "png", "gif", "jpg", "jpeg" }, new ImageContentProvider());
this.Library.ContentProviders.Add(new[] { "scad" }, new OpenScadContentProvider());

View file

@ -78,7 +78,8 @@ namespace MatterHackers.MatterControl
loadedItem = Object3D.Load(contentStream.Stream, Path.GetExtension(streamInterface.FileName), CancellationToken.None, null /*itemCache*/, progressReporter);
// Set MeshPath for non-mcx content. Avoid on mcx to ensure serialization of children
if (item is FileSystemFileItem fileItem
if (loadedItem != null
&& item is FileSystemFileItem fileItem
&& !string.Equals(Path.GetExtension(fileItem.FileName), ".mcx", StringComparison.OrdinalIgnoreCase))
{
loadedItem.MeshPath = fileItem.Path;

View file

@ -215,8 +215,7 @@ namespace MatterHackers.MatterControl.Library.Export
var errors = new List<ValidationError>();
if (ApplicationSettings.ValidFileExtensions.IndexOf(sourceExtension, StringComparison.OrdinalIgnoreCase) >= 0
|| string.Equals(sourceExtension, ".mcx", StringComparison.OrdinalIgnoreCase))
if (ApplicationSettings.ValidFileExtensions.IndexOf(sourceExtension, StringComparison.OrdinalIgnoreCase) >= 0)
{
if (CenterOnBed)
{

View file

@ -204,7 +204,7 @@ namespace MatterHackers.MatterControl.Library
{
string fileExtensionLower = Path.GetExtension(fileName).ToLower().Trim('.');
return !string.IsNullOrEmpty(fileExtensionLower)
&& ApplicationSettings.LibraryMeshFileExtensions.Contains(fileExtensionLower);
&& ApplicationSettings.ValidFileExtensions.Contains(fileExtensionLower);
}
public async Task LoadItemThumbnail(Action<ImageBuffer> thumbnailListener, Action<MeshContentProvider> buildThumbnail, ILibraryItem libraryItem, ILibraryContainer libraryContainer, int thumbWidth, int thumbHeight, ThemeConfig theme)

View file

@ -589,13 +589,13 @@ namespace MatterHackers.MatterControl.PrintLibrary
{
Icon = StaticData.Instance.LoadIcon("cube.png", 16, 16).SetToColor(theme.TextColor),
Title = "Add".Localize(),
ToolTipText = "Add an.stl, .obj, .amf, .gcode or.zip file to the Library".Localize(),
ToolTipText = "Add an.stl, .obj, .3mf, .amf, .gcode or.zip file to the Library".Localize(),
Action = (selectedLibraryItems, listView) =>
{
UiThread.RunOnIdle(() =>
{
AggContext.FileDialogs.OpenFileDialog(
new OpenFileDialogParams(ApplicationSettings.OpenPrintableFileParams, multiSelect: true),
new OpenFileDialogParams(ApplicationSettings.OpenDesignFileParams, multiSelect: true),
(openParams) =>
{
if (openParams.FileNames != null)

View file

@ -213,6 +213,7 @@ namespace MatterHackers.MatterControl.PrintQueue
case ".STL":
return StlProcessing.GetEstimatedMemoryUse(fileLocation);
case ".3MF":
case ".AMF":
return AmfDocument.GetEstimatedMemoryUse(fileLocation);

View file

@ -47,15 +47,11 @@ namespace MatterHackers.MatterControl
public class ApplicationSettings
{
public static string ValidFileExtensions { get; } = ".STL;.AMF;.OBJ";
public static string ValidFileExtensions { get; } = ".stl,.obj,.3mf,.amf,.mcx";
public static string LibraryMeshFileExtensions { get; } = ".stl,.obj,.amf,.mcx";
public static string LibraryFilterFileExtensions { get; } = ValidFileExtensions + ",.gcode";
public static string LibraryFilterFileExtensions { get; } = LibraryMeshFileExtensions + ",.gcode";
public static string OpenPrintableFileParams { get; } = "STL, AMF, OBJ, GCODE, MCX|*.stl;*.amf;*.obj;*.gcode;*.mcx";
public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, GCODE, MCX|*.stl;*.amf;*.obj;*.gcode;*.mcx";
public static string OpenDesignFileParams { get; } = "STL, AMF, OBJ, 3MF, GCODE, MCX|*.stl;*.amf;*.obj;*.gcode;*.mcx";
private static ApplicationSettings globalInstance = null;

View file

@ -317,7 +317,7 @@ namespace MatterHackers.MatterControl
systemWindow.ShowAsSystemWindow();
}
private static string[] shellFileExtensions = new string[] { ".stl", ".amf" };
private static string[] shellFileExtensions = new string[] { ".stl", ".amf", ".3mf", ".obj" };
private static readonly object locker = new object();

View file

@ -973,6 +973,9 @@ Translated:Fit to Cylinder
English:Flat
Translated:Flat
English:Flattened
Translated:Flattened
English:Force a retraction when moving between islands (distinct parts on the layer).
Translated:Force a retraction when moving between islands (distinct parts on the layer).
@ -2575,6 +2578,9 @@ Translated:Sphere
English:Spiral Vase
Translated:Spiral Vase
English:Split
Translated:Split
English:Split Mesh
Translated:Split Mesh

@ -1 +1 @@
Subproject commit 3ff85dfb5a47d603d123c185e4b6adb1e7dedabd
Subproject commit a4ed28cd0824cc393a0af1bd1109541408a6a87a