Пример #1
0
        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);
        }
Пример #2
0
        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);
        }