private void Cut(WallIntersectionData data, AngleCalculator calculator, WallExtrusion extrusion) { using (TransactionGroup tranGr = new TransactionGroup(_doc)) { tranGr.Start("wall penetration one element"); var _roundOpen = _doc.GetFamilySymbol("Отверстие_Поворотное", "Отверстие"); var _rectOpen = _doc.GetFamilySymbol("ОтверстиеПрямоугольное_Поворотное", "Отверстие"); using (Transaction tran = new Transaction(_doc)) { tran.Start("Creating wall penetration"); FamilyInstance fi = _doc.Create.NewFamilyInstance(data.WallSideFaceRef, calculator.LocationPoint, new XYZ(1, 0, 0), _rectOpen); tran.Commit(); tran.Start("SetPar"); double offset = UnitUtils.ConvertToInternalUnits(0, DisplayUnitType.DUT_MILLIMETERS); fi.LookupParameter("ШиринаОтверстия").Set(extrusion.Width + offset); fi.LookupParameter("ВысотаОтверстия").Set(extrusion.Height + offset); fi.LookupParameter("УголВертикальногоПоворота").Set(calculator.VerticalAngle); fi.LookupParameter("УголГоризонтальногоПоворота").Set(calculator.HorizontalAngle); tran.Commit(); } tranGr.Assimilate(); } }
private void FamilyInstanceIntersection(Wall wall) { var intersector = GetIntersectingElement(); WallExtrusion extrusion = new WallExtrusion(intersector, wall); WallIntersectionData data = new WallIntersectionData(wall, intersector); AngleCalculator calculator = new AngleCalculator(data); Cut(data, calculator, extrusion); }
private void CutBasicRectangular(Transaction trans, Wall wall, Element intersector, FamilySymbol rectOpen) { WallExtrusion extrusion = new WallExtrusion(intersector, wall); Curve extrusionCurve = extrusion.LocationCurve; trans.Start("Creating extrusion"); var fi = _doc.Create.NewFamilyInstance(extrusionCurve, rectOpen, _doc.GetElement(intersector.LevelId) as Level, StructuralType.Beam); InstanceVoidCutUtils.AddInstanceVoidCut(_doc, wall, fi); fi.get_Parameter(BuiltInParameter.YZ_JUSTIFICATION).Set(0); fi.get_Parameter(BuiltInParameter.Z_JUSTIFICATION).Set(1); fi.get_Parameter(BuiltInParameter.Y_JUSTIFICATION).Set(1); fi.LookupParameter("w").Set(extrusion.Width); fi.LookupParameter("h").Set(extrusion.Height); trans.Commit(); trans.Start("Setting appropriate extrusion dimensions"); SetAppropriateDimensions(intersector, fi, extrusion); trans.Commit(); }
private static void SetAppropriateDimensions(Element intersector, Element element, WallExtrusion extrusion) { BoundingBoxXYZ extrusionBb = element.get_BoundingBox(null); var interBb = intersector.get_BoundingBox(null); double offset = UnitUtils.ConvertToInternalUnits(100, DisplayUnitType.DUT_MILLIMETERS); if (!extrusionBb.Min.IsAlmostEqualTo(interBb.Min)) { element.LookupParameter("h").Set(extrusion.Width + offset); element.LookupParameter("w").Set(extrusion.Height + offset); } else { element.LookupParameter("h").Set(extrusion.Height + offset); element.LookupParameter("w").Set(extrusion.Width + offset); } }