// Создание арматурной сетки по параметрам обьекта RebarArea rebarArea public static AreaReinforcement Create(Models.RebarArea rebarArea, XYZ majorDirection) { if (null == rebarArea.RebarBarType) { throw new Exception(string.Format("{0} - не выбран типоразмер арматуры", rebarArea.AreaReinforcementType.Name)); } else { Document doc = rebarArea.Document; Element hostElement = rebarArea.Host; //IList<Curve> curveArray = GetCurveArray(rebarArea, majorDirection); IList <Curve> curveArray = GetCurveArray2(rebarArea, majorDirection); ElementId areaReinforcementTypeId = rebarArea.AreaReinforcementType.Id; ElementId rebarBarTypeId = rebarArea.RebarBarType.Id; ElementId rebarHookTypeId = ElementId.InvalidElementId; using (Transaction t = new Transaction(doc, "CreateAreaReinforcement")) { t.Start(); AreaReinforcement areaReinforcement = AreaReinforcement.Create( doc, hostElement, curveArray, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId); SetDirectionAndSpacing(areaReinforcement, rebarArea); t.Commit(); return(areaReinforcement); } } }
///<summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData revit, ref string message, Autodesk.Revit.DB.ElementSet elements) { Transaction trans = new Transaction(revit.Application.ActiveUIDocument.Document, "Revit.SDK.Samples.CreateComplexAreaRein"); trans.Start(); //initialize members m_revit = revit; m_currentDoc = revit.Application.ActiveUIDocument; m_data = new AreaReinData(revit.Application.ActiveUIDocument.Document); try { //check precondition and prepare necessary data to create AreaReinforcement. Reference refer = null; IList <Curve> curves = new List <Curve>(); Floor floor = InitFloor(ref refer, ref curves); //ask for user's input AreaReinData dataOnFloor = new AreaReinData(revit.Application.ActiveUIDocument.Document); CreateComplexAreaReinForm createForm = new CreateComplexAreaReinForm(dataOnFloor); if (createForm.ShowDialog() == DialogResult.OK) { //define the Major Direction of AreaReinforcement, //we get direction of first Line on the Floor as the Major Direction Line firstLine = (Line)(curves[0]); Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ( firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z); //create AreaReinforcement by AreaReinforcement.Create() function DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create; ElementId areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(revit.Application.ActiveUIDocument.Document); ElementId rebarBarTypeId = RebarBarType.CreateDefaultRebarBarType(revit.Application.ActiveUIDocument.Document); ElementId rebarHookTypeId = RebarHookType.CreateDefaultRebarHookType(revit.Application.ActiveUIDocument.Document); AreaReinforcement areaRein = AreaReinforcement.Create(revit.Application.ActiveUIDocument.Document, floor, curves, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId); //set AreaReinforcement and it's AreaReinforcementCurves parameters dataOnFloor.FillIn(areaRein); trans.Commit(); return(Autodesk.Revit.UI.Result.Succeeded); } } catch (ApplicationException appEx) { message = appEx.Message; trans.RollBack(); return(Autodesk.Revit.UI.Result.Failed); } catch { message = "Unknow Errors."; trans.RollBack(); return(Autodesk.Revit.UI.Result.Failed); } trans.RollBack(); return(Autodesk.Revit.UI.Result.Cancelled); }
/// <summary> /// create simple AreaReinforcement on vertical straight rectangular wall /// </summary> /// <param name="wall"></param> /// <returns>is successful</returns> private bool CreateAreaReinOnWall(Wall wall) { //make sure selected is basic wall if (wall.WallType.Kind != WallKind.Basic) { TaskDialog.Show("Revit", "Selected wall is not a basic wall."); return(false); } GeomHelper helper = new GeomHelper(); Reference refer = null; IList <Curve> curves = new List <Curve>(); //check whether wall is vertical rectangular and analytical model shape is line if (!helper.GetWallGeom(wall, ref refer, ref curves)) { ApplicationException appEx = new ApplicationException( "Your selection is not a structural straight rectangular wall."); throw appEx; } AreaReinDataOnWall dataOnWall = new AreaReinDataOnWall(); CreateSimpleAreaReinForm createForm = new CreateSimpleAreaReinForm(dataOnWall); //allow use select parameters to create if (createForm.ShowDialog() == DialogResult.OK) { DocCreator creator = m_revit.Application.ActiveUIDocument.Document.Create; //define the Major Direction of AreaReinforcement, //we get direction of first Line on the Floor as the Major Direction Line firstLine = (Line)(curves[0]); Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ( firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z); //create AreaReinforcement IList <Curve> curveList = new List <Curve>(); foreach (Curve curve in curves) { curveList.Add(curve); } ElementId areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(m_revit.Application.ActiveUIDocument.Document); ElementId rebarBarTypeId = RebarBarType.CreateDefaultRebarBarType(m_revit.Application.ActiveUIDocument.Document); ElementId rebarHookTypeId = RebarHookType.CreateDefaultRebarHookType(m_revit.Application.ActiveUIDocument.Document); AreaReinforcement areaRein = AreaReinforcement.Create(m_revit.Application.ActiveUIDocument.Document, wall, curveList, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId); dataOnWall.FillIn(areaRein); return(true); } return(false); }
private static AreaReinforcement Generate(Document doc, Wall wall, List <Curve> profile, bool isHorizontal, bool createInterior, bool createExterior, double offsetInt, double offsetExt, double interval, ElementId areaId, RebarBarType barType, string partition) { Debug.WriteLine("Start generating area rebar. Profile debug info: "); Debug.WriteLine(Util.ProfileDebugInfo(profile)); CurveUtils.SortCurvesContiguous(doc.Application.Create, profile, true); AreaReinforcement arein = AreaReinforcement.Create(doc, wall, profile, new XYZ(0, 0, 1), areaId, barType.Id, ElementId.InvalidElementId); if (isHorizontal) { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BACK_DIR_1).Set(0); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_FRONT_DIR_1).Set(0); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_2_GENERIC).Set(interval); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_2_GENERIC).Set(interval); if (!createInterior) { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BACK_DIR_2).Set(0); } if (!createExterior) { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_FRONT_DIR_2).Set(0); } } else { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_FRONT_DIR_2).Set(0); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BACK_DIR_2).Set(0); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_1_GENERIC).Set(interval); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_1_GENERIC).Set(interval); if (!createInterior) { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BACK_DIR_1).Set(0); } if (!createExterior) { arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_FRONT_DIR_1).Set(0); } } arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_INTERIOR_OFFSET).Set(offsetInt); arein.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_EXTERIOR_OFFSET).Set(offsetExt); arein.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set(partition); Debug.WriteLine("Rebar area created"); return(arein); }
/// <summary> /// create simple AreaReinforcement on horizontal floor /// </summary> /// <param name="floor"></param> /// <returns>is successful</returns> private bool CreateAreaReinOnFloor(Floor floor) { GeomHelper helper = new GeomHelper(); Reference refer = null; IList <Curve> curves = new List <Curve>(); //check whether floor is horizontal rectangular //and prepare necessary to create AreaReinforcement if (!helper.GetFloorGeom(floor, ref refer, ref curves)) { ApplicationException appEx = new ApplicationException( "Your selection is not a horizontal rectangular slab."); throw appEx; } AreaReinDataOnFloor dataOnFloor = new AreaReinDataOnFloor(); CreateSimpleAreaReinForm createForm = new CreateSimpleAreaReinForm(dataOnFloor); //allow use select parameters to create if (createForm.ShowDialog() == DialogResult.OK) { //define the Major Direction of AreaReinforcement, //we get direction of first Line on the Floor as the Major Direction Line firstLine = (Line)(curves[0]); Autodesk.Revit.DB.XYZ majorDirection = new Autodesk.Revit.DB.XYZ( firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z); //Create AreaReinforcement ElementId areaReinforcementTypeId = AreaReinforcementType.CreateDefaultAreaReinforcementType(m_revit.Application.ActiveUIDocument.Document); ElementId rebarBarTypeId = RebarBarType.CreateDefaultRebarBarType(m_revit.Application.ActiveUIDocument.Document); ElementId rebarHookTypeId = RebarHookType.CreateDefaultRebarHookType(m_revit.Application.ActiveUIDocument.Document); AreaReinforcement areaRein = AreaReinforcement.Create(m_revit.Application.ActiveUIDocument.Document, floor, curves, majorDirection, areaReinforcementTypeId, rebarBarTypeId, rebarHookTypeId); //set AreaReinforcement and it's AreaReinforcementCurves parameters dataOnFloor.FillIn(areaRein); return(true); } return(false); }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { #region App Constants and instances UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Selection sel = uidoc.Selection; #endregion IList <Reference> refs = sel.PickObjects(ObjectType.Element, "Please select an element to copy"); foreach (Reference r in refs) { Element element = doc.GetElement(r.ElementId); Debug.Print(element.ToString()); Debug.Print(element.Name); AnalyticalModel analytical = element.GetAnalyticalModel() as AnalyticalModel; if (null == analytical) { throw new Exception("Can't get AnalyticalModel from the selected wall"); } AreaReinforcement rein = null; IList <Curve> curves = analytical.GetCurves(AnalyticalCurveType.ActiveCurves); Line firstLine = (Line)(curves[0]); XYZ majorDirection = new XYZ( firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z ); ElementId defaultRebarBarTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType); ElementId defaultAreaReinforcementTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType); ElementId defaultHookTypeId = ElementId.InvalidElementId; using (Transaction trans = new Transaction(doc)) { trans.Start("Arming.."); FailureHandlingOptions options = trans.GetFailureHandlingOptions(); WarningSuppressor preproccessor = new WarningSuppressor(); options.SetClearAfterRollback(true); options.SetFailuresPreprocessor(preproccessor); trans.SetFailureHandlingOptions(options); rein = AreaReinforcement.Create(doc, element, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId); rein.AdditionalTopCoverOffset = 0; // any number <-- rein.AdditionalBottomCoverOffset = 0; // any number --> trans.SetFailureHandlingOptions(options); trans.Commit(); var suppressor = new WarningSuppressor(); } } return(Result.Succeeded); }
private AreaReinforcement FemDesignRebarToRevit(Document doc, FemDesignRebar femRebar) { string hostGuid = femRebar.hostGuid; double meterToFeet = UnitUtils.ConvertToInternalUnits(1, DisplayUnitType.DUT_METERS); double diameter = femRebar.diameter * meterToFeet; double spacing = femRebar.spacing * meterToFeet; XYZ majorDirection = new XYZ(femRebar.majorDirection.x, femRebar.majorDirection.y, femRebar.majorDirection.z); Dictionary<string, int> isActiveDirection = new Dictionary<string, int>() { {"x top", 0}, {"x bottom", 0}, {"y top", 0}, {"y bottom", 0} }; isActiveDirection[femRebar.direction + " " + femRebar.layer] = 1; Element rebarHost = null; FilteredElementCollector fec = new FilteredElementCollector(doc).OfClass(typeof(AnalyticalModelSurface)).WhereElementIsNotElementType(); foreach (AnalyticalModelSurface s in fec) { //if(e.get_Parameter(new Guid("7f162ddd-61bb-43f5-9394-846db8aef825")) == null) continue; //if(e.get_Parameter(new Guid("7f162ddd-61bb-43f5-9394-846db8aef825")).AsString() == hostGuid) { //if (s.LookupParameter("StruXML Guid") == null) continue; //if (s.LookupParameter("StruXML Guid").AsString() == hostGuid) //{ // rebarHost = doc.GetElement(s.GetElementId()); // break; //} // FEM-design guid is stored in Extensible Storage if (s.GetEntity(Schema.Lookup(new Guid("3a97c049-093e-46e6-b854-0e2323d640d0"))) == null) continue; Entity ent = s.GetEntity(Schema.Lookup(new Guid("3a97c049-093e-46e6-b854-0e2323d640d0"))); if (ent.Get<Guid>("Guid").ToString() == hostGuid) { rebarHost = doc.GetElement(s.GetElementId()); break; } } //The boundary curves of the area rebar system IList<Curve> curveList = new List<Curve>(); foreach (FemDesignLine femLine in femRebar.regionCurves) { XYZ p1 = new XYZ(femLine.startPoint.x * meterToFeet, femLine.startPoint.y * meterToFeet, femLine.startPoint.z * meterToFeet); XYZ p2 = new XYZ(femLine.endPoint.x * meterToFeet, femLine.endPoint.y * meterToFeet, femLine.endPoint.z * meterToFeet); Line l1 = Line.CreateBound(p1, p2); curveList.Add(l1); } ElementId rebarTypeId = new FilteredElementCollector(doc).OfClass(typeof(RebarBarType)).Cast<RebarBarType>().FirstOrDefault(x => Math.Abs(x.BarDiameter - diameter) < 0.0001).Id; ElementId areaReinfType = new FilteredElementCollector(doc).OfClass(typeof(AreaReinforcementType)).FirstOrDefault().Id; //Create area reinforcement AreaReinforcement areaReinf1 = AreaReinforcement.Create(doc, rebarHost, curveList, majorDirection, areaReinfType, rebarTypeId, ElementId.InvalidElementId); //set spacing areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_1_GENERIC).Set(spacing); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_2_GENERIC).Set(spacing); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_1_GENERIC).Set(spacing); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_2_GENERIC).Set(spacing); //Area reinforcement in Revit can have up to 4 layers and FEM-Design considers one at a time. Deactivating the three unused layers: areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(isActiveDirection["x top"]); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(isActiveDirection["x bottom"]); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(isActiveDirection["y top"]); areaReinf1.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(isActiveDirection["y bottom"]); //TODO: Cover //TODO: Option do remove area system, and correct spacing return areaReinf1; }
public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { #region App Constants and instances UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; Selection sel = uidoc.Selection; #endregion #region Core Functionality // Retrieve elements from database Reference pickedObj = sel.PickObject(ObjectType.Element, "Please select an element to copy."); if (pickedObj != null && pickedObj.ElementId != ElementId.InvalidElementId) { Element element = doc.GetElement(pickedObj.ElementId); Element wall = element as Element; Debug.Print(wall.Name); AnalyticalModel analytical = wall.GetAnalyticalModel() as AnalyticalModel; if (null == analytical) { throw new Exception("Can't get AnalyticalModel from the selected wall"); } #region Path Reinforcement Implementation /* * List<Curve> curves = new List<Curve>(); * LocationCurve location = wall.Location as LocationCurve; * XYZ start = location.Curve.GetEndPoint(0); * XYZ end = location.Curve.GetEndPoint(1); * curves.Add(Line.CreateBound(start, end)); * ElementId defaultRebarBarTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType); * ElementId defaultPathReinforcementTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.PathReinforcementType); * ElementId defaultHookTypeId = ElementId.InvalidElementId; * * using (Transaction trans = new Transaction(doc)) * { * trans.Start("Arming.."); * * * PathReinforcement rein = PathReinforcement.Create(doc, wall, curves, true, defaultPathReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId, defaultHookTypeId); * rein.AdditionalOffset = 10; * Console.WriteLine(rein.Parameters); * Console.WriteLine(); * Console.WriteLine(rein.ParametersMap); * Console.WriteLine(); * Console.WriteLine(rein.PrimaryBarOrientation); * Console.WriteLine(); * Console.WriteLine(rein.GetOrderedParameters()); * Console.WriteLine(); * Console.WriteLine(rein.GetSubelements()); * Console.WriteLine(); * * trans.Commit(); * } */ #endregion #region Area Reinforcement Implementation /* Area Reinforce */ AreaReinforcement rein = null; IList <Curve> curves = analytical.GetCurves(AnalyticalCurveType.ActiveCurves); Line firstLine = (Line)(curves[0]); XYZ majorDirection = new XYZ( firstLine.GetEndPoint(1).X - firstLine.GetEndPoint(0).X, firstLine.GetEndPoint(1).Y - firstLine.GetEndPoint(0).Y, firstLine.GetEndPoint(1).Z - firstLine.GetEndPoint(0).Z ); ElementId defaultRebarBarTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.RebarBarType); ElementId defaultAreaReinforcementTypeId = doc.GetDefaultElementTypeId(ElementTypeGroup.AreaReinforcementType); ElementId defaultHookTypeId = ElementId.InvalidElementId; using (Transaction trans = new Transaction(doc)) { trans.Start("Arming.."); rein = AreaReinforcement.Create(doc, wall, curves, majorDirection, defaultAreaReinforcementTypeId, defaultRebarBarTypeId, defaultHookTypeId); rein.AdditionalTopCoverOffset = 0; // any number <-- rein.AdditionalBottomCoverOffset = 0; // any number --> trans.Commit(); } /* * TaskDialog td = new TaskDialog("spacing?"); * td.MainInstruction = "spacing!"; * td.CommonButtons = TaskDialogCommonButtons.Yes; * td.AddCommandLink(TaskDialogCommandLinkId.CommandLink1, "yes"); * td.Show(); */ using (Transaction trans = new Transaction(doc)) { IList <Parameter> parameters = rein.GetOrderedParameters(); //14 20 26! 32! var i = 0; trans.Start("Spacing.."); foreach (Parameter p in parameters) { //Debug.Print(p.Definition.Name); //Debug.Print(p.Definition.ParameterType.ToString()); // Debug.Print(i.ToString()); //Debug.Print(""); if (i == 14) { Debug.Print(p.Definition.Name + " will be 500.0"); p.SetValueString("500.0"); //»нтервал в основном направлении, наружна¤ грань } if (i == 20) { Debug.Print(p.Definition.Name + " will be 500.0"); p.SetValueString("500.0"); //»нтервал во второстепенном направлении, наружна¤ грань } if (i == 26) { Debug.Print(p.Definition.Name + " will be 500.0"); p.SetValueString("500.0"); // »нтервал в основном направлении, внутренн¤¤ грань } if (i == 32) { Debug.Print(p.Definition.Name + " will be 500.0"); p.SetValueString("500.0"); //»нтервал во второстепенном направлении, внутренн¤¤ грань } i += 1; } trans.Commit(); } #endregion } #endregion #region StandartFiltering for Future /* * FilteredElementCollector col * = new FilteredElementCollector(doc) * .WhereElementIsNotElementType() * .OfCategory(BuiltInCategory.INVALID) * .OfClass(typeof(Wall)); * * * // Filtered element collector is iterable * * foreach (Element e in col) * { * Debug.Print(e.Name); * } */ #endregion return(Result.Succeeded); }
public static List <string> Generate(Document doc, Floor floor, RebarInfoFloor rif, ElementId areaTypeId) { Debug.WriteLine("RebarWorkerFloor is started"); List <string> messages = new List <string>(); MyRebarType mrt = new MyRebarType(doc, rif.rebarTypeName); if (mrt.isValid == false) { messages.Add("Не удалось получить тип стержня " + rif.rebarTypeName); } double interval = rif.interval; double topCoverUser = rif.topCover; double bottomCoverUser = rif.bottomCover; RebarCoverType coverTop = doc.GetElement(floor.get_Parameter(BuiltInParameter.CLEAR_COVER_TOP).AsElementId()) as RebarCoverType; RebarCoverType coverBottom = doc.GetElement(floor.get_Parameter(BuiltInParameter.CLEAR_COVER_BOTTOM).AsElementId()) as RebarCoverType; if (coverTop == null) { Debug.WriteLine("Top cover is null"); coverTop = coverBottom; } if (coverBottom == null) { Debug.WriteLine("Bottom cover is null"); coverBottom = coverTop; } Debug.WriteLine("Rebar cover types id, top: " + coverTop.Id.IntegerValue + ", bottom: " + coverBottom.Id.IntegerValue); #if R2017 || R2018 || R2019 || R2020 || R2021 double diam = mrt.bartype.BarDiameter; #else double diam = mrt.bartype.BarNominalDiameter; #endif double topCoverDir1 = topCoverUser - coverTop.CoverDistance; double topCoverDir2 = topCoverDir1 + diam; if (rif.turnTopBars) { topCoverDir1 += diam; topCoverDir2 -= diam; } double bottomCoverDir1 = bottomCoverUser - coverBottom.CoverDistance; double bottomCoverDir2 = bottomCoverDir1 + diam; if (rif.turnBottomBars) { bottomCoverDir1 += diam; bottomCoverDir2 -= diam; } List <Curve> curves = SupportGeometry.GetFloorOuterBoundary(floor); Debug.WriteLine("Boundary curves count: " + curves.Count); XYZ direction = new XYZ(1, 0, 0); if (rif.useDirection) { double angle = floor.SpanDirectionAngle; Transform rotateTransform = Transform.CreateRotationAtPoint(new XYZ(0, 0, 1), angle, new XYZ(0, 0, 0)); Line horizontal = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(1, 0, 0)); Curve rotatedCurve = horizontal.CreateTransformed(rotateTransform); direction = rotatedCurve.GetEndPoint(1); } Debug.WriteLine("Direction: " + direction.ToString()); AreaReinforcement arTopX = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(1); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_1_GENERIC).Set(interval); arTopX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_TOP_OFFSET).Set(topCoverDir1); arTopX.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("верх X фон"); Debug.WriteLine("Top X is created"); AreaReinforcement arTopY = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(1); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_TOP_DIR_2_GENERIC).Set(interval); arTopY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_TOP_OFFSET).Set(topCoverDir2); arTopY.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("верх Y фон"); Debug.WriteLine("Top Y is created"); AreaReinforcement arBottomX = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(1); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(0); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_1_GENERIC).Set(interval); arBottomX.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_BOTTOM_OFFSET).Set(bottomCoverDir1); arBottomX.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("низ X фон"); Debug.WriteLine("Bottom X is created"); AreaReinforcement arBottomY = AreaReinforcement .Create(doc, floor, curves, direction, areaTypeId, mrt.bartype.Id, ElementId.InvalidElementId); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_1_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_TOP_DIR_2_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_1_GENERIC).Set(0); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ACTIVE_BOTTOM_DIR_2_GENERIC).Set(1); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_SPACING_BOTTOM_DIR_2_GENERIC).Set(interval); arBottomY.get_Parameter(BuiltInParameter.REBAR_SYSTEM_ADDL_BOTTOM_OFFSET).Set(bottomCoverDir2); arBottomY.get_Parameter(BuiltInParameter.NUMBER_PARTITION_PARAM).Set("низ Y фон"); Debug.WriteLine("Bottom Y is created"); return(messages); }