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

完善主體資料,免費(fèi)贈(zèng)送VIP會(huì)員!
* 主體類型
* 企業(yè)名稱
* 信用代碼
* 所在行業(yè)
* 企業(yè)規(guī)模
* 所在職位
* 姓名
* 所在行業(yè)
* 學(xué)歷
* 工作性質(zhì)
請(qǐng)先選擇行業(yè)
您還可以選擇以下福利:
行業(yè)福利,領(lǐng)完即止!

下載app免費(fèi)領(lǐng)取會(huì)員

NULL

ad.jpg

二次開發(fā)教程:Revit開發(fā)樓梯創(chuàng)建

發(fā)布于:2019-08-23 17:15:17

網(wǎng)友投稿

更多

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;

        }

    }

}


本文版權(quán)歸腿腿教學(xué)網(wǎng)及原創(chuàng)作者所有,未經(jīng)授權(quán),謝絕轉(zhuǎn)載。

未標(biāo)題-1.jpg

上一篇:二次開發(fā)教程:Revit開發(fā)將WPF的Ower設(shè)置為Revit窗體

下一篇:二次開發(fā)教程:Revit開發(fā)通過API 創(chuàng)建族

主站蜘蛛池模板: 毛片大全| 久久亚洲国产成人亚 | 欧美性大片免费 | 91久久国产露脸精品免费 | 国产狂喷白浆在线观看视频 | 亚洲免费一区二区 | 成年人污视频 | 欧美亚洲日本一区二区三区浪人 | 国产精品久久永久免费 | 国产精品偷伦视频免费观看了 | 久久婷婷色 | 99久久中文字幕伊人情人 | 日本精品视频一区二区三区 | 五月婷婷在线视频 | 欧美一级第一免费高清 | 另类日韩 | 成人在线不卡视频 | 欧美黑人性猛交╳xx╳动态图 | 成年人网站在线观看视频 | 香蕉网站狼人久久五月亭亭 | 国产一区二区fc2ppv在线播放 | 亚洲欧洲日产国码久在线观看 | 国产精品午夜国产小视频 | 成年人在线免费网站 | 黑人操亚洲女人视频 | 一级毛片一级毛片一级毛片一级毛片 | 国产精品你懂的在线播放调教 | 美女被拍拍拍拍拍拍拍拍 | 97视频精品| 青青青国产在线观看免费 | 国产aav| 一级国产精品一级国产精品片 | 欧美国产小视频 | 久久国产免费一区二区三区 | 一级片 720p| 欧美在线乱妇一级毛片 | 春水堂在线| 欧美日韩精品在线观看 | 视频二区 调教中字 知名国产 | 中文字幕午夜乱理片11111 | 日本成aⅴ人片日本伦 |