3D文档控件Aspose.3D实用教程:在 C# 中将 3MF 文件转换为 STL

3MF和STL都是 3D 建模软件广泛使用的 3D 文件格式。在某些情况下,由于行业标准要求和兼容性,STL 文件格式更受青睐。本教程将演示借助**++Aspose.3D for .NET++**,使用 C# 以编程方式将 3MF 转换为 STL 。

Aspose.3D官方试用版下载

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 文件转换模块。

相关推荐
rockey6274 小时前
AScript如何实现中文脚本引擎
c#·.net·script·eval·expression·function·动态脚本
研究点啥好呢5 小时前
Github热门项目推荐 | 创建你的像素风格!
c++·python·node.js·github·开源软件
_dindong5 小时前
cf1091div2 C.Grid Covering(数论)
c++·算法
沫璃染墨5 小时前
C++ string 从入门到精通:构造、迭代器、容量接口全解析
c语言·开发语言·c++
6Hzlia5 小时前
【Hot 100 刷题计划】 LeetCode 17. 电话号码的字母组合 | C++ 回溯算法经典模板
c++·算法·leetcode
我是唐青枫6 小时前
C#.NET gRPC 深入解析:Proto 定义、流式调用与服务间通信取舍
开发语言·c#·.net
计算机安禾6 小时前
【数据结构与算法】第36篇:排序大总结:稳定性、时间复杂度与适用场景
c语言·数据结构·c++·算法·链表·线性回归·visual studio
unicrom_深圳市由你创科技6 小时前
做虚拟示波器这种实时波形显示的上位机,用什么语言?
c++·python·c#
无限进步_6 小时前
【C++】电话号码的字母组合:从有限处理到通用解法
开发语言·c++·ide·windows·git·github·visual studio
答案—answer6 小时前
ThreeFlowX接入3D体积云和谷歌3D瓦片地图
3d