Beispiel #1
0
 protected static Autodesk.Revit.DB.ViewPlan CreateAreaPlan(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.AreaScheme areaScheme)
 {
     return(Autodesk.Revit.DB.ViewPlan.CreateAreaPlan(Document, areaScheme.Id, level.Id));
 }
Beispiel #2
0
 private Level(Autodesk.Revit.DB.Level level)
 {
     this.InternalSetLevel(level);
 }
Beispiel #3
0
 /// <summary>
 /// Internal constructor for a FamilyInstance
 /// </summary>
 internal FamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.XYZ pos,
                         Autodesk.Revit.DB.Level level)
 {
     SafeInit(() => InitFamilyInstance(fs, pos, level));
 }
Beispiel #4
0
 /// <summary>
 /// Create a new Room by Level and location
 /// </summary>
 /// <param name="level"></param>
 /// <param name="location"></param>
 /// <param name="name"></param>
 /// <param name="number"></param>
 private Room(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.XYZ location, string name, string number)
 {
     SafeInit(() => Init(level, location, name, number));
 }
Beispiel #5
0
 public Level(Autodesk.Revit.DB.Level level) : base(level)
 {
 }
Beispiel #6
0
 /// <summary>
 /// Private constructor
 /// </summary>
 private FloorPlanView(Autodesk.Revit.DB.Level level)
 {
     SafeInit(() => InitFloorPlanView(level));
 }
Beispiel #7
0
 private CeilingPlanViews(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.ViewFamilyType viewFamilyType)
 {
     SafeInit(() => InitViewPlan(level, viewFamilyType));
 }
Beispiel #8
0
 /// <summary>
 /// Private constructor
 /// </summary>
 private AreaPlanView(Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.AreaScheme areaScheme)
 {
     SafeInit(() => InitAreaPlanView(level, areaScheme));
 }
Beispiel #9
0
        private void InitFamilyInstance(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.Line line, Autodesk.Revit.DB.Level level)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldFam = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.FamilyInstance>(DocumentManager.Instance.CurrentDBDocument);

            //There was a point, rebind to that, and adjust its position
            if (oldFam != null)
            {
                InternalSetFamilyInstance(oldFam);
                InternalSetLevel(level);
                InternalSetFamilySymbol(fs);
                InternalSetPosition(line);
                return;
            }

            //Phase 2- There was no existing point, create one
            TransactionManager.Instance.EnsureInTransaction(DocumentManager.Instance.CurrentDBDocument);

            //If the symbol is not active, then activate it
            if (!fs.IsActive)
            {
                fs.Activate();
            }

            var fi = DocumentManager.Instance.CurrentDBDocument.Create.NewFamilyInstance(line, fs, level, Autodesk.Revit.DB.Structure.StructuralType.NonStructural);

            ((Autodesk.Revit.DB.LocationCurve)fi.Location).Curve = line;

            InternalSetFamilyInstance(fi);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(InternalElement);
        }
Beispiel #10
0
 /// <summary>
 /// Set the Element, it's Id, and it's uniqueId
 /// </summary>
 /// <param name="level"></param>
 private void InternalSetLevel(Autodesk.Revit.DB.Level level)
 {
     this.InternalLevel     = level;
     this.InternalElementId = level.Id;
     this.InternalUniqueId  = level.UniqueId;
 }
Beispiel #11
0
 internal FamilyInstances(Autodesk.Revit.DB.FamilySymbol fs, Autodesk.Revit.DB.Line line, Autodesk.Revit.DB.Level level)
 {
     SafeInit(() => InitFamilyInstance(fs, line, level));
 }
Beispiel #12
0
        /// <summary>
        /// Initialize a StructuralFraming element
        /// </summary>
        private void InitStructuralFraming(Autodesk.Revit.DB.Curve curve, Autodesk.Revit.DB.XYZ upVector, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.Structure.StructuralType structuralType, Autodesk.Revit.DB.FamilySymbol symbol)
        {
            //Phase 1 - Check to see if the object exists and should be rebound
            var oldFam =
                ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.FamilyInstance>(Document);

            //There was a point, rebind to that, and adjust its position
            if (oldFam != null)
            {
                InternalSetFamilyInstance(oldFam);
                InternalSetFamilySymbol(symbol);
                InternalSetCurve(curve);
                return;
            }

            //Phase 2- There was no existing point, create one
            TransactionManager.Instance.EnsureInTransaction(Document);

            var creationData = GetCreationData(curve, upVector, level, structuralType, symbol);

            Autodesk.Revit.DB.FamilyInstance fi;
            if (Document.IsFamilyDocument)
            {
                var elementIds = Document.FamilyCreate.NewFamilyInstances2(new List <FamilyInstanceCreationData>()
                {
                    creationData
                });

                if (elementIds.Count == 0)
                {
                    throw new Exception(Properties.Resources.FamilyInstanceCreationFailure);
                }

                fi = (Autodesk.Revit.DB.FamilyInstance)Document.GetElement(elementIds.First());
            }
            else
            {
                var elementIds = Document.Create.NewFamilyInstances2(new List <FamilyInstanceCreationData>()
                {
                    creationData
                });

                if (elementIds.Count == 0)
                {
                    throw new Exception(Properties.Resources.FamilyInstanceCreationFailure);
                }

                fi = (Autodesk.Revit.DB.FamilyInstance)Document.GetElement(elementIds.First());
            }

            InternalSetFamilyInstance(fi);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.SetElementForTrace(this.InternalElement);
        }
Beispiel #13
0
 /// <summary>
 /// Internal constructor - creates a single StructuralFraming instance
 /// </summary>
 internal StructuralFraming(Autodesk.Revit.DB.Curve curve, Autodesk.Revit.DB.Level level,
                            Autodesk.Revit.DB.Structure.StructuralType structuralType, Autodesk.Revit.DB.FamilySymbol symbol)
 {
     SafeInit(() => InitStructuralFraming(curve, level, structuralType, symbol));
 }
Beispiel #14
0
 private static FamilyInstanceCreationData GetCreationData(Autodesk.Revit.DB.Curve curve, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.Structure.StructuralType structuralType, Autodesk.Revit.DB.FamilySymbol symbol)
 {
     return(new FamilyInstanceCreationData(curve, symbol, level, structuralType));
 }
Beispiel #15
0
        private static FamilyInstanceCreationData GetCreationData(Autodesk.Revit.DB.Curve curve, Autodesk.Revit.DB.XYZ upVector, Autodesk.Revit.DB.Level level, Autodesk.Revit.DB.Structure.StructuralType structuralType, Autodesk.Revit.DB.FamilySymbol symbol)
        {
            //calculate the desired rotation
            //we do this by finding the angle between the z axis
            //and vector between the start of the beam and the target point
            //both projected onto the start plane of the beam.
            var zAxis = new Autodesk.Revit.DB.XYZ(0, 0, 1);
            var yAxis = new Autodesk.Revit.DB.XYZ(0, 1, 0);

            //flatten the beam line onto the XZ plane
            //using the start's z coordinate
            var start  = curve.GetEndPoint(0);
            var end    = curve.GetEndPoint(1);
            var newEnd = new Autodesk.Revit.DB.XYZ(end.X, end.Y, start.Z); //drop end point to plane

            //catch the case where the end is directly above
            //the start, creating a normal with zero length
            //in that case, use the Z axis
            var planeNormal = newEnd.IsAlmostEqualTo(start) ? zAxis : (newEnd - start).Normalize();

            var gamma = upVector.AngleOnPlaneTo(zAxis.IsAlmostEqualTo(planeNormal) ? yAxis : zAxis, planeNormal);

            return(new FamilyInstanceCreationData(curve, symbol, level, structuralType)
            {
                RotateAngle = gamma
            });
        }