关于如何快速导出FBX文件
2021/7/19 6:04:47
本文主要是介绍关于如何快速导出FBX文件,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Creat3DView { [Transaction(TransactionMode.Manual)] public class Class1 : IExternalCommand { public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uidoc = commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; UIApplication uiapp = uidoc.Application; Selection sel = uidoc.Selection; View view = commandData.View; List<Reference> referlist = sel.PickObjects(ObjectType.Element, "选择构件").ToList(); List<ElementId> ids = new List<ElementId>(); //声明一个视图集合 ViewSet views = new ViewSet();//特点是集合内容在一个视图文件内 //声明一个视图list集合 List<View3D> view3Ds = new List<View3D>(); //新建事件并启动事件 Transaction ts = new Transaction(doc, "创建围框"); ts.Start(); foreach (var reference in referlist) { Element ele = doc.GetElement(reference); BoundingBoxXYZ boundingBox = ele.get_BoundingBox(view); Transform transform = Transform.Identity; BoundingBoxXYZ box = new BoundingBoxXYZ(); box.Transform = transform; box.Min = boundingBox.Min; box.Max = boundingBox.Max; View3D view3D = View3D.CreateIsometric (doc, new FilteredElementCollector(doc).OfClass(typeof(ViewFamilyType)) .Cast<ViewFamilyType>().Where(m => m.ViewFamily == ViewFamily.ThreeDimensional) .First().Id); //设置三维剖面框 view3D.SetSectionBox(box); views.Insert(view3D); view3Ds.Add(view3D); } ts.Commit(); FBXExportOptions options = new FBXExportOptions(); string fileFolder = @"D:\作品准备\FBX导出"; string fileName = "水厂项目三维构件综合"; doc.Export(fileFolder, fileName, views, options); for (int i = 0; i < view3Ds.Count; i++) { ViewSet viewSet = new ViewSet(); viewSet.Insert(view3Ds[i]); string filename = "水厂项目三维构件" + i; FBXExportOptions pts = new FBXExportOptions(); doc.Export(fileFolder, filename, viewSet, pts); } return Result.Succeeded; } } }
导出文件格式参考文档
关于导出各文件格式API使用实例
这篇关于关于如何快速导出FBX文件的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-26大厂数据结构与算法教程:入门级详解
- 2024-12-26大厂算法与数据结构教程:新手入门指南
- 2024-12-26Python编程入门指南
- 2024-12-26数据结构高级教程:新手入门及初级提升指南
- 2024-12-26并查集入门教程:从零开始学会并查集
- 2024-12-26大厂数据结构与算法入门指南
- 2024-12-26大厂算法与数据结构入门教程
- 2024-12-26二叉树入门教程:轻松掌握基础概念与操作
- 2024-12-26初学者指南:轻松掌握链表
- 2024-12-26平衡树入门教程:轻松理解与应用