Skip to content

Commit

Permalink
Added Orca Slicer
Browse files Browse the repository at this point in the history
  • Loading branch information
SalamiSimon committed May 1, 2024
1 parent 9f34460 commit 0cfb9a9
Show file tree
Hide file tree
Showing 27 changed files with 171 additions and 15 deletions.
16 changes: 16 additions & 0 deletions ApplicationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,21 @@ public Slic3rSettings(string path, FileType fileType, bool enabled)
Enabled = enabled;
}
}

public class OrcaSettings
{
public string Path { get; set; } = "";
public FileType FileType { get; set; } = FileType._STL;
public bool Enabled { get; set; } = false;

public OrcaSettings() { }

public OrcaSettings(string path, FileType fileType, bool enabled)
{
Path = path;
FileType = fileType;
Enabled = enabled;
}
}
}
}
37 changes: 36 additions & 1 deletion Easy3DPrint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public class Easy3DPrint : SwAddInEx
private readonly AnkerMakeSettings ankerMakeSettings = new AnkerMakeSettings();
private readonly PrusaSettings prusaSettings = new PrusaSettings();
private readonly Slic3rSettings slic3rSettings = new Slic3rSettings();
private readonly OrcaSettings orcaSettings = new OrcaSettings();

[Title("Easy3DPrint")]
[Description("Open parts directly in slicing apps")]
Expand Down Expand Up @@ -59,6 +60,11 @@ public enum Commands_e
[Icon(typeof(Resources), nameof(Resources.slic3r))]
OpenInSlic3r,

[Title("Open in Orca")]
[Description("Opens the model in Orca")]
[Icon(typeof(Resources), nameof(Resources.orca))]
OpenInOrca,

[Title("Settings")]
[Description("Easy3DPrint Settings")]
[Icon(typeof(Resources), nameof(Resources.settings))]
Expand Down Expand Up @@ -115,6 +121,9 @@ private void OnButtonEnable(Commands_e cmd, CommandState state)
case Commands_e.OpenInSlic3r:
state.Enabled = slic3rSettings.Enabled;
break;
case Commands_e.OpenInOrca:
state.Enabled = orcaSettings.Enabled;
break;
}
}

Expand Down Expand Up @@ -150,6 +159,10 @@ private bool LoadSettings()
prusaSettings.FileType = settings.ExportFormatPrusa;
prusaSettings.Enabled = settings.PrusaEnabled;

orcaSettings.Path = settings.OrcaPath;
orcaSettings.FileType = settings.ExportFormatOrca;
orcaSettings.Enabled = settings.OrcaEnabled;

if (settings.ExportFormatQuickSave != null)
addInSettings.QuickSaveType = settings.ExportFormatQuickSave;

Expand All @@ -167,7 +180,7 @@ private bool LoadSettings()

