public Result setup_joists() { using (Transaction t = new Transaction(doc, "Joists")) { t.Start(); Family f = null; //FIXME : move to a function that's called only once string familyPath = @"C:\ProgramData\Autodesk\RVT 2019\Libraries\US Imperial\Structural Framing\Wood\Plywood Web Joist.rfa"; doc.LoadFamily(familyPath, out f); XYZ pt0 = XYZ.Zero; Line directionLine = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 5, -joist_offset)); SketchPlane sp = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 40, -joist_offset))); BeamSystem bs = BeamSystem.Create(doc, joistCurves, sp, directionLine.Direction, false); //get the layoutRule of the beamsystem Autodesk.Revit.DB.LayoutRule layoutRule = bs.LayoutRule; //create a new instance of the LayoutRuleClearSpacing class LayoutRuleClearSpacing myLayoutRuleClearSpacing = new LayoutRuleClearSpacing(2.0, BeamSystemJustifyType.Beginning); //set the new layoutRule to the beamsystem bs.LayoutRule = myLayoutRuleClearSpacing; t.Commit(); } return(Result.Succeeded); }
/// <summary> /// /// </summary> /// <param name="app"></param> /// <param name="beamSystem"></param> /// <returns></returns> private static Revit.Element CloneElement(Autodesk.Revit.UI.UIApplication app, BeamSystem beamSystem) { List <Curve> profile = new List <Curve>(); foreach (Curve curve in beamSystem.Profile) { profile.Add(curve); } BeamSystem beamSystemClone = BeamSystem.Create(app.ActiveUIDocument.Document, profile, beamSystem.Level, 0, false); Utils.ParamUtil.SetParameters(beamSystemClone.Parameters, beamSystem.Parameters); return(beamSystemClone); }
/// <summary> /// create beam system according to given profile and property /// </summary> public void CreateBeamSystem() { Document document = m_data.CommandData.Application.ActiveUIDocument.Document; // create curve array and insert Lines in order IList <Curve> curves = new List <Curve>(); foreach (Line line in m_data.Lines) { curves.Add(line); } // create beam system takes closed profile consist of lines BeamSystem aBeamSystem = BeamSystem.Create(document, curves, document.ActiveView.SketchPlane, 0); // set created beam system's layout rule and beam type property aBeamSystem.LayoutRule = m_data.Param.Layout; aBeamSystem.BeamType = m_data.Param.BeamType; }
public Result setup_joists() { using (Transaction t = new Transaction(doc, "Joists")) { t.Start(); Family f = null; //FIXME : move to a function that's called only once string familyPath = @"C:\ProgramData\Autodesk\RVT 2019\Libraries\US Imperial\Structural Framing\Wood\Plywood Web Joist.rfa"; doc.LoadFamily(familyPath, out f); XYZ pt0 = XYZ.Zero; Line directionLine = Line.CreateBound(new XYZ(0, 0, 0), new XYZ(0, 5, -joist_offset)); SketchPlane sp = SketchPlane.Create(doc, Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 40, -joist_offset))); BeamSystem bs = BeamSystem.Create(doc, joistCurves, sp, directionLine.Direction, false); //get the layoutRule of the beamsystem Autodesk.Revit.DB.LayoutRule layoutRule = bs.LayoutRule; //create a new instance of the LayoutRuleClearSpacing class LayoutRuleClearSpacing myLayoutRuleClearSpacing = new LayoutRuleClearSpacing(2.0, BeamSystemJustifyType.Beginning); //set the new layoutRule to the beamsystem bs.LayoutRule = myLayoutRuleClearSpacing; t.Commit(); } // Metal beam double offset_from_floor = 80 / 12.0; XYZ startPoint = new XYZ(0.0, 183 / 12.0, level.Elevation + offset_from_floor); XYZ endPoint = new XYZ(472 / 12.0, 183 / 12.0, level.Elevation + offset_from_floor); FamilySymbol beamSymbol = new FilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).Cast <FamilySymbol>() .First(q => q.Family.FamilyCategory.Name == "Structural Framing" && q.Family.Name == "W Shapes" && q.Name == "W12X26"); using (Transaction t = new Transaction(doc)) { t.Start("Activate beam"); if (!beamSymbol.IsActive) { beamSymbol.Activate(); // doc.Regenerate(); } t.Commit(); } // try to insert an instance using (Transaction tx = new Transaction(doc)) { tx.Start("insert beam"); FamilyInstance fi = doc.Create.NewFamilyInstance(XYZ.Zero, beamSymbol, StructuralType.Beam); (fi.Location as LocationCurve).Curve = Line.CreateBound(startPoint, endPoint);; tx.Commit(); } return(Result.Succeeded); }