标签:Autodesk doc 建模 Revit new using trans 建筑
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();
}
}
}
标签:Autodesk,doc,建模,Revit,new,using,trans,建筑 来源: https://www.cnblogs.com/3118460692wwx/p/15196647.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。