public void ShowSettingsDialog()
{
SettingsDialog settingsDialog = new SettingsDialog(addInSettings, curaSettings, bambuSettings, ankerMakeSettings, prusaSettings, slic3rSettings);
SettingsDialog settingsDialog = new SettingsDialog(addInSettings, curaSettings, bambuSettings, ankerMakeSettings, prusaSettings, slic3rSettings, orcaSettings);
if (settingsDialog.ShowDialog() == DialogResult.OK)
{
LoadSettings();
Expand Down Expand Up @@ -288,6 +301,28 @@ private void OnCommandClick(Commands_e spec)
}
break;

case Commands_e.OpenInOrca:
string FilePathOrca = null;

if (orcaSettings.FileType != FileType._NONE)
{
FilePathOrca = SaveCurrentPart(addInSettings.ExportPath, orcaSettings.FileType);
}
else
{
Application.ShowMessageBox("Select file format in settings.");
}

if (!string.IsNullOrEmpty(FilePathOrca) && !string.IsNullOrEmpty(orcaSettings.Path))
{
System.Diagnostics.Process.Start(orcaSettings.Path, $"\"{FilePathOrca}\"");
}
else
{
Application.ShowMessageBox("No Orca executable path entered in settings or file not saved sucessfully.");
}
break;

case Commands_e.QuickSave:
if (addInSettings.QuickSaveType != FileType._NONE)
{
Expand Down
1 change: 1 addition & 0 deletions Easy3DPrint_NetFW.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
</ItemGroup>
<ItemGroup>
<Content Include="3DPrint_SW.sln" />
<None Include="img\orca.png" />
<None Include="img\quicksave.png" />
<None Include="img\github.png" />
</ItemGroup>
Expand Down
10 changes: 10 additions & 0 deletions Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@
<data name="github" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\github.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="orca" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\orca.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="prusa" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\img\prusa.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand Down
117 changes: 104 additions & 13 deletions SettingsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,23 @@ public class SettingsDialog : Form
private ComboBox cmbExportFormatAnkerMake;
private ComboBox cmbExportFormatPrusa;
private ComboBox cmbExportFormatSlic3r;
private ComboBox cmbExportFormatOrca;
private ComboBox cmbQuickSaveFileType;

private TextBox txtCuraPath;
private TextBox txtBambuLabPath;
private TextBox txtAnkerMakePath;
private TextBox txtPrusaPath;
private TextBox txtSlic3rPath;
private TextBox txtOrcaPath;
private TextBox txtExportPath;

private CheckBox chkCuraEnabled;
private CheckBox chkSlic3rEnabled;
private CheckBox chkPrusaEnabled;
private CheckBox chkAnkerMakeEnabled;
private CheckBox chkBambuEnabled;
private CheckBox chkOrcaEnabled;

private Button btnSave;

Expand All @@ -42,11 +45,13 @@ public class SettingsDialog : Form
public string AnkerMakePath => txtAnkerMakePath.Text;
public string PrusaPath => txtPrusaPath.Text;
public string Slic3rPath => txtSlic3rPath.Text;
public string OrcaPath => txtOrcaPath.Text;
public string ExportFormatCura => cmbExportFormatCura.SelectedItem.ToString();
public string ExportFormatBambuLab => cmbExportFormatBambuLab.SelectedItem.ToString();
public string ExportFormatAnkerMake => cmbExportFormatAnkerMake.SelectedItem.ToString();
public string ExportFormatPrusa => cmbExportFormatPrusa.SelectedItem.ToString();
public string ExportFormatSlic3r => cmbExportFormatSlic3r.SelectedItem.ToString();
public string ExportFormatOrca => cmbExportFormatOrca.SelectedItem.ToString();
public string ExportFormatQuickSave => cmbQuickSaveFileType.SelectedItem.ToString();

public SettingsDialog(
Expand All @@ -55,7 +60,8 @@ public SettingsDialog(
ApplicationSettings.BambuSettings bambuSettings,
ApplicationSettings.AnkerMakeSettings ankerMakeSettings,
ApplicationSettings.PrusaSettings prusaSettings,
ApplicationSettings.Slic3rSettings slic3rSettings)
ApplicationSettings.Slic3rSettings slic3rSettings,
ApplicationSettings.OrcaSettings orcaSettings)
{
InitializeComponents();

Expand All @@ -81,6 +87,10 @@ public SettingsDialog(
cmbExportFormatSlic3r.SelectedItem = slic3rSettings?.FileType.ToString().TrimStart('_') ?? string.Empty;
chkSlic3rEnabled.Checked = slic3rSettings.Enabled;

txtOrcaPath.Text = orcaSettings?.Path ?? string.Empty;
cmbExportFormatOrca.SelectedItem = orcaSettings?.FileType.ToString().TrimStart('_') ?? string.Empty;
chkOrcaEnabled.Checked = orcaSettings.Enabled;

cmbQuickSaveFileType.SelectedItem = addInSettings?.QuickSaveType.ToString().TrimStart('_') ?? string.Empty;
}

Expand Down Expand Up @@ -257,15 +267,48 @@ private void InitializeComponents()
btnBrowseSlic3rPath.Visible = chkSlic3rEnabled.Checked;
};

// Orca Components
Label lblOrcaSettingsTitle = new() { Text = "Orca Slicer", Location = new Point(10, 620), Size = new Size(150, 20) };
lblOrcaSettingsTitle.Font = new Font(lblOrcaSettingsTitle.Font, FontStyle.Bold);
lblOrcaSettingsTitle.Font = new Font(lblOrcaSettingsTitle.Font.FontFamily, lblOrcaSettingsTitle.Font.Size + 1, FontStyle.Bold);
chkOrcaEnabled = new CheckBox { Text = "Orca Enabled", Location = new Point(10, 650), Size = new Size(150, 20) };
Label lblOrcaFormat = new() { Text = "Orca Filetype:", Location = new Point(10, 680), Size = new Size(150, 20) };
cmbExportFormatOrca = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Location = new Point(170, 680), Size = new Size(220, 20) };
Label lblOrcaPath = new() { Text = "Orca .EXE Path:", Location = new Point(10, 710), Size = new Size(150, 20) };
txtOrcaPath = new TextBox { Location = new Point(170, 710), Size = new Size(220, 20) };
Button btnBrowseOrcaPath = new Button { Text = "Browse", Location = new Point(400, 710), Size = new Size(75, 20) };
btnBrowseOrcaPath.Click += (sender, e) => {
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Executable files (*.exe)|*.exe";
if (openFileDialog.ShowDialog() == DialogResult.OK) {
txtOrcaPath.Text = openFileDialog.FileName;
}
};

lblOrcaFormat.Visible = chkOrcaEnabled.Checked;
cmbExportFormatOrca.Visible = chkOrcaEnabled.Checked;
lblOrcaPath.Visible = chkOrcaEnabled.Checked;
txtOrcaPath.Visible = chkOrcaEnabled.Checked;
btnBrowseOrcaPath.Visible = chkOrcaEnabled.Checked;

chkOrcaEnabled.CheckedChanged += (sender, e) =>
{
lblOrcaFormat.Visible = chkOrcaEnabled.Checked;
cmbExportFormatOrca.Visible = chkOrcaEnabled.Checked;
lblOrcaPath.Visible = chkOrcaEnabled.Checked;
txtOrcaPath.Visible = chkOrcaEnabled.Checked;
btnBrowseOrcaPath.Visible = chkOrcaEnabled.Checked;
};

// Add-in settings Components
Label lblExportedTitle = new() { Text = "Add-In Settings", Location = new Point(10, 620), Size = new Size(150, 20) };
Label lblExportedTitle = new() { Text = "Add-In Settings", Location = new Point(10, 750), Size = new Size(150, 20) };
lblExportedTitle.Font = new Font(lblExportedTitle.Font, FontStyle.Bold);
lblExportedTitle.Font = new Font(lblExportedTitle.Font.FontFamily, lblExportedTitle.Font.Size + 1, FontStyle.Bold);
Label lblQuickSaveFileTypeTitle = new() { Text = "QuickSave Filetype", Location = new Point(10, 650), Size = new Size(150, 20) };
cmbQuickSaveFileType = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Location = new Point(170, 650), Size = new Size(220, 20) };
Label lblExportPath = new() { Text = "File Export Path:", Location = new Point(10, 680), Size = new Size(150, 20) };
txtExportPath = new TextBox { Location = new Point(170, 680), Size = new Size(220, 20) };
Button btnBrowseExportPath = new Button { Text = "Browse", Location = new Point(400, 680), Size = new Size(75, 20) };
Label lblQuickSaveFileTypeTitle = new() { Text = "QuickSave Filetype", Location = new Point(10, 780), Size = new Size(150, 20) };
cmbQuickSaveFileType = new ComboBox { DropDownStyle = ComboBoxStyle.DropDownList, Location = new Point(170, 780), Size = new Size(220, 20) };
Label lblExportPath = new() { Text = "File Export Path:", Location = new Point(10, 810), Size = new Size(150, 20) };
txtExportPath = new TextBox { Location = new Point(170, 810), Size = new Size(220, 20) };
Button btnBrowseExportPath = new Button { Text = "Browse", Location = new Point(400, 810), Size = new Size(75, 20) };
btnBrowseExportPath.Click += (sender, e) => {
FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog();
if (folderBrowserDialog.ShowDialog() == DialogResult.OK) {
Expand All @@ -274,7 +317,7 @@ private void InitializeComponents()
};

// Save button
btnSave = new Button { Text = "Save", Location = new Point(10, 720), Size = new Size(450, 30) };
btnSave = new Button { Text = "Save", Location = new Point(10, 840), Size = new Size(450, 30) };

// Populate ComboBoxes
cmbExportFormatCura.Items.AddRange(new string[] { "OBJ", "STL", "3MF" });
Expand All @@ -283,6 +326,7 @@ private void InitializeComponents()
cmbExportFormatPrusa.Items.AddRange(new string[] { "OBJ", "STL", "STEP", "3MF" });
cmbExportFormatSlic3r.Items.AddRange(new string[] { "OBJ", "STL", "3MF" }); // Potentially add AMF in the future
cmbQuickSaveFileType.Items.AddRange(new string[] { "OBJ", "STL", "STEP", "3MF" });
cmbExportFormatOrca.Items.AddRange(new string[] { "OBJ", "STL", "STEP", "3MF" });

btnSave.Click += (sender, e) =>
{
Expand All @@ -291,9 +335,31 @@ private void InitializeComponents()
FileType exportFormatAnkerMake = (!string.IsNullOrEmpty(this.ExportFormatAnkerMake)) ? (FileType)Enum.Parse(typeof(FileType), "_" + this.ExportFormatAnkerMake) : FileType._NONE;
FileType exportFormatPrusa = (!string.IsNullOrEmpty(this.ExportFormatPrusa)) ? (FileType)Enum.Parse(typeof(FileType), "_" + this.ExportFormatPrusa) : FileType._NONE;
FileType exportFormatSlic3r = (!string.IsNullOrEmpty(this.ExportFormatSlic3r)) ? (FileType)Enum.Parse(typeof(FileType), "_" + this.ExportFormatSlic3r) : FileType._NONE;
FileType exportFormatOrca = (!string.IsNullOrEmpty(this.ExportFormatOrca)) ? (FileType)Enum.Parse(typeof(FileType), "_" + this.ExportFormatOrca) : FileType._NONE;
FileType quickSaveFileType = (!string.IsNullOrEmpty(this.ExportFormatQuickSave)) ? (FileType)Enum.Parse(typeof(FileType), "_" + this.ExportFormatQuickSave) : FileType._NONE;

SaveSettings(this.CuraPath, this.ExportPath, exportFormatCura, exportFormatBambu, this.BambuLabPath, this.AnkerMakePath, exportFormatAnkerMake, this.PrusaPath, exportFormatPrusa, this.Slic3rPath, exportFormatSlic3r, quickSaveFileType, chkCuraEnabled.Checked, chkBambuEnabled.Checked, chkAnkerMakeEnabled.Checked, chkPrusaEnabled.Checked, chkSlic3rEnabled.Checked);
SaveSettings(
this.ExportPath,
this.CuraPath,
this.BambuLabPath,
this.AnkerMakePath,
this.PrusaPath,
this.Slic3rPath,
this.OrcaPath,
exportFormatCura,
exportFormatBambu,
exportFormatAnkerMake,
exportFormatPrusa,
exportFormatSlic3r,
exportFormatOrca,
quickSaveFileType,
chkCuraEnabled.Checked,
chkBambuEnabled.Checked,
chkAnkerMakeEnabled.Checked,
chkPrusaEnabled.Checked,
chkSlic3rEnabled.Checked,
chkOrcaEnabled.Checked
);
};

// Add components to the form
Expand All @@ -303,20 +369,42 @@ private void InitializeComponents()
lblAnkerMakeSettingsTitle, chkAnkerMakeEnabled, lblAnkerMakeFormat, cmbExportFormatAnkerMake, lblAnkerMakePath, txtAnkerMakePath, btnBrowseAnkerMakePath,
lblPrusaSettingsTitle, chkPrusaEnabled, lblPrusaFormat, cmbExportFormatPrusa, lblPrusaPath, txtPrusaPath, btnBrowsePrusaPath,
lblSlic3rSettingsTitle, chkSlic3rEnabled, lblSlic3rFormat, cmbExportFormatSlic3r, lblSlic3rPath, txtSlic3rPath, btnBrowseSlic3rPath,
lblOrcaSettingsTitle, chkOrcaEnabled, lblOrcaFormat, cmbExportFormatOrca, lblOrcaPath, txtOrcaPath, btnBrowseOrcaPath,
lblExportedTitle, lblExportPath, txtExportPath, btnBrowseExportPath,
lblQuickSaveFileTypeTitle, cmbQuickSaveFileType, btnSave
});

// Set the size of the form
Size = new Size(500, 800);
Size = new Size(500, 950);
}

private void SaveSettings(string curaPath, string exportPath, FileType exportFormatCura, FileType exportFormatBambu, string bambuPath, string ankerMakePath, FileType exportFormatAnkerMake, string prusaPath, FileType exportFormatPrusa, string slic3rPath, FileType exportFormatSlic3r, FileType quickSaveFileType, bool curaEnabled, bool bambuEnabled, bool ankerMakeEnabled, bool prusaEnabled, bool slic3rEnabled)
private void SaveSettings(
string exportPath,
string curaPath,
string bambuPath,
string ankerMakePath,
string prusaPath,
string slic3rPath,
string orcaPath,
FileType exportFormatCura,
FileType exportFormatBambu,
FileType exportFormatAnkerMake,
FileType exportFormatPrusa,
FileType exportFormatSlic3r,
FileType exportFormatOrca,
FileType quickSaveFileType,
bool curaEnabled,
bool bambuEnabled,
bool ankerMakeEnabled,
bool prusaEnabled,
bool slic3rEnabled,
bool orcaEnabled
)
{
var settings = new
{
CuraPath = curaPath ?? "",
ExportPath = exportPath ?? "",
CuraPath = curaPath ?? "",
ExportFormatCura = exportFormatCura,
CuraEnabled = curaEnabled,
ExportFormatBambu = exportFormatBambu,
Expand All @@ -331,14 +419,17 @@ private void SaveSettings(string curaPath, string exportPath, FileType exportFor
Slic3rPath = slic3rPath ?? "",
ExportFormatSlic3r = exportFormatSlic3r,
Slic3rEnabled = slic3rEnabled,
OrcaPath = orcaPath ?? "",
ExportFormatOrca = exportFormatOrca,
OrcaEnabled = orcaEnabled,
ExportFormatQuickSave = quickSaveFileType
};

AddinSettings addinSettings = new AddinSettings();
string json = JsonConvert.SerializeObject(settings, Formatting.Indented, new StringEnumConverter());
File.WriteAllText(addinSettings.DataPath, json);

MessageBox.Show("Settings saved.\n\nEnable state will update correctly after the next restart. (Or open and close settings again)");
MessageBox.Show("Settings saved.\n\nKnown issue: Changes are not applied until you open and close settings again");
this.Close();
}
}
Expand Down
Binary file modified bin/x64/Debug/Easy3DPrint_NetFW.dll
Binary file not shown.
Binary file modified bin/x64/Debug/Easy3DPrint_NetFW.pdb
Binary file not shown.
Binary file modified bin/x64/Release/Easy3DPrint_NetFW.dll
Binary file not shown.
Binary file modified bin/x64/Release/Easy3DPrint_NetFW.pdb
Binary file not shown.
Binary file added img/orca.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file modified obj/x64/Debug/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Binary file modified obj/x64/Debug/DesignTimeResolveAssemblyReferencesInput.cache
Binary file not shown.
Binary file modified obj/x64/Debug/Easy3DPrint_NetFW.Properties.Resources.resources
Binary file not shown.
Binary file modified obj/x64/Debug/Easy3DPrint_NetFW.csproj.GenerateResource.cache
Binary file not shown.
Binary file modified obj/x64/Debug/Easy3DPrint_NetFW.dll
Binary file not shown.
Binary file modified obj/x64/Debug/Easy3DPrint_NetFW.pdb
Binary file not shown.
Binary file modified obj/x64/Debug/TempPE/Properties.Resources.Designer.cs.dll
Binary file not shown.
Binary file modified obj/x64/Release/DesignTimeResolveAssemblyReferences.cache
Binary file not shown.
Binary file modified obj/x64/Release/Easy3DPrint_NetFW.Properties.Resources.resources
Binary file not shown.
Binary file modified obj/x64/Release/Easy3DPrint_NetFW.csproj.AssemblyReference.cache
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
77685e0c7f779d380e1519dd37364e0596c1182b0190d3aecc4d0a95212ada14
3ca2c095d73caa56ebd8b88d796c98cdff3403782802fe19c131829cae910f30
Binary file modified obj/x64/Release/Easy3DPrint_NetFW.csproj.GenerateResource.cache
Binary file not shown.
Binary file modified obj/x64/Release/Easy3DPrint_NetFW.dll
Binary file not shown.
Binary file modified obj/x64/Release/Easy3DPrint_NetFW.pdb
Binary file not shown.
Binary file modified obj/x64/Release/TempPE/Properties.Resources.Designer.cs.dll
Binary file not shown.

0 comments on commit 0cfb9a9

Please sign in to comment.