Revit建筑建模

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.Creation;
using Autodesk.Revit.Exceptions;

namespace 建筑建模
{
[Autodesk.Revit.Attributes.Transaction(TransactionMode.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
try
{

var doc = commandData.Application.ActiveUIDocument.Document;
FilteredElementCollector elems = new FilteredElementCollector(doc);

//提取坐标


//
ElementClassFilter elementClassFilter = new ElementClassFilter(typeof(Wall));
int i = 0;
elems = elems.WherePasses(elementClassFilter);
foreach (var elem in elems)
{
var opt = new Options();
GeometryElement geometryElement = elem.get_Geometry(opt);
using (Transaction trans = new Transaction(doc))
{
trans.Start("create level");
Level level1 = Level.Create(doc, 3000);
level1.Name = "标高1";

trans.Commit();
var viewfilter = new FilteredElementCollector(doc);
ElementClassFilter viewFilter = new ElementClassFilter(typeof(ViewFamilyType));
viewfilter.WherePasses(viewFilter);
ViewFamily viewFamily = ViewFamily.FloorPlan;
foreach (ViewFamilyType f in viewfilter)
{
if (f.ViewFamily == viewFamily)
{
trans.Start("create view");
ViewPlan viewPlan = ViewPlan.Create(doc,f.Id, level1.Id);
trans.Commit();
}
}
//创建轴网
trans.Start();
Grid grid1 = Grid.Create(doc, Line.CreateBound(new XYZ(0, 0, 0), new XYZ(10, 10, 0)));
trans.Commit();
trans.Start();

}


using (Transaction tran = new Transaction(doc))
{

}
i++;
foreach (var geometry in geometryElement)
{
Solid solid = geometry as Solid;
if(null!=solid)
{
foreach (Face face in solid.Faces)
{
//
}
foreach (var edge in solid.Edges)
{
//

}
}
}
}

return Result.Succeeded;
}
catch (Exception)
{

return Result.Failed;
//throw;
}
//throw new NotImplementedException();
}
}
}

Revit建筑建模

上一篇:【K8s故障排查】kubectl get componentstatuses 命令执行问题


下一篇:下载openjdk8源码