Uy Võ Lê 1838 Uy Võ Lê

Link download thư viện LRE: https://leuyvo.com/getLRE

  • LRE bản 1.0.2.
  • Chọn phiên bản Revit bạn sử dụng tương ứng, hiện tại chỉ có Revit 2018. Tạm thời bạn có thể sử dụng bản 2018 này trên cả Revit 2019 và 2020.
  • Giải nén file .zip bạn có file *.dll, Add Reference vào dự án của bạn và thử sử dụng.

Code mẫu tham khảo

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

            Reference reference = uidoc.Selection.PickObject(ObjectType.Element);
            Element element = doc.GetElement(reference);

            BoundingBoxIntersectsFilter boundingBoxIntersectsFilter = element.GetBoundingboxFilter(doc.ActiveView);

            IEnumerable<FamilyInstance> beams = new FilteredElementCollector(doc)
                .OfClass(typeof(FamilyInstance))
                .OfCategory(BuiltInCategory.OST_StructuralFraming)
                .WherePasses(boundingBoxIntersectsFilter)
                .Cast<FamilyInstance>();

            if(beams == null || beams.Count() == 0)
            {
                MessageBox.Show("Không tiếp xúc với dầm nào!");
                return Result.Succeeded;
            }

            double intersectionArea = 0;
            foreach(FamilyInstance familyInstance in beams)
            {
                double intersectionAreaTemp = element.GetIntersectionAreaWith(familyInstance);
                if (intersectionAreaTemp < 0) continue;
                intersectionArea += intersectionAreaTemp;
            }

            intersectionArea = intersectionArea * .3048 * .3048;
            //MessageBox.Show(intersectionArea.ToString() + " m2");

            Solid solidElement = element.GetSolids().JoinAllSolid().Result;

            double formworkArea0 = 0;
            foreach(Face face in solidElement.Faces)
            {
                PlanarFace planarFace = face as PlanarFace;
                if(Math.Abs(planarFace.FaceNormal.DotProduct(XYZ.BasisZ)) < 1e-9)
                {
                    formworkArea0 += planarFace.Area;
                }
            }

            formworkArea0 = formworkArea0 * .3048 * .3048;
            MessageBox.Show(formworkArea0.ToString() + " m2");

            MessageBox.Show((formworkArea0 - intersectionArea).ToString() + " m2");

            return Result.Succeeded;

Nội dụng buổi tiếp theo chúng ta sẽ tìm hiểu cách tạo parameter trong Revit.


Reply 0