繁体   English   中英

C#Revit API在Revit中创建面板

[英]C# revit api to Create panels in Revit

我是revit api的新手。 我想在revit空项目中创建一个面板。 我可以创建墙。 我想知道如何在墙上添加面板数据(螺柱,面板名称,开口等)。 我也是建筑术语的新手。

这是我的代码:

        UIApplication uiapp = commandData.Application;
        UIDocument uidoc = uiapp.ActiveUIDocument;
        Document doc = uiapp.ActiveUIDocument.Document;

        WallType w = getWallType(doc);

        RetrievingLevels(doc);

        Level newLevel = CreateLevels(doc);
        if(newLevel != null)
        {
            IList<Curve> curves = new List<Curve>();

            XYZ first = new XYZ(0, 0, 0);
            XYZ second = new XYZ(20, 0, 0);
            XYZ third = new XYZ(20, 0, 15);
            XYZ fourth = new XYZ(0, 0, 15);

            curves.Add(Line.CreateBound(first, second));
            curves.Add(Line.CreateBound(second, third));
            curves.Add(Line.CreateBound(third, fourth));
            curves.Add(Line.CreateBound(fourth, first));

            //Line l = Line.CreateBound(a1, b1);

            Transaction trans = new Transaction(doc);
            try
            {
                trans.Start("create walls");
                Wall.Create(doc, curves, w.Id,newLevel.Id,  true);
                trans.Commit();
                return Result.Succeeded;
            }
            catch (Exception ex)
            {
                trans.Dispose();
                return Result.Failed;
            }
        }
        return Result.Failed;
        //IList<Curve> curves = new List<Curve>();
    }

    private WallType getWallType(Document doc)
    {
        FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(WallType));
        IList<Element> WallTypes = collector.ToElements();
        return WallTypes.First() as WallType;
    }

    private Level CreateLevels(Document document)
    {
        double elevation = 33.0;

        Transaction t = new Transaction(document);
        // Begin to create a level
        t.Start("create Level");
        try
        {
            Level level = Level.Create(document, elevation);



            if (null == level)
            {
                throw new Exception("Create a new level failed.");
            }
            // Change the level name
            level.Name = "New level";
            t.Commit();
            return level;
        }
        catch (Exception e)
        {

        }
        return null;
    }

另外,请从可以从何处了解有关revit APIS的建议。

好吧,在您尝试对其进行编程之前,从用户角度了解Revit和BIM将大有帮助。 在开始之前 然后,您应该研究Revit API的其余入门资料

接下来,您应该学习如何进行研究以找到适合自己的Revit API解决方案

始终绝对要做的第一步就是安装RevitLookup交互式Revit BIM数据库浏览工具,以查看和导航元素属性和关系。

将其放置在适当的位置后,您可以首先在用户界面中手动创建希望以编程方式生成的模型。 使用RevitLookup和其他工具(例如BipChecker和元素列表器)进行探索,以发现手动流程及其属性和关系生成了哪种元素。

一旦了解了所有内容,就可以使用Revit API以编程方式生成相同的模型。

祝好运并玩得开心点!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM