3D文檔控件Aspose.3D實用教程:在 C# 中將 3MF 文件轉換為 STL

3MF和STL都是 3D 建模軟件廣泛使用的 3D 文件格式。在某些情況下,由于行業標準要求和兼容性,STL 文件格式更受青睞。本教程將演示借助Aspose.3D for .NET,使用 C# 以編程方式將 3MF 轉換為 STL 。
Aspose.3D官方試用版下載,請聯系Aspose官方授權代理商慧都科技
加入Aspose技術交流QQ群(1041253375),與更多小伙伴一起探討提升開發技能。
3D建模SDK-安裝
要安裝Aspose.3D for .NET ,您只需下載DLL文件或在NuGet 包管理器中運行以下命令即可:
Install-Package Aspose.3D
使用 C# 將 3MF 文件轉換為 STL - 實現
安裝此 3D 建模 SDK 后,下一步就是編寫代碼片段以實現 3MF 到 STL 的轉換。
您可以按照以下步驟操作:
- 創建場景類的實例。
- 調用 Open 方法加載源 3MF 文件。
- 實例化StlSaveOptions類的對象以訪問將場景導出為 STL 文件的選項。
- 調用Save方法將輸出保存為 STL 文件。
以下代碼示例演示了如何以編程方式在 C# 中將 3MF 文件轉換為 STL:
using Aspose.ThreeD;
using Aspose.ThreeD.Formats;
namespace AsposeThreeD
{
class Graphics
{
// Convert 3MF to STL in C#
static void Main(string[] args)
{
// Set the directory path.
String dataDir = "data";
// Create an instance of the Scene class.
Scene scene = new Scene();
// Invoke the Open method to load the Source 3MF file.
scene.Open(dataDir + "torus_sliced.3mf");
// Instantiate an object of the StlSaveOptions class to access the options for exporting scene as STL file.
var stlSaveOptions = new StlSaveOptions();
// Call the Save method to save the output as a STL file.
scene.Save(dataDir + "sample.stl", stlSaveOptions);
}
}
}
輸出:

總結
在 3D 文件格式轉換和操作方面, Aspose.3D for .NET是一個強有力的選擇。本指南展示了如何使用 Aspose.3D for .NET這款 3D 建模 SDK 在 C# 中將 3MF 文件轉換為 STL 文件。同樣,您也可以使用 Aspose.3D for .NET為您的應用程序開發一個 3D 文件轉換模塊。
Aspose.3D官方試用版下載,請聯系Aspose官方授權代理商慧都科技
加入Aspose技術交流QQ群(1041253375),與更多小伙伴一起探討提升開發技能。
浙公網安備 33010602011771號