Revit API:用IFC寻找失落的坡道 IFCLegacyStairOrRamp

前言

Ramp 没有直接的 Revit API 可以用。不过最近研究了一下 IFC,发现倒是有另外一个途径。不过,你想把这些内容从 Autodesk 的开源项目中分离出来,估计需要花点功夫。https://github.com/Autodesk/revit-ifc

坡道 Revit API

命名空间:Autodesk.Revit.DB.IFC
类名:ExporterIFCUtils

IFCLegacyStairOrRamp legacyStairOrRamp = ExporterIFCUtils.GetLegacyStairOrRampComponents(exporterIFC, legacyStair);

找到坡道的 Walk Line

Revit API:IFCLegacyStairOrRamp::GetWalkLines

代码出处:这里

      /// <summary>
      /// Creates walk line representations from stair walk lines.
      /// </summary>
      /// <param name="exporterIFC">The exporter.</param>
      /// <param name="legacyStair">The stair.</param>
      /// <param name="legacyStairElem">The stair element.</param>
      /// <returns>The walk line representation handles.  Some of them may be null.</returns>
      static IList<IFCAnyHandle> CreateWalkLineReps(ExporterIFC exporterIFC, IFCLegacyStairOrRamp legacyStair, Element legacyStairElem)
      {
         IList<IFCAnyHandle> walkLineReps = new List<IFCAnyHandle>();
         IFCAnyHandle contextOfItemsWalkLine = exporterIFC.Get3DContextHandle("Axis");

         ElementId cateId = CategoryUtil.GetSafeCategoryId(legacyStairElem);
         Transform lcs = Transform.Identity;
         XYZ projDir = XYZ.BasisZ;

         IList<IList<Curve>> curvesArr = legacyStair.GetWalkLines();
         foreach (IList<Curve> curves in curvesArr)
         {
            IFCAnyHandle curve = GeometryUtil.CreateIFCCurveFromCurves(exporterIFC, curves, lcs, projDir);
            if (!IFCAnyHandleUtil.IsNullOrHasNoValue(curve))
            {
               HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
               bodyItems.Add(curve);
               walkLineReps.Add(RepresentationUtil.CreateShapeRepresentation(exporterIFC, legacyStairElem, cateId,
                   contextOfItemsWalkLine, "Axis", "Curve2D", bodyItems));
            }
            else
               walkLineReps.Add(null);
         }
         return walkLineReps;
      }

找到坡道的边界线

Revit API:IFCLegacyStairOrRamp::GetBoundaryLines

代码出处:这里

      /// <summary>
      /// Creates boundary line representations from stair boundary lines.
      /// </summary>
      /// <param name="exporterIFC">The exporter.</param>
      /// <param name="legacyStair">The stair.</param>
      /// <param name="legacyStairElem">The stair element.</param>
      /// <returns>Boundary line representations.</returns>
      static IList<IFCAnyHandle> CreateBoundaryLineReps(ExporterIFC exporterIFC, IFCLegacyStairOrRamp legacyStair, Element legacyStairElem)
      {
         IFCAnyHandle contextOfItemsBoundary = exporterIFC.Get3DContextHandle("FootPrint");

         IList<IFCAnyHandle> boundaryLineReps = new List<IFCAnyHandle>();

         IFCFile file = exporterIFC.GetFile();
         ElementId cateId = CategoryUtil.GetSafeCategoryId(legacyStairElem);

         HashSet<IFCAnyHandle> curveSet = new HashSet<IFCAnyHandle>();
         IList<CurveLoop> boundaryLines = legacyStair.GetBoundaryLines();
         foreach (CurveLoop curveLoop in boundaryLines)
         {
            Transform lcs = Transform.Identity;
            foreach (Curve curve in curveLoop)
            {
               if (ExporterCacheManager.ExportOptionsCache.ExportAs4ReferenceView)
               {
                  IFCAnyHandle curveHnd = GeometryUtil.CreatePolyCurveFromCurve(exporterIFC, curve);
                  //IList<int> segmentIndex = null;
                  //IList<IList<double>> pointList = GeometryUtil.PointListFromCurve(exporterIFC, curve, null, null, out segmentIndex);

                   For now because of no support in creating IfcLineIndex and IfcArcIndex yet, it is set to null
                  IList<IList<int>> segmentIndexList = new List<IList<int>>();
                  segmentIndexList.Add(segmentIndex);
                  //IList<IList<int>> segmentIndexList = null;

                  //IFCAnyHandle pointListHnd = IFCInstanceExporter.CreateCartesianPointList3D(file, pointList);
                  //IFCAnyHandle curveHnd = IFCInstanceExporter.CreateIndexedPolyCurve(file, pointListHnd, segmentIndexList, false);
                  if (!IFCAnyHandleUtil.IsNullOrHasNoValue(curveHnd))
                     curveSet.Add(curveHnd);
               }
               else
               {
                  IFCGeometryInfo info = IFCGeometryInfo.CreateCurveGeometryInfo(exporterIFC, lcs, XYZ.BasisZ, false);
                  ExporterIFCUtils.CollectGeometryInfo(exporterIFC, info, curve, XYZ.Zero, false);
                  IList<IFCAnyHandle> curves = info.GetCurves();

                  if (curves.Count == 1 && !IFCAnyHandleUtil.IsNullOrHasNoValue(curves[0]))
                  {
                     curveSet.Add(curves[0]);
                  }
               }
            }
            IFCAnyHandle curveRepresentationItem = IFCInstanceExporter.CreateGeometricSet(file, curveSet);
            HashSet<IFCAnyHandle> bodyItems = new HashSet<IFCAnyHandle>();
            bodyItems.Add(curveRepresentationItem);
            IFCAnyHandle boundaryLineRep = RepresentationUtil.CreateGeometricSetRep(exporterIFC, legacyStairElem, cateId, "FootPrint",
               contextOfItemsBoundary, bodyItems);
            boundaryLineReps.Add(boundaryLineRep);
         }
         return boundaryLineReps;
      }

总结

IFC 作为一个行业标准,各个厂商都会有自己的实现,并且这些实现对基本的元素都要支持。从这个思路出发,可以发现一些隐藏的功能。

BIM Master is a unique and free application designed to easily and fast view BIM models (revit, nwd, ifc, 3ds Max, XSTEEL of tekla). BIM Master also allows users to open, view, create, navigate, store and share 2D DWG (AutoCAD, ZWCAD, DXF, DWF) drawings, office documents, pdf files and images across web, windows and mobile devices, anytime anywhere. Certification and Awards: •BIM Master ranks eighth in the list of 2016 Top Ten New App authorized by an authoritative media-Internet Weekly. Major Features:Fast open popular formats: •With BIM Master, users can open and view large BIM models in seconds•Use intuitive gesture zoom, pan and orbit to easily navigateRevit models fast browsing: •BIM models can rotate in varieties of modes •Models can be viewed in the full-screen mode •With BIM models, BIM models can be moved, scaled, cut, measured, reset and saved as images •Users can view components and attribute information of BIM modelsCentralized management:• BIM Master provides users free Cloud storage•By uploading files through web, files are saved in your Cloud storage, you can access files from mobile devices •Once you make any changes on your project files, upload it so that your team members can see, also all of you can check the original versions Files securely sharing: •When sharing projects files by e-mail with team members, you can set password and expiry time for every file. Also, you can directly share a folder.•Cache files are also encrypted to protect source files. Contact Us:E-mail: app@ejianzhu.com We appreciate your precious advice, please feel free to contact us with any questions.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

极客BIM工作室

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值