示例#1
0
 /// <summary>
 /// Checks existance of the connects
 /// </summary>
 /// <param name="inID">ElementId of the incoming Element</param>
 /// <param name="outID">ElementId of the outgoing Element</param>
 /// <returns>True if the connection exists already</returns>
 private static bool ConnectionExists(ElementId inID, ElementId outID)
 {
     string elementIdKey = inID.ToString() + "_" + outID.ToString();
     return m_ConnectionExists.Contains(elementIdKey);
 }
示例#2
0
 /// <summary>
 /// Add new Connection
 /// </summary>
 /// <param name="inID"></param>
 /// <param name="outID"></param>
 private static void AddConnectionInternal(ElementId inID, ElementId outID)
 {
     string elementIdKey = inID.ToString() + "_" + outID.ToString();
     m_ConnectionExists.Add(elementIdKey);
 }
示例#3
0
        private void CreateSheets()
        {
            TaskDialog taskDialog = new TaskDialog("Create Sheets");

            taskDialog.MainIcon        = TaskDialogIcon.TaskDialogIconNone;
            taskDialog.MainInstruction = "Are you sure you want to create these sheets?";
            taskDialog.CommonButtons   = TaskDialogCommonButtons.Yes | TaskDialogCommonButtons.No;

            string EXviewId    = string.Empty;
            string EXviewToAdd = string.Empty;

            if (this.cbTitleblocks.Items.Count == 0)
            {
                TaskDialog.Show("No Titleblocks Loaded", "Make sure you have a titleblock loaded and selected before continuing.");
            }
            else
            {
                if (taskDialog.Show() == TaskDialogResult.Yes)
                {
                    Transaction trans = new Transaction(revitDoc, "Create Sheets");

                    try
                    {
                        #region SELECTS SPECIFIC TITLEBLOCK AND VIEW FROM DOCUMENT

                        var            query          = from element in titleblockCollector where element.Name == this.titleBlockName select element;
                        List <Element> titleblockList = query.ToList <Element>();
                        ElementId      titleBlockid   = titleblockList[0].Id;

                        #endregion

                        #region  READ FROM lstSheetsToCreate AND CREATE SHEETS

                        trans.Start(); //STARTS THE Create Sheets TRANSACTION

                        foreach (DataGridViewRow row in dgvSheetToCreate.Rows)
                        {
                            string sheet = string.Empty;
                            sheet = Convert.ToString(row.Cells["Sheet"].Value);

                            char[]   separator = new char[] { ':' };
                            string[] values    = sheet.Split(separator, StringSplitOptions.None);

                            string viewToAdd = string.Empty;
                            viewToAdd   = Convert.ToString(row.Cells["View"].Value); //SELECT A SPECIFIC VIEW
                            EXviewToAdd = viewToAdd;

                            if (viewToAdd != string.Empty)                                    //IF THERE IS A VIEW ASSIGNED TO A SHEET THEN CREATE A VIEWPORT
                            {
                                ViewSheet vsSheet = ViewSheet.Create(revitDoc, titleBlockid); //CREATES A NEW SHEET

                                vsSheet.SheetNumber = values[0];                              //SETS THE SHEET NUMBER
                                vsSheet.Name        = values[1];                              //SETS THE SHEET NAME

                                ElementId viewId = null;
                                viewId   = viewDictionary[viewToAdd];
                                EXviewId = viewId.ToString();

                                //GETS THE CENTER OF THE SCREEN TO ADD THE VIEW
                                UV location = new UV((vsSheet.Outline.Max.U - vsSheet.Outline.Min.U) / 2, (vsSheet.Outline.Max.V - vsSheet.Outline.Min.V) / 2);

                                Viewport.Create(revitDoc, vsSheet.Id, viewId, new XYZ(location.U, location.V, 0)); //PLACES THE VIEW ONTO THE SHEET
                            }
                            else //IF THERE IS NOT A VIEW ASSIGNED TO A SHEET THEN JUST CREATE AN EMPTY SHEET
                            {
                                ViewSheet vsSheet = ViewSheet.Create(revitDoc, titleBlockid); //CREATES A NEW SHEET

                                vsSheet.SheetNumber = values[0];                              //SETS THE SHEET NUMBER
                                vsSheet.Name        = values[1];                              //SETS THE SHEET NAME
                            }
                        }

                        trans.Commit();
                        this.Close();

                        #endregion
                    }
                    catch (Exception ex)
                    {
                        TaskDialog errorMessage = new TaskDialog("Create Sheet Error");
                        errorMessage.MainInstruction = "An error occurrued while creating sheets." + Environment.NewLine + "Please read the following error message below";
                        errorMessage.MainContent     = ex.Message + Environment.NewLine + "viewId: " + EXviewId + Environment.NewLine + "View Name: " + EXviewToAdd;
                        errorMessage.Show();

                        trans.Dispose();
                    }
                }
            }
        }
示例#4
0
文件: FilterData.cs 项目: AMEE/revit
 /// <summary>
 /// Create FilterRuleBuilder for ElementId FilterRule
 /// </summary>
 /// <param name="param">Parameter of FilterRule.</param>
 /// <param name="ruleCriteria">Rule criteria.</param>
 /// <param name="ruleValue">Rule value.</param>
 public FilterRuleBuilder(BuiltInParameter param, String ruleCriteria, ElementId ruleValue)
 {
     InitializeMemebers();
     //
     // set data with specified values
     ParamType = StorageType.ElementId;
     Parameter = param;
     RuleCriteria = ruleCriteria;
     RuleValue = ruleValue.ToString();
 }
示例#5
0
        /// <summary>
        /// Add new Connection
        /// </summary>
        /// <param name="inID"></param>
        /// <param name="outID"></param>
        private static void AddConnectionInternal(ElementId inID, ElementId outID)
        {
            string elementIdKey = inID.ToString() + "_" + outID.ToString();

            m_ConnectionExists.Add(elementIdKey);
        }
示例#6
0
 public void Execute(Autodesk.Revit.UI.UIApplication revitApp)
 {
     using (Transaction tran = new Transaction(revitApp.ActiveUIDocument.Document, "Set Default family type to " + _defaultTypeId.ToString()))
     {
         tran.Start();
         revitApp.ActiveUIDocument.Document.SetDefaultFamilyTypeId(_builtInCategory, _defaultTypeId);
         tran.Commit();
     }
 }
示例#7
0
        /// <summary>
        /// Checks existance of the connects
        /// </summary>
        /// <param name="inID">ElementId of the incoming Element</param>
        /// <param name="outID">ElementId of the outgoing Element</param>
        /// <returns>True if the connection exists already</returns>
        private static bool ConnectionExists(ElementId inID, ElementId outID)
        {
            string elementIdKey = inID.ToString() + "_" + outID.ToString();

            return(m_ConnectionExists.Contains(elementIdKey));
        }
示例#8
0
        /***************************************************/

        public static void AddOrReplace(this Dictionary <string, List <IBHoMObject> > refObjects, ElementId key, IBHoMObject value)
        {
            refObjects.AddOrReplace(key.ToString(), value);
        }
示例#9
0
 public void Execute(Autodesk.Revit.UI.UIApplication revitApp)
 {
     using (Transaction tran = new Transaction(revitApp.ActiveUIDocument.Document, "Set Default element type to " + _defaultTypeId.ToString()))
     {
         tran.Start();
         revitApp.ActiveUIDocument.Document.SetDefaultElementTypeId(_elementTypeGroup, _defaultTypeId);
         tran.Commit();
     }
 }
示例#10
0
 /// <summary>
 /// Get a level by a level id.
 /// </summary>
 /// <param name="id">The id of the level</param>
 /// <returns>Returns a level which id equals the specified id.</returns>
 static public Level GetLevelByID(ElementId id)
 {
     return(m_levels[id.ToString()]);
 }
示例#11
0
        /***************************************************/

        public static T GetValue <T>(this Dictionary <string, List <IBHoMObject> > refObjects, ElementId key) where T : IBHoMObject
        {
            return(refObjects.GetValue <T>(key.ToString()));
        }