Exemplo n.º 1
0
        private static void ReinsertHostedObject(Document doc, IList <WallOpening> openings, Wall newWall)
        {
            Face  face       = RvtGeometryUtils.ObtainWallFace(newWall);
            XYZ   lowerPoint = ObtainVerticalCurve(face).GetEndPoint(0);
            XYZ   upperPoint = ObtainVerticalCurve(face).GetEndPoint(1);
            Level wallLevel  = doc.GetElement(newWall.LevelId) as Level;

            Trace.Write(string.Format("lowerPoint.Z={0}; upperPoint.Z={1}; Level={2}",
                                      lowerPoint.Z, upperPoint.Z, wallLevel.Name));

            foreach (WallOpening opening in openings)
            {
                Trace.Write(string.Format("locationPoint.Point={0}",
                                          opening.LocationPoint.ToString()));

                if (opening.LocationPoint.Z >= lowerPoint.Z &&
                    opening.LocationPoint.Z <= upperPoint.Z)
                {
                    using (Transaction t = new Transaction(doc))
                    {
                        t.Start("reinsert opening");
                        doc.Create.NewOpening(newWall, opening.LowerEndPoint, opening.UpperEndPoint);
                        t.Commit();
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void ReinsertHostedObject(Document doc, IList <Insert> inserts, Wall newWall)
        {
            Face  face       = RvtGeometryUtils.ObtainWallFace(newWall);
            XYZ   lowerPoint = ObtainVerticalCurve(face).GetEndPoint(0);
            XYZ   upperPoint = ObtainVerticalCurve(face).GetEndPoint(1);
            Level wallLevel  = doc.GetElement(newWall.LevelId) as Level;

            Trace.Write(string.Format("lowerPoint.Z={0}; upperPoint.Z={1}; Level={2}",
                                      lowerPoint.Z, upperPoint.Z, wallLevel.Name));

            foreach (Insert insert in inserts)
            {
                Trace.Write(string.Format("locationPoint.Point={0}",
                                          insert.LocationPoint.ToString()));

                if (insert.LocationPoint.Z >= lowerPoint.Z &&
                    insert.LocationPoint.Z <= upperPoint.Z)
                {
                    Trace.Write(string.Format("famSbl.Name={0}", insert.FamilySymbol.Name));

                    using (Transaction t = new Transaction(doc))
                    {
                        t.Start("reinsert hosted element");
                        doc.Create.NewFamilyInstance(insert.LocationPoint,
                                                     insert.FamilySymbol, newWall, wallLevel, StructuralType.NonStructural);
                        t.Commit();
                    }
                }
            }
        }