Esempio n. 1
0
        /// <summary>
        /// Initialize a CurtainSystem element
        /// </summary>
        private void InitCurtainSystem(ReferenceArray faces, Autodesk.Revit.DB.CurtainSystemType curtainSystemType)
        {
            TransactionManager.Instance.EnsureInTransaction(Document);

            Autodesk.Revit.DB.CurtainSystem curtainSystem = ElementBinder.GetElementFromTrace <Autodesk.Revit.DB.CurtainSystem>(Document);

            ICollection <ElementId> ids = Document.Create.NewCurtainSystem2(faces, curtainSystemType);

            if (ids.Count > 1)
            {
                foreach (ElementId id in ids)
                {
                    Autodesk.Revit.DB.CurtainSystem system = (Autodesk.Revit.DB.CurtainSystem)Document.GetElement(id);
                    InitCurtainSystem(system);
                }
                return;
            }
            else
            {
                curtainSystem = (Autodesk.Revit.DB.CurtainSystem)Document.GetElement(ids.First());
            }

            InternalSetCurtainSystem(curtainSystem);

            TransactionManager.Instance.TransactionTaskDone();

            ElementBinder.CleanupAndSetElementForTrace(Document, InternalCurtainSystem);
        }
Esempio n. 2
0
 /// <summary>
 /// Create a CurtainSystem from a user selected Element.
 /// </summary>
 /// <param name="curtainSystem"></param>
 /// <param name="isRevitOwned"></param>
 /// <returns></returns>
 internal static CurtainSystem FromExisting(Autodesk.Revit.DB.CurtainSystem curtainSystem, bool isRevitOwned)
 {
     return(new CurtainSystem(curtainSystem)
     {
         IsRevitOwned = isRevitOwned
     });
 }
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // grab input
            DB.CurtainSystem curtainSystemInstance = default;
            if (!DA.GetData("Curtain System", ref curtainSystemInstance))
            {
                return;
            }

            if (curtainSystemInstance.CurtainGrids != null)
            {
                var cGrids = curtainSystemInstance.CurtainGrids.Cast <DB.CurtainGrid>();
                DA.SetDataList("Curtain Grids", cGrids.Select(x => new Types.CurtainGrid(curtainSystemInstance, x)));
            }
        }
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            // grab input
            DB.CurtainSystem curtainSystemInstance = default;
            if (!DA.GetData("Curtain System", ref curtainSystemInstance))
            {
                return;
            }

            if (curtainSystemInstance.CurtainGrids != null)
            {
                var cGrids = new List <DB.CurtainGrid>();
                foreach (DB.CurtainGrid cgrid in curtainSystemInstance.CurtainGrids)
                {
                    cGrids.Add(cgrid);
                }

                DA.SetDataList("Curtain Grids", cGrids.Select(x => new Types.DataObject <DB.CurtainGrid>(x, srcDocument: curtainSystemInstance.Document)));
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Initialize a CurtainSystem element
 /// </summary>
 private void InitCurtainSystem(Autodesk.Revit.DB.CurtainSystem curtainSystem)
 {
     InternalSetCurtainSystem(curtainSystem);
 }
Esempio n. 6
0
 /// <summary>
 /// Private constructor
 /// </summary>
 private CurtainSystem(Autodesk.Revit.DB.CurtainSystem curtainSystem)
 {
     SafeInit(() => InitCurtainSystem(curtainSystem));
 }
Esempio n. 7
0
 /// <summary>
 /// Set the InternalCurtainSystem property and the associated element id and unique id
 /// </summary>
 /// <param name="curtainSystem"></param>
 private void InternalSetCurtainSystem(Autodesk.Revit.DB.CurtainSystem curtainSystem)
 {
     InternalCurtainSystem = curtainSystem;
     InternalElementId     = curtainSystem.Id;
     InternalUniqueId      = curtainSystem.UniqueId;
 }
Esempio n. 8
0
 public static CurtainSystem Wrap(Autodesk.Revit.DB.CurtainSystem ele, bool isRevitOwned)
 {
     return(CurtainSystem.FromExisting(ele, isRevitOwned));
 }
Esempio n. 9
0
        /// <summary>
        /// create a new curtain system
        /// </summary>
        /// <param name="faceIndices">
        /// the faces to be covered with new curtain system
        /// </param>
        /// <param name="byFaceArray">
        /// indicates whether the curtain system will be created by face array
        /// </param>
        public void CreateCurtainSystem(List <int> faceIndices, bool byFaceArray)
        {
            // just refresh the main UI
            if (null == faceIndices ||
                0 == faceIndices.Count)
            {
                if (null != CurtainSystemChanged)
                {
                    CurtainSystemChanged();
                }
                return;
            }
            SystemInfo resultInfo = new SystemInfo(m_mydocument);

            resultInfo.ByFaceArray      = byFaceArray;
            resultInfo.GridFacesIndices = faceIndices;
            resultInfo.Index            = ++m_csIndex;

            //
            // step 1: create the curtain system
            //
            // create the curtain system by face array
            if (true == byFaceArray)
            {
                FaceArray faceArray = new FaceArray();
                foreach (int index in faceIndices)
                {
                    faceArray.Append(m_mydocument.MassFaceArray.get_Item(index));
                }

                Autodesk.Revit.DB.CurtainSystem curtainSystem = null;
                Transaction t = new Transaction(m_mydocument.Document, Guid.NewGuid().GetHashCode().ToString());
                t.Start();
                try
                {
                    curtainSystem = m_mydocument.Document.Create.NewCurtainSystem(faceArray, m_mydocument.CurtainSystemType);
                }
                catch (System.Exception)
                {
                    m_mydocument.FatalErrorMsg = Properties.Resources.MSG_CreateCSFailed;
                    t.RollBack();
                    return;
                }

                t.Commit();

                resultInfo.CurtainForm = curtainSystem;
            }
            // create the curtain system by reference array
            else
            {
                ReferenceArray refArray = new ReferenceArray();
                foreach (int index in faceIndices)
                {
                    refArray.Append(m_mydocument.MassFaceArray.get_Item(index).Reference);
                }

                ICollection <ElementId> curtainSystems = null;
                Transaction             t = new Transaction(m_mydocument.Document, Guid.NewGuid().GetHashCode().ToString());
                t.Start();
                try
                {
                    curtainSystems = m_mydocument.Document.Create.NewCurtainSystem2(refArray, m_mydocument.CurtainSystemType);
                }
                catch (System.Exception)
                {
                    m_mydocument.FatalErrorMsg = Properties.Resources.MSG_CreateCSFailed;
                    t.RollBack();
                    return;
                }
                t.Commit();

                // internal fatal error, quit the sample
                if (null == curtainSystems ||
                    1 != curtainSystems.Count)
                {
                    m_mydocument.FatalErrorMsg = Properties.Resources.MSG_MoreThan1CSCreated;
                    return;
                }

                // store the curtain system
                foreach (ElementId cs in curtainSystems)
                {
                    resultInfo.CurtainForm = m_mydocument.Document.GetElement(cs) as Autodesk.Revit.DB.CurtainSystem;
                    break;
                }
            }
            //
            // step 2: update the curtain system list in the main UI
            //
            m_curtainSystemInfos.Add(resultInfo);
            if (null != CurtainSystemChanged)
            {
                CurtainSystemChanged();
            }
        }
 public CurtainSystem(DB.CurtainSystem host) : base(host)
 {
 }