protected override void SolveInstance(IGH_DataAccess DA) { int id = 0; RebarShape rebarShape = null; int count = 0; Curve curve = null; double angle = 0.0; DA.GetData(0, ref id); DA.GetData(1, ref rebarShape); DA.GetData(2, ref curve); DA.GetData(3, ref count); if (!DA.GetData(4, ref angle)) { return; } if (_useDegrees) { angle = RhinoMath.ToRadians(angle); } RebarGroup rebarGroup = new RebarGroup(id, new RebarSpacing(rebarShape, count, curve, angle)); DA.SetData(0, rebarGroup); DA.SetDataList(1, rebarGroup.RebarGroupMesh); DA.SetDataList(2, rebarGroup.RebarGroupCurves); }
protected override void SolveInstance(IGH_DataAccess DA) { Plane insertPlane = Plane.Unset; double height = 0.0; double width = 0.0; int hooksType = 0; double hookLength = 0.0; RebarProperties properties = null; BendingRoller bendingRoller = null; DA.GetData(0, ref insertPlane); DA.GetData(1, ref height); DA.GetData(2, ref width); DA.GetData(3, ref hooksType); DA.GetData(4, ref hookLength); DA.GetData(5, ref properties); DA.GetData(6, ref bendingRoller); RebarShape rebarShape = new RebarShape(properties); rebarShape.BuildStirrupShape(insertPlane, height, width, bendingRoller, hooksType, hookLength); DA.SetData(0, rebarShape); DA.SetData(1, rebarShape.RebarMesh); }
public void testRebarSys() { UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; // Load rebar Shape FilteredElementCollector fecRebarShap = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); IEnumerable <RebarShape> iterRebarBarShapes = fecRebarShap.Cast <RebarShape>(); RebarShape myRebarShape = iterRebarBarShapes.FirstOrDefault <RebarShape>(); ElementId myRebarShapeId = myRebarShape.Id; // Select first Element (ex RebarSystem) Reference myRefRebar = uiDoc.Selection.PickObject(ObjectType.Element, "Pick a Rebar..."); Element mySysRebar = doc.GetElement(myRefRebar); RebarInSystem myRebarInSys = mySysRebar as RebarInSystem; List <Subelement> myList = myRebarInSys.GetSubelements() as List <Subelement>; TaskDialog.Show("abc", "xyz" + myList.Count); }
/// <summary> /// Add stirrup bars into corbel with given options. /// </summary> /// <param name="options">Options for Rebar Creation</param> private void PlaceStirrupBars(CorbelReinforcementOptions options) { var filter = new FilteredElementCollector(options.RevitDoc) .OfClass(typeof(RebarShape)).ToElements().Cast <RebarShape>() .Where <RebarShape>(shape => shape.RebarStyle == RebarStyle.StirrupTie); RebarShape stirrupShape = null; foreach (RebarShape shape in filter) { if (shape.Name.Equals("T1")) { stirrupShape = shape; break; } } Trapezoid profileCopy = m_profile.Clone(); profileCopy.OffsetTop(-m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter); profileCopy.OffsetLeft(-m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter); profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance - 0.5 * options.StirrupBarType.BarDiameter); profileCopy.OffsetRight(-m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter); XYZ extruDir = (m_extrusionLine.GetEndPoint(1) - m_extrusionLine.GetEndPoint(0)).Normalize(); double offset = m_corbelCoverDistance + 0.5 * options.StirrupBarType.BarDiameter; XYZ origin = profileCopy.Vertical.GetEndPoint(0) + extruDir * offset; XYZ xAxis = extruDir; XYZ yAxis = (profileCopy.Vertical.GetEndPoint(1) - profileCopy.Vertical.GetEndPoint(0)).Normalize(); Rebar stirrupBars = Rebar.CreateFromRebarShape(options.RevitDoc, stirrupShape, options.StirrupBarType, m_corbel, origin, xAxis, yAxis); double xLength = m_extrusionLine.Length - 2 * offset; double yLength = profileCopy.Vertical.Length; stirrupBars.SetLayoutAsFixedNumber(options.StirrupBarCount + 1, profileCopy.Top.Length, false, false, true); stirrupBars.ScaleToBox(origin, xAxis * xLength, yAxis * yLength); ShowRebar3d(stirrupBars); double space = profileCopy.Top.Length / options.StirrupBarCount; double step = space * m_profile.Vertical.Length / (m_profile.Bottom.Length - m_profile.Top.Length); XYZ dirTop = (m_profile.Top.GetEndPoint(0) - m_profile.Top.GetEndPoint(1)).Normalize(); XYZ dirVertical = yAxis; XYZ deltaStep = dirTop * space + dirVertical * step; origin = profileCopy.Top.GetEndPoint(0) + extruDir * offset; int count = (int)((m_profile.Vertical.Length - m_corbelCoverDistance - 0.5 * options.StirrupBarType.BarDiameter) / step); for (int i = 1; i <= count; i++) { origin += deltaStep; Rebar stirrupBars2 = Rebar.CreateFromRebarShape(options.RevitDoc, stirrupShape, options.StirrupBarType, m_corbel, origin, xAxis, yAxis); stirrupBars2.ScaleToBox(origin, xAxis * xLength, yAxis * (yLength - i * step)); ShowRebar3d(stirrupBars2); } }
// Token: 0x060001D5 RID: 469 RVA: 0x0000C760 File Offset: 0x0000A960 private bool IsStirrup() { RebarShape rebarShape = this.Rebar.Document.GetElement(this.Rebar.Element.GetShapeId()) as RebarShape; bool flag = rebarShape == null; return(flag || rebarShape.RebarStyle == (RebarStyle)1); }
static public string getShapeNameAtIndex(Rebar rebar, int barPositionIndex) { string shapeName = ""; if (rebar == null) { return(shapeName); } RebarFreeFormAccessor accessor = rebar.GetFreeFormAccessor(); if (accessor == null) { return(shapeName); } if (rebar.Document == null) { return(shapeName); } ElementId idShape = accessor.GetShapeIdAtIndex(barPositionIndex); RebarShape shape = rebar.Document.GetElement(idShape) as RebarShape; if (shape == null) { return(shapeName); } shapeName = shape.Name; return(shapeName); }
Stream(ArrayList data, RebarShape rebarShape) { data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShape))); data.Add(new Snoop.Data.Object("GetRebarShapeDefinition()", rebarShape.GetRebarShapeDefinition())); data.Add(new Snoop.Data.String("Rebar style", rebarShape.RebarStyle.ToString())); data.Add(new Snoop.Data.Bool("Simple arc", rebarShape.SimpleArc)); // TBD: should be "IsSimpleArc"? data.Add(new Snoop.Data.Bool("Simple line", rebarShape.SimpleLine)); // TBD: should be "IsSimpleLine?" // TBD: how to call other functions? }
protected override void SolveInstance(IGH_DataAccess DA) { Curve rebarCurve = null; RebarProperties props = null; DA.GetData(0, ref rebarCurve); DA.GetData(1, ref props); RebarShape rebarShape = new RebarShape(props); rebarShape.CurveToRebarShape(rebarCurve); DA.SetData(0, rebarShape); DA.SetData(1, rebarShape.RebarMesh); }
private RebarShape GetRebarShape(string nameRebarShape) { RebarShape rebarShape = null; FilteredElementCollector rsCollector = new FilteredElementCollector(doc); rsCollector.OfClass(typeof(RebarShape)) .OfCategory(BuiltInCategory.OST_Rebar); foreach (RebarShape rs in rsCollector) { if (rs.Name == nameRebarShape) { rebarShape = rs; } } return(rebarShape); }
protected override void SolveInstance(IGH_DataAccess DA) { Curve rebarCurve = null; RebarProperties props = null; BendingRoller bendingRoller = null; DA.GetData(0, ref rebarCurve); DA.GetData(1, ref props); DA.GetData(2, ref bendingRoller); RebarShape rebarShape = new RebarShape(props); rebarShape.PolylineToRebarShape(rebarCurve, bendingRoller); DA.SetData(0, rebarShape); DA.SetData(1, rebarShape.RebarMesh); }
protected override void SolveInstance(IGH_DataAccess DA) { int id = 0; RebarShape rebarShape = null; Vector3d vector = new Vector3d(); int count = 0; DA.GetData(0, ref id); DA.GetData(1, ref rebarShape); DA.GetData(2, ref vector); DA.GetData(3, ref count); RebarGroup rebarGroup = new RebarGroup(id, new RebarSpacing(rebarShape, vector, count)); DA.SetData(0, rebarGroup); DA.SetDataList(1, rebarGroup.RebarGroupMesh); DA.SetDataList(2, rebarGroup.RebarGroupCurves); }
protected override void SolveInstance(IGH_DataAccess DA) { Rectangle3d rectangle = Rectangle3d.Unset; RebarProperties properties = null; int position = 0; CoverDimensions coverDimensions = null; DA.GetData(0, ref rectangle); DA.GetData(1, ref properties); DA.GetData(2, ref position); DA.GetData(3, ref coverDimensions); RebarShape rebarShape = new RebarShape(properties); rebarShape.BuildRectangleToLineBarShape(rectangle, position, coverDimensions); DA.SetData(0, rebarShape); DA.SetData(1, rebarShape.RebarMesh); }
/// <summary> /// Present the main dialog for user to prepare the parameters for Rebar creation, /// and after that if user click the OK button, a new Rebar will be created. /// </summary> public void Execute() { using (NewRebarForm form = new NewRebarForm(m_rvtUIDoc.Document)) { if (DialogResult.OK == form.ShowDialog()) { RebarBarType barType = form.RebarBarType; RebarShape barShape = form.RebarShape; List <Autodesk.Revit.DB.XYZ> profilePoints = m_geometryData.ProfilePoints; Autodesk.Revit.DB.XYZ origin = profilePoints[0]; Autodesk.Revit.DB.XYZ yVec = profilePoints[1] - origin; Autodesk.Revit.DB.XYZ xVec = profilePoints[3] - origin; m_createdRebar = Rebar.CreateFromRebarShape(m_rvtUIDoc.Document, barShape, barType, m_rebarHost, origin, xVec, yVec); LayoutRebar(); } } }
protected override void SolveInstance(IGH_DataAccess DA) { int id = 0; RebarShape rebarShape = null; Vector3d vector = new Vector3d(); double spacingDistance = double.NaN; int spacingType = 0; double tolerance = double.NaN; DA.GetData(0, ref id); DA.GetData(1, ref rebarShape); DA.GetData(2, ref vector); DA.GetData(3, ref spacingDistance); DA.GetData(4, ref spacingType); DA.GetData(5, ref tolerance); RebarGroup rebarGroup = new RebarGroup(id, new RebarSpacing(rebarShape, vector, spacingDistance, spacingType, tolerance)); DA.SetData(0, rebarGroup); DA.SetDataList(1, rebarGroup.RebarGroupMesh); DA.SetDataList(2, rebarGroup.RebarGroupCurves); }
/// <summary> /// Add a multi-planar bar into corbel with given options. /// </summary> /// <param name="options">Options for Rebar Creation</param> private void PlaceMultiplanarRebar(CorbelReinforcementOptions options) { Trapezoid profileCopy = m_profile.Clone(); profileCopy.OffsetTop(-m_corbelCoverDistance - options.StirrupBarType.BarDiameter - 0.5 * options.MultiplanarBarType.BarDiameter); profileCopy.OffsetLeft(-m_corbelCoverDistance - 0.5 * options.MultiplanarBarType.BarDiameter); profileCopy.OffsetBottom(m_hostDepth - m_hostCoverDistance - options.HostStraightBarType.BarDiameter * 4 - options.StirrupBarType.BarDiameter); profileCopy.OffsetRight(-m_corbelCoverDistance - options.StirrupBarType.BarDiameter - 0.5 * options.StirrupBarType.BarDiameter); //m_profile.Draw(options.RevitDoc); //profileCopy.Draw(options.RevitDoc); XYZ origin, vx, vy; profileCopy.Boundary(out origin, out vx, out vy); XYZ vecX = vx.Normalize(); XYZ vecY = vy.Normalize(); RebarShape barshape = profileCopy.ConstructMultiplanarRebarShape(options.RevitDoc, 0.5 * options.MultiplanarBarType.StirrupTieBendDiameter); Rebar newRebar = Rebar.CreateFromRebarShape( options.RevitDoc, barshape, options.MultiplanarBarType, m_corbel, origin, vecX, vecY); XYZ extruDir = (m_extrusionLine.GetEndPoint(1) - m_extrusionLine.GetEndPoint(0)).Normalize(); double offset = m_corbelCoverDistance + options.StirrupBarType.BarDiameter + 0.5 * options.MultiplanarBarType.BarDiameter; newRebar.ScaleToBoxFor3D(origin + extruDir * (m_extrusionLine.Length - offset), vx, vy, m_extrusionLine.Length - 2 * offset); ShowRebar3d(newRebar); }
protected override void SolveInstance(IGH_DataAccess DA) { Rectangle3d rectangle = Rectangle3d.Unset; RebarProperties properties = null; BendingRoller bendingRoller = null; int hooksType = 0; CoverDimensions coverDimensions = null; double hookLength = 0.0; DA.GetData(0, ref rectangle); DA.GetData(1, ref properties); DA.GetData(2, ref bendingRoller); DA.GetData(3, ref hooksType); DA.GetData(4, ref hookLength); DA.GetData(5, ref coverDimensions); RebarShape rebarShape = new RebarShape(properties); rebarShape.BuildRectangleToStirrupShape(rectangle, bendingRoller, hooksType, coverDimensions, hookLength); DA.SetData(0, rebarShape); DA.SetData(1, rebarShape.RebarMesh); }
public void testRebar_FromCurve_Bot_Func(Document doc, Element myBeam, List <Face> myListFacePicked, double divideFac, double coverBar, string myRebarShapeName, string myRebarTypeName) { LocationCurve myLocBeam = myBeam.Location as LocationCurve; List <XYZ> myEndPoints = getPointCenterBottomLine(doc, myBeam); XYZ p1 = myEndPoints[0]; XYZ p2 = myEndPoints[1]; XYZ Vp1p2 = p2 - p1; double p1p2Length = Vp1p2.GetLength(); // Cover bar thickness = 25 // double coverBar = 25/304.8; XYZ p1_Rb = p1 + coverBar / p1p2Length * Vp1p2; XYZ p2_Rb = p1 + (1 - coverBar / p1p2Length) * Vp1p2; p1_Rb = new XYZ(p1_Rb.X, p1_Rb.Y, p1_Rb.Z + coverBar); p2_Rb = new XYZ(p2_Rb.X, p2_Rb.Y, p2_Rb.Z + coverBar); Line centerLineBeam = Line.CreateBound(p1_Rb, p2_Rb); XYZ v = p2_Rb - p1_Rb; XYZ p = p1_Rb - 0.1 * v; XYZ v1 = new XYZ(v.Y, -1 * v.X, v.Z); XYZ v2 = p2_Rb - p; List <double> myListDisSortFace = getAndSortDisOfEndFaces(myListFacePicked, p); double lengSeg = myListDisSortFace[myListDisSortFace.Count() - 1] - myListDisSortFace[0]; // double divideFac = 6; XYZ ePR1 = p + ((myListDisSortFace[0] + lengSeg / divideFac) / v2.GetLength()) * v2; XYZ ePR2 = p + ((myListDisSortFace[myListDisSortFace.Count() - 1] - lengSeg / divideFac) / v2.GetLength()) * v2; Line curveOfRebar = Line.CreateBound(ePR1, ePR2); List <Curve> myShape = new List <Curve>() { curveOfRebar }; // RebarShape FilteredElementCollector fecRebarShape = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); RebarShape myRebarShape = fecRebarShape.Cast <RebarShape>(). First <RebarShape>(myRebarShape2 => myRebarShape2.Name == myRebarShapeName); // Rebartype FilteredElementCollector fecRebarType = new FilteredElementCollector(doc) .OfClass(typeof(RebarBarType)); RebarBarType myRebarType = fecRebarType.Cast <RebarBarType>(). First <RebarBarType>(myRebarType2 => myRebarType2.Name == myRebarTypeName); // Hooktype FilteredElementCollector fec2 = new FilteredElementCollector(doc) .OfClass(typeof(RebarHookType)); IEnumerable <RebarHookType> iterRebarHookTypes = fec2.Cast <RebarHookType>(); RebarHookType myRebarHookType = iterRebarHookTypes.First(); using (Transaction trans = new Transaction(doc, "rebar test")) { trans.Start(); // Rebar myRebar = Rebar.CreateFromCurvesAndShape(doc, myRebarShape, myRebarType, // null, null, // myBeam,v1, // myShape, // RebarHookOrientation.Left, // RebarHookOrientation.Left); Rebar myRebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, myRebarType, null, null, myBeam, v1, myShape, RebarHookOrientation.Left, RebarHookOrientation.Right, true, false); trans.Commit(); } }
/// <summary> /// Create the multi-planar Rebar Shape according to the trapezoid wire-frame. /// </summary> /// <param name="revitDoc">Revit DB Document</param> /// /// <param name="bendDiameter">OutOfPlaneBendDiameter for multi-planar shape</param> /// <returns>Created multi-planar Rebar Shape</returns> public RebarShape ConstructMultiplanarRebarShape(Document revitDoc, double bendDiameter) { // Construct a segment definition with 2 lines. RebarShapeDefinitionBySegments shapedef = new RebarShapeDefinitionBySegments(revitDoc, 2); // Define parameters for the dimension. ElementId B = SharedParameterUtil.GetOrCreateDef("B", revitDoc); ElementId H = SharedParameterUtil.GetOrCreateDef("H", revitDoc); ElementId K = SharedParameterUtil.GetOrCreateDef("K", revitDoc); ElementId MM = SharedParameterUtil.GetOrCreateDef("MM", revitDoc); // Set parameters default values according to the size Trapezoid shape. shapedef.AddParameter(B, Top.Length); shapedef.AddParameter(H, Bottom.Length - Top.Length); shapedef.AddParameter(K, Vertical.Length); shapedef.AddParameter(MM, 15); // Rebar shape geometry curves consist of Line S0 and Line S1. // // // |Y V1 // |--S0(B)--\ // | \S1(H, K) // | \ //---------|O-----------\----X // | // Define Segment 0 (S0) // // S0's direction is fixed in positive X Axis. shapedef.SetSegmentFixedDirection(0, 1, 0); // S0's length is determined by parameter B shapedef.AddConstraintParallelToSegment(0, B, false, false); // Define Segment 1 (S1) // // Fix S1's direction. shapedef.SetSegmentFixedDirection(1, Bottom.Length - Top.Length, -Vertical.Length); // S1's length in positive X Axis is parameter H. shapedef.AddConstraintToSegment(1, H, 1, 0, 1, false, false); // S1's length in negative Y Axis is parameter K. shapedef.AddConstraintToSegment(1, K, 0, -1, 1, false, false); // Define Vertex 1 (V1) // // S1 at V1 is turn to right and the angle is acute. shapedef.AddBendDefaultRadius(1, RebarShapeVertexTurn.Right, RebarShapeBendAngle.Acute); // Check to see if it's full constrained. if (!shapedef.Complete) { throw new Exception("Shape was not completed."); } // Try to solve it to make sure the shape can be resolved with default parameter value. if (!shapedef.CheckDefaultParameterValues(0, 0)) { throw new Exception("Can't resolve rebar shape."); } // Define multi-planar definition RebarShapeMultiplanarDefinition multiPlanarDef = new RebarShapeMultiplanarDefinition(bendDiameter); multiPlanarDef.DepthParamId = MM; // Realize the Rebar shape with creation static method. // The RebarStype is stirrupTie, and it will attach to the top cover. RebarShape newshape = RebarShape.Create(revitDoc, shapedef, multiPlanarDef, RebarStyle.StirrupTie, StirrupTieAttachmentType.InteriorFace, 0, RebarHookOrientation.Left, 0, RebarHookOrientation.Left, 0); // Give a readable name newshape.Name = "API Corbel Multi-Shape " + newshape.Id; // Make sure we can see the created shape from the browser. IList <Curve> curvesForBrowser = newshape.GetCurvesForBrowser(); if (curvesForBrowser.Count == 0) { throw new Exception("The Rebar shape is invisible in browser."); } return(newshape); }
// Token: 0x060001D7 RID: 471 RVA: 0x0000C80C File Offset: 0x0000AA0C internal override void WriteToUnitechnik(ICollection <ExportReinfData> exportedElements) { bool flag = this.Rebar == null; if (!flag) { bool flag2 = base.IronSetsSchematic.none <List <ItGeCurve3d> >(); if (flag2) { ItFailures.PostFailure(ItFailures.CAMInvalidRebarShape, this.Rebar.Id); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsFailure }); } else { bool ironSetsSchematicAreInvalid = base.IronSetsSchematicAreInvalid; if (ironSetsSchematicAreInvalid) { ItFailures.PostFailure(ItFailures.CAMUnsupportedRebarShapeExportedAsStraightBar, this.Rebar.Id); } bool flag3 = SteelGroupElementRebar.IsMultiplanar(this.Rebar); if (flag3) { this.UnitechnikWriteRebarAsMountPart(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsMountPart }); } else { bool flag4 = base.IronSetsSchematic.any((List <ItGeCurve3d> ls) => ls.OfType <ItGeCircArc3d>().any <ItGeCircArc3d>()); if (flag4) { this.UnitechnikWriteRebarAsMountPart(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsMountPart }); } else { bool flag5 = SteelGroupElementRebar.IsStraightBarsInXYPlane(base.IronSetsSchematic); if (flag5) { this.UnitechnikWriteRebars(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsRodstock }); } else { RebarShape rebarShape = this.Rebar.Document.GetElement(this.Rebar.Element.GetShapeId()) as RebarShape; bool flag6 = rebarShape.RebarStyle == (RebarStyle)1; if (flag6) { this.UnitechnikWriteRebarAsMountPart(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsMountPart }); } else { bool flag7 = SteelGroupElementRebar.IsValidBendingFormForUnitechnikFreeForm(base.IronSetsSchematic); if (flag7) { this.UnitechnikWriteRebarAsFreeForm(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsFreeForm }); } else { this.UnitechnikWriteRebarAsMountPart(); exportedElements.Add(new ExportReinfData { Id = this.Rebar.Id, ExportedAs = ExportReinfData.ExportType.AsMountPart }); } } } } } } } }
public void testRebar_FromShape() { UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; // Pick Rebar List <int> myListIdCategoryRebar = new List <int>(); myListIdCategoryRebar.Add((int)BuiltInCategory.OST_StructuralFraming); // Select first Element (ex beam) Reference myRefBeam = uiDoc.Selection.PickObject(ObjectType.Element, new FilterByIdCategory(myListIdCategoryRebar), "Pick a Beam..."); //Get element1 from ref Element myBeam = doc.GetElement(myRefBeam); setBeJoined(myBeam); LocationCurve myLocBeam = myBeam.Location as LocationCurve; Line centerLinebeam = myLocBeam.Curve as Line; XYZ p = centerLinebeam.GetEndPoint(0); XYZ q = centerLinebeam.GetEndPoint(1); XYZ v = p - q; XYZ v1 = v.CrossProduct(p); List <Curve> myShape = new List <Curve>() { centerLinebeam }; // Rebartype FilteredElementCollector fec1 = new FilteredElementCollector(doc) .OfClass(typeof(RebarBarType)); IEnumerable <RebarBarType> iterRebarBarTypes = fec1.Cast <RebarBarType>(); RebarBarType myRebarType = iterRebarBarTypes.First(); // RebarShape FilteredElementCollector fec3 = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); IEnumerable <RebarShape> iterRebarBarShapes = fec3.Cast <RebarShape>(); RebarShape myRebarShape = iterRebarBarShapes.First(); // Hooktype FilteredElementCollector fec2 = new FilteredElementCollector(doc) .OfClass(typeof(RebarHookType)); IEnumerable <RebarHookType> iterRebarHookTypes = fec2.Cast <RebarHookType>(); RebarHookType myRebarHookType = iterRebarHookTypes.First(); XYZ ORIGIN = new XYZ(q.X, q.Y, q.Z - 25 / 304.8); using (Transaction trans = new Transaction(doc, "rebar test")) { trans.Start(); Rebar bar = Rebar.CreateFromRebarShape(doc, myRebarShape, myRebarType, myBeam, ORIGIN, v, new XYZ(0, 0, 1)); doc.Regenerate(); List <Curve> myCenterLineOfRebar = bar.GetCenterlineCurves(false, false, false, MultiplanarOption.IncludeOnlyPlanarCurves, 0) as List <Curve>; trans.Commit(); } }
/// <summary> /// Present a dialog to customize a RebarShape. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void createShapeButton_Click(object sender, EventArgs e) { // Make sure the name is not null or empty. if (string.IsNullOrEmpty(nameTextBox.Text.Trim())) { TaskDialog.Show("Revit", "Please give a name to create a rebar shape."); return; } // Make sure the input name is started with letter and // just contains letters, numbers and underlines. Regex regex = new Regex("^[a-zA-Z]\\w+$"); if (!regex.IsMatch(nameTextBox.Text.Trim())) { TaskDialog.Show("Revit", "Please input the name starting with letter and just containing letters, numbers and underlines. String is " + nameTextBox.Text.ToString()); nameTextBox.Focus(); return; } // Create a RebarShapeDefinition. RebarShapeDef shapeDef = null; if (byArcradioButton.Checked) { // Create arc shape. RebarShapeDefinitionByArc arcShapeDefinition = null; RebarShapeDefinitionByArcType arcType = (RebarShapeDefinitionByArcType)Enum.Parse(typeof(RebarShapeDefinitionByArcType), arcTypecomboBox.Text); if (arcType != RebarShapeDefinitionByArcType.Spiral) { arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, arcType); } else { // Set default value for Spiral-Shape definition. arcShapeDefinition = new RebarShapeDefinitionByArc(m_rvtDoc, 10.0, 3.0, 0, 0); } shapeDef = new RebarShapeDefByArc(arcShapeDefinition); } else if (bySegmentsradioButton.Checked) { // Create straight segments shape. int segmentCount = 0; if (int.TryParse(segmentCountTextBox.Text, out segmentCount) && segmentCount > 0) { shapeDef = new RebarShapeDefBySegment(new RebarShapeDefinitionBySegments(m_rvtDoc, segmentCount)); } else { TaskDialog.Show("Revit", "Please input a valid positive integer as segments count."); return; } } int startHookAngle = 0; int endHookAngle = 0; RebarHookOrientation startHookOrientation = RebarHookOrientation.Left; RebarHookOrientation endHookOrientation = RebarHookOrientation.Left; bool doCreate = false; using (NewRebarShapeForm form = new NewRebarShapeForm(m_rvtDoc, shapeDef)) { // Present a form to customize the shape. if (DialogResult.OK == form.ShowDialog()) { doCreate = true; if (form.NeedSetHooks) { // Set hooks for rebar shape. startHookAngle = form.StartHookAngle; endHookAngle = form.EndHookAngle; startHookOrientation = form.StartHookOrientation; endHookOrientation = form.EndHookOrientation; } } } if (doCreate) { // Create the RebarShape. RebarShape createdRebarShape = RebarShape.Create(m_rvtDoc, shapeDef.RebarshapeDefinition, null, RebarStyle.Standard, StirrupTieAttachmentType.InteriorFace, startHookAngle, startHookOrientation, endHookAngle, endHookOrientation, 0); createdRebarShape.Name = nameTextBox.Text.Trim(); // Add the created shape to the candidate list. m_rebarShapes.Add(createdRebarShape); m_shapesBinding.ResetBindings(false); shapesComboBox.SelectedItem = createdRebarShape; } }
private void Stream(ArrayList data, RebarShape rebarShape) { data.Add(new Snoop.Data.ClassSeparator(typeof(RebarShape))); data.Add(new Snoop.Data.Object("GetRebarShapeDefinition()", rebarShape.GetRebarShapeDefinition())); data.Add(new Snoop.Data.String("Rebar style", rebarShape.RebarStyle.ToString())); data.Add(new Snoop.Data.Bool("Simple arc", rebarShape.SimpleArc)); // TBD: should be "IsSimpleArc"? data.Add(new Snoop.Data.Bool("Simple line", rebarShape.SimpleLine)); // TBD: should be "IsSimpleLine?" // TBD: how to call other functions? }
Stream(ArrayList data, ElementType sym) { data.Add(new Snoop.Data.ClassSeparator(typeof(ElementType))); // no data at this level yet AnnotationSymbolType annoType = sym as AnnotationSymbolType; if (annoType != null) { Stream(data, annoType); return; } AreaReinforcementType areaReinforcementType = sym as AreaReinforcementType; if (areaReinforcementType != null) { Stream(data, areaReinforcementType); return; } AreaTagType areaTagType = sym as AreaTagType; if (areaTagType != null) { Stream(data, areaTagType); return; } BeamSystemType beamSystemType = sym as BeamSystemType; if (beamSystemType != null) { Stream(data, beamSystemType); return; } DimensionType dimType = sym as DimensionType; if (dimType != null) { Stream(data, dimType); return; } //TF FabricSheetType fabricST = sym as FabricSheetType; if (fabricST != null) { Stream(data, fabricST); return; } FabricWireType fabricWT = sym as FabricWireType; if (fabricWT != null) { Stream(data, fabricWT); return; } //TFEND GroupType groupType = sym as GroupType; if (groupType != null) { Stream(data, groupType); return; } HostObjAttributes hostAtt = sym as HostObjAttributes; if (hostAtt != null) { Stream(data, hostAtt); return; } InsertableObject insObj = sym as InsertableObject; if (insObj != null) { Stream(data, insObj); return; } LevelType levelType = sym as LevelType; if (levelType != null) { Stream(data, levelType); return; } LineAndTextAttrSymbol lineAndTextAttr = sym as LineAndTextAttrSymbol; if (lineAndTextAttr != null) { Stream(data, lineAndTextAttr); return; } LoadTypeBase loadTypeBase = sym as LoadTypeBase; if (loadTypeBase != null) { Stream(data, loadTypeBase); return; } MEPBuildingConstruction mepBldConst = sym as MEPBuildingConstruction; if (mepBldConst != null) { Stream(data, mepBldConst); return; } PathReinforcementType pathReinforcementType = sym as PathReinforcementType; if (pathReinforcementType != null) { Stream(data, pathReinforcementType); return; } RebarBarType rebarBarType = sym as RebarBarType; if (rebarBarType != null) { Stream(data, rebarBarType); return; } RebarCoverType rebarCoverType = sym as RebarCoverType; if (rebarCoverType != null) { Stream(data, rebarCoverType); return; } RebarHookType rebarHookType = sym as RebarHookType; if (rebarHookType != null) { Stream(data, rebarHookType); return; } RebarShape rebarShape = sym as RebarShape; if (rebarShape != null) { Stream(data, rebarShape); return; } RoomTagType roomTagType = sym as RoomTagType; if (roomTagType != null) { Stream(data, roomTagType); return; } SpaceTagType spaceTagType = sym as SpaceTagType; if (spaceTagType != null) { Stream(data, spaceTagType); return; } TrussType trussType = sym as TrussType; if (trussType != null) { Stream(data, trussType); return; } DistributionSysType distSysType = sym as DistributionSysType; if (distSysType != null) { Stream(data, distSysType); return; } MEPCurveType mepCurType = sym as MEPCurveType; if (mepCurType != null) { Stream(data, mepCurType); return; } FluidType fluidType = sym as FluidType; if (fluidType != null) { Stream(data, fluidType); return; } PipeScheduleType pipeSchedType = sym as PipeScheduleType; if (pipeSchedType != null) { Stream(data, pipeSchedType); return; } VoltageType voltType = sym as VoltageType; if (voltType != null) { Stream(data, voltType); return; } WireType wireType = sym as WireType; if (wireType != null) { Stream(data, wireType); return; } ModelTextType modelTxtType = sym as ModelTextType; if (modelTxtType != null) { Stream(data, modelTxtType); return; } }
//private void setBeJoined(Document doc, Element myBeJoined) //{ // ICollection<ElementId> myListElemIdsJoined = JoinGeometryUtils.GetJoinedElements(doc, myBeJoined); // using (Transaction trans = new Transaction(doc, "Switch Join")) // { // trans.Start(); // foreach (ElementId myElemId in myListElemIdsJoined) // { // if (!JoinGeometryUtils.IsCuttingElementInJoin(doc, doc.GetElement(myElemId), myBeJoined)) // { // JoinGeometryUtils.SwitchJoinOrder(doc, doc.GetElement(myElemId), myBeJoined); // } // } // trans.Commit(); // } //} public void Rebar_FromCurve_Top_Func(Document doc, Element myBeam, List <Face> myListFacePicked, double divideFac, double coverBar, string myRebarShapeName, string myRebarTypeName) { //BoundingBox beam BoundingBoxXYZ myBoundBeam = myBeam.get_BoundingBox(null); double hBeam = myBoundBeam.Max.Z - myBoundBeam.Min.Z; LocationCurve myLocBeam = myBeam.Location as LocationCurve; Line myLocLine = myLocBeam.Curve as Line; XYZ p = myLocLine.GetEndPoint(0); XYZ q = myLocLine.GetEndPoint(1); XYZ v = q - p; XYZ pE = p - 0.5 * v; XYZ vE = q - pE; XYZ vRB = new XYZ(v.Y, -1 * v.X, v.Z); List <double> myListDisSortFace = getAndSortDisOfEndFaces(myListFacePicked, pE); double lengSeg_1 = myListDisSortFace[1] - myListDisSortFace[0]; double lengSeg_2 = myListDisSortFace[3] - myListDisSortFace[2]; XYZ ePR1_XY = pE + ((myListDisSortFace[1] - lengSeg_1 / divideFac) / vE.GetLength()) * vE; XYZ ePR2_XY = pE + ((myListDisSortFace[2] + lengSeg_2 / divideFac) / vE.GetLength()) * vE; XYZ ePR1 = new XYZ(ePR1_XY.X, ePR1_XY.Y, myBoundBeam.Max.Z - coverBar); XYZ ePR2 = new XYZ(ePR2_XY.X, ePR2_XY.Y, myBoundBeam.Max.Z - coverBar); Line curveOfRebar = Line.CreateBound(ePR1, ePR2); //Tang List <Curve> myShape = new List <Curve>() { curveOfRebar }; // RebarShape FilteredElementCollector fecRebarShape = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); RebarShape myRebarShape = fecRebarShape.Cast <RebarShape>(). First <RebarShape>(myRebarShape2 => myRebarShape2.Name == myRebarShapeName); // Rebartype FilteredElementCollector fecRebarType = new FilteredElementCollector(doc) .OfClass(typeof(RebarBarType)); RebarBarType myRebarType = fecRebarType.Cast <RebarBarType>(). First <RebarBarType>(myRebarType2 => myRebarType2.Name == myRebarTypeName); // Hooktype FilteredElementCollector fec2 = new FilteredElementCollector(doc) .OfClass(typeof(RebarHookType)); IEnumerable <RebarHookType> iterRebarHookTypes = fec2.Cast <RebarHookType>(); RebarHookType myRebarHookType = iterRebarHookTypes.First(); using (Transaction trans = new Transaction(doc, "rebar test")) { trans.Start(); Rebar myRebar = Rebar.CreateFromCurves(doc, RebarStyle.Standard, myRebarType, null, null, myBeam, vRB, myShape, RebarHookOrientation.Left, RebarHookOrientation.Right, true, false); trans.Commit(); } }
public void GetFraming() { if (VolumeParametrA < 100) { throw new ArgumentException("Значение A должно быть больше 100"); } if (VolumeParametrB < 50) { throw new ArgumentException("Значение B должно быть больше 50"); } if (RebarSpace < 50) { throw new ArgumentException("Значение RebarSpace должно быть больше 50"); } Options geoOptions = new Options() { View = doc.ActiveView, IncludeNonVisibleObjects = true }; GeometryElement geoElement = host.get_Geometry(geoOptions); FaceArray faceArray = new FaceArray(); foreach (GeometryObject geoObject in geoElement) { Solid geoSolid = geoObject as Solid; if (null != geoSolid) { faceArray = geoSolid.Faces; } } RebarShape rebarShape = GetRebarShape(NameRebarShape); RebarBarType rebarBarType = GetRebarBarType(NameRebarBarType); using (TransactionGroup tg = new TransactionGroup(doc , "TransactionGroupSlabReinforcement_3")) { tg.Start(); foreach (PlanarFace planarFace in faceArray) { if (planarFace.FaceNormal.Z == 0) { XYZ origin = GetOrigin(planarFace , VolumeParametrA / coof , NameRebarShape); using (Transaction t = new Transaction(doc, "SlabReinforcement_3")) { t.Start(); if (NameRebarShape == "Стж_Г") { XYZ xVec = planarFace.FaceNormal; XYZ yVec = -planarFace.XVector; Rebar rebar = Rebar.CreateFromRebarShape(doc, rebarShape , rebarBarType, host, origin, xVec, yVec); if (null != rebar) { bool barsOnNormalSide; if (planarFace.YVector == new XYZ(0, 1, 0)) { barsOnNormalSide = true; } else { barsOnNormalSide = false; } int numberOfBarPositions = (int)Math.Round ( ((planarFace.GetBoundingBox().Max.V - (2 * 50 / coof)) / (RebarSpace / coof) + 1) ); double spacing = RebarSpace / coof; bool includeFirstBar = true; bool includeLastBar = true; rebar.GetShapeDrivenAccessor() .SetLayoutAsNumberWithSpacing(numberOfBarPositions , spacing, barsOnNormalSide , includeFirstBar, includeLastBar); foreach (Parameter para in rebar.Parameters) { SetParametr(para); } } } if (NameRebarShape == "Стж_П") { XYZ xVec = -planarFace.XVector; XYZ yVec = -planarFace.FaceNormal; Rebar rebar = Rebar.CreateFromRebarShape(doc, rebarShape , rebarBarType, host, origin, xVec, yVec); if (null != rebar) { bool barsOnNormalSide; if (planarFace.YVector == new XYZ(0, 1, 0)) { barsOnNormalSide = true; } else { barsOnNormalSide = false; } int numberOfBarPositions = (int)Math.Round ( ((planarFace.GetBoundingBox().Max.V - (2 * 50 / coof)) / (RebarSpace / coof) + 1) ); double spacing = RebarSpace / coof; bool includeFirstBar = true; bool includeLastBar = true; rebar.GetShapeDrivenAccessor() .SetLayoutAsNumberWithSpacing(numberOfBarPositions , spacing, barsOnNormalSide , includeFirstBar, includeLastBar); foreach (Parameter para in rebar.Parameters) { SetParametr(para); } } } t.Commit(); } } } tg.Assimilate(); } }
public void testRebar_FromShapeAndCurve_Bot() { UIDocument uiDoc = this.ActiveUIDocument; Document doc = uiDoc.Document; List <int> myListIdCategoryRebar = new List <int>(); myListIdCategoryRebar.Add((int)BuiltInCategory.OST_StructuralFraming); // Select first Element (ex beam) Reference myRefBeam = uiDoc.Selection.PickObject(ObjectType.Element, new FilterByIdCategory(myListIdCategoryRebar), "Pick a Beam..."); //Get element1 from ref Element myBeam = doc.GetElement(myRefBeam); setBeJoined(myBeam); // doc.Regenerate(); LocationCurve myLocBeam = myBeam.Location as LocationCurve; List <XYZ> myEndPoints = getPointCenterBottomLine(myBeam); XYZ p1 = myEndPoints[0]; XYZ p2 = myEndPoints[1]; XYZ Vp1p2 = p2 - p1; double p1p2Length = Vp1p2.GetLength(); // Cover bar thickness = 25 double coverBar = 25 / 304.8; XYZ p1_Rb = p1 + coverBar / p1p2Length * Vp1p2; XYZ p2_Rb = p1 + (1 - coverBar / p1p2Length) * Vp1p2; p1_Rb = new XYZ(p1_Rb.X, p1_Rb.Y, p1_Rb.Z + coverBar); p2_Rb = new XYZ(p2_Rb.X, p2_Rb.Y, p2_Rb.Z + coverBar); Line curveOfRebar = Line.CreateBound(p1_Rb, p2_Rb); List <Curve> myShape = new List <Curve>() { curveOfRebar }; Line centerLineBeam = Line.CreateBound(p1, p2); XYZ p = centerLineBeam.GetEndPoint(0); XYZ q = centerLineBeam.GetEndPoint(1); XYZ v = p - q; XYZ v1 = new XYZ(v.Y, -1 * v.X, v.Z); // RebarShape FilteredElementCollector fec3 = new FilteredElementCollector(doc) .OfClass(typeof(RebarShape)); IEnumerable <RebarShape> iterRebarBarShapes = fec3.Cast <RebarShape>(); RebarShape myRebarShape = iterRebarBarShapes.First(); // Rebartype FilteredElementCollector fec1 = new FilteredElementCollector(doc) .OfClass(typeof(RebarBarType)); IEnumerable <RebarBarType> iterRebarBarTypes = fec1.Cast <RebarBarType>(); RebarBarType myRebarType = iterRebarBarTypes.First(); // Hooktype FilteredElementCollector fec2 = new FilteredElementCollector(doc) .OfClass(typeof(RebarHookType)); IEnumerable <RebarHookType> iterRebarHookTypes = fec2.Cast <RebarHookType>(); RebarHookType myRebarHookType = iterRebarHookTypes.First(); using (Transaction trans = new Transaction(doc, "rebar test")) { trans.Start(); Rebar myRebar = Rebar.CreateFromCurvesAndShape(doc, myRebarShape, myRebarType, null, null, myBeam, v1, myShape, RebarHookOrientation.Left, RebarHookOrientation.Left); //myRebar.GetShapeDrivenAccessor().SetLayoutAsFixedNumber(4,1,true, true, true); trans.Commit(); } }