首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用Revit SDK示例创建revit-addon?

如何使用Revit SDK示例创建revit-addon?
EN

Stack Overflow用户
提问于 2019-03-24 01:11:16
回答 1查看 251关注 0票数 0

我正在学习为revit创建加载项,并尝试使用下面的示例创建。所以我从revit api.chm得到了代码,问题是我如何使用它作为revit插件?非常感谢。

代码语言:javascript
复制
namespace somenamespace
{
    [TransactionAttribute(TransactionMode.Manual)]
    public class CreateFloor : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //Get UIDocument
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            //Get Document
            Autodesk.Revit.DB.Document doc = uidoc.Document;

            Floor CreateFloor(UIApplication application, Level level)
            {
                // Get the Revit document
                Autodesk.Revit.DB.Document document = application.ActiveUIDocument.Document;

                // Get the application creation object
                Autodesk.Revit.Creation.Application appCreation = application.Application.Create;

                // Get a floor type for floor creation
                FilteredElementCollector collector = new FilteredElementCollector(document);
                collector.OfClass(typeof(FloorType));
                FloorType floorType = collector.FirstElement() as FloorType;

                // Build a floor profile for the floor creation
                XYZ first = new XYZ(0, 0, 0);
                XYZ second = new XYZ(20, 0, 0);
                XYZ third = new XYZ(20, 15, 0);
                XYZ fourth = new XYZ(0, 15, 0);
                CurveArray profile = new CurveArray();
                profile.Append(Line.CreateBound(first, second));
                profile.Append(Line.CreateBound(second, third));
                profile.Append(Line.CreateBound(third, fourth));
                profile.Append(Line.CreateBound(fourth, first));

                // The normal vector (0,0,1) that must be perpendicular to the profile.
                XYZ normal = XYZ.BasisZ;

                return document.Create.NewFloor(profile, floorType, level, true, normal);
            }

            return Result.Succeeded;

        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-25 14:46:59

最简单的入门方法是使用Revit API getting started material。这将引导您逐步完成整个过程,包括视频教程。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55316306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档