91手机视频在线-91手机视频在线观看-91手机在线-91手机在线播放-91手机在线观看

完善主體資料,免費贈送VIP會員!
* 主體類型
* 企業名稱
* 信用代碼
* 所在行業
* 企業規模
* 所在職位
* 姓名
* 所在行業
* 學歷
* 工作性質
請先選擇行業
您還可以選擇以下福利:
行業福利,領完即止!

下載app免費領取會員

NULL

ad.jpg

二次開發教程:Revit開發樓梯創建

發布于:2019-08-23 17:15:17

網友投稿

更多

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Autodesk.Revit.Attributes;

using Autodesk.Revit.DB;

using Autodesk.Revit.UI;

using Autodesk.Revit.DB.Architecture;



namespace CreateStairs

{

    [Transaction(TransactionMode.Manual)]

    public class Class1:IExternalCommand

    {

        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)

        {

            Document doc = commandData.Application.ActiveUIDocument.Document;

            Transaction trans = new Transaction(doc,"new level");

            trans.Start();

            Level blvl = Level.Create(doc, 0);

            Level tlvl = Level.Create(doc, 2);

            trans.Commit();

            CreateStairs(doc, blvl, tlvl);

            return Result.Succeeded;

        }

        private ElementId CreateStairs(Document document, Level levelBottom, Level levelTop)

        {

            ElementId newStairsId = null;

            using (StairsEditScope newStairsScope = new StairsEditScope(document, "New Stairs"))

            {

                newStairsId = newStairsScope.Start(levelBottom.Id, levelTop.Id);

                using (Transaction stairsTrans = new Transaction(document, "Add Runs and Landings to Stairs"))

                {

                    stairsTrans.Start();


                    // Create a sketched run for the stairs

                    IList<Curve> bdryCurves = new List<Curve>();

                    IList<Curve> riserCurves = new List<Curve>();

                    IList<Curve> pathCurves = new List<Curve>();

                    XYZ pnt1 = new XYZ(0, 0, 0);

                    XYZ pnt2 = new XYZ(15, 0, 0);

                    XYZ pnt3 = new XYZ(0, 10, 0);

                    XYZ pnt4 = new XYZ(15, 10, 0);

                    // boundaries       

                    bdryCurves.Add(Line.CreateBound(pnt1, pnt2));

                    bdryCurves.Add(Line.CreateBound(pnt3, pnt4));

                    // riser curves

                    const int riserNum = 20;

                    for (int ii = 0; ii <= riserNum; ii++)

                    {

                        XYZ end0 = (pnt1 + pnt2) * ii / (double)riserNum;

                        XYZ end1 = (pnt3 + pnt4) * ii / (double)riserNum;

                        XYZ end2 = new XYZ(end1.X, 10, 0);

                        riserCurves.Add(Line.CreateBound(end0, end2));

                    }


                    //stairs path curves

                    XYZ pathEnd0 = (pnt1 + pnt3) / 2.0;

                    XYZ pathEnd1 = (pnt2 + pnt4) / 2.0;

                    pathCurves.Add(Line.CreateBound(pathEnd0, pathEnd1));

                    StairsRun newRun1 = StairsRun.CreateSketchedRun(document, newStairsId, levelBottom.Elevation, bdryCurves, riserCurves, pathCurves);

                    // Add a straight run

                    Line locationLine = Line.CreateBound(new XYZ(20, -5, newRun1.TopElevation), new XYZ(35, -5, newRun1.TopElevation));

                    StairsRun newRun2 = StairsRun.CreateStraightRun(document, newStairsId, locationLine, StairsRunJustification.Center);

                    newRun2.ActualRunWidth = 10;

                    // Add a landing between the runs

                    CurveLoop landingLoop = new CurveLoop();

                    XYZ p1 = new XYZ(15, 10, 0);

                    XYZ p2 = new XYZ(20, 10, 0);

                    XYZ p3 = new XYZ(20, -10, 0);

                    XYZ p4 = new XYZ(15, -10, 0);

                    Line curve_1 = Line.CreateBound(p1, p2);

                    Line curve_2 = Line.CreateBound(p2, p3);

                    Line curve_3 = Line.CreateBound(p3, p4);

                    Line curve_4 = Line.CreateBound(p4, p1);

                    landingLoop.Append(curve_1);

                    landingLoop.Append(curve_2);

                    landingLoop.Append(curve_3);

                    landingLoop.Append(curve_4);

                    StairsLanding newLanding = StairsLanding.CreateSketchedLanding(document, newStairsId, landingLoop, newRun1.TopElevation);

                    stairsTrans.Commit();

                }

                // A failure preprocessor is to handle possible failures during the edit mode commitment process.

                newStairsScope.Commit(new FailuresPreprocessor());//new StairsFailurePreprocessor());

            }

            return newStairsId;

        }


    }

    public class FailuresPreprocessor : IFailuresPreprocessor

    {

        public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)

        {

            IList<FailureMessageAccessor> listFma = failuresAccessor.GetFailureMessages();

            if (listFma.Count == 0)

                return FailureProcessingResult.Continue;

            foreach (FailureMessageAccessor fma in listFma)

            {

                if (fma.GetSeverity() == FailureSeverity.Error)

                {

                    if (fma.HasResolutions())

                        failuresAccessor.ResolveFailure(fma);

                }

                if (fma.GetSeverity() == FailureSeverity.Warning)

                {

                    failuresAccessor.DeleteWarning(fma);

                }

            }

            return FailureProcessingResult.ProceedWithCommit;

        }

    }

}


本文版權歸腿腿教學網及原創作者所有,未經授權,謝絕轉載。

未標題-1.jpg

上一篇:二次開發教程:Revit開發將WPF的Ower設置為Revit窗體

下一篇:二次開發教程:Revit開發通過API 創建族

主站蜘蛛池模板: 亚洲国产精品自在在线观看 | 欧美黄免在线播放 | 黄色工厂在线播放 | 成 人 黄 色 大 片全部 | 久久久久国产精品免费 | 女人午夜色又刺激黄的视频免费 | 欧美精品午夜毛片免费看 | 小草免费在线视频 | 国产精品久久久久亚洲 | 欧美综合视频在线观看 | 成人黄色小视频在线观看 | 美女福利视频一区 | 成人在线观看国产 | 成年美女毛片黄网站色奶头大全 | 久热操 | 九九视频高清视频免费观看 | 中文字幕日韩欧美 | 在线色图 | 日韩成人高清 | 91视频 88av| 在线观看国产视频 | 欧美最黄视频 | 亚洲不卡 | 国产毛片a精品毛 | 中国特级黄色毛片 | 欧美日韩亚洲精品一区二区三区 | 在线亚洲一区 | 亚洲一区无码中文字幕 | 日韩丝袜在线 | 免费看黄的视频 | 美国美女一级片 | 国产刚刚发育被强j在线播放 | 欧美一区二区三区在线观看 | 国内精品久久久久影院薰衣草 | 麻豆麻豆必出精品入口 | 色图综合网 | 日韩视频高清 | 可以看的黄色网址 | 99免费视频 | 美国一级做a一级爱视频 | 久久久9999久久精品小说 |