Esempio n. 1
0
        /// <summary>
        /// Apply linepattern to grids
        /// </summary>
        /// <param name="sender">This object</param>
        /// <param name="e">A object contains the event data</param>
        private void buttonApplyToGrids_Click(object sender, EventArgs e)
        {
            List <ElementId> lstGridTypeIds = new List <ElementId>();

            GetSelectedGridTypeIds(lstGridTypeIds);
            if (lstGridTypeIds.Count == 0)
            {
                TaskDialog.Show("Apply To Grids",
                                "Before applying a LinePattern to Grids, you must first select at least one grid.");
                this.Close();
                return;
            }

            if (treeViewLinePattern.SelectedNode == null || treeViewLinePattern.Parent == null)
            {
                TaskDialog.Show("Apply To Grids",
                                "Before applying a LinePattern to Grids, you must first select a LinePattern.");
                return;
            }
            ElementId eid = ElementId.Parse(treeViewLinePattern.SelectedNode.Name);

            foreach (ElementId typeId in lstGridTypeIds)
            {
                Element gridType = doc.GetElement(typeId);
                //set the parameter value of End Segment Pattern
                SetParameter("End Segment Pattern", eid, gridType);
            }
            this.Close();
        }
        /// <summary>
        /// Look up a pipe type by ElementId string and return it.
        /// </summary>
        /// <returns></returns>
        private PipeType GetSelectedPipeType()
        {
            string selectedString = comboBox_PipeTypes.SelectedItem.ToString();

            string[] selectedsplit = selectedString.Split(':');
            if (selectedsplit.Length != 2)
            {
                throw new ArgumentException();
            }

            ElementId id = ElementId.Parse(selectedsplit[1]);

            return(m_application.ActiveUIDocument.Document.GetElement(id) as PipeType);
        }
Esempio n. 3
0
        /// <summary>
        /// Create API FilterRule according to sample's FilterRuleBuilder
        /// </summary>
        /// <returns>API FilterRule converted from current FilterRuleBuilder.</returns>
        public FilterRule AsFilterRule()
        {
            ElementId paramId = new ElementId(Parameter);

            if (ParamType == StorageType.String)
            {
                switch (RuleCriteria)
                {
                case RuleCriteraNames.BeginWith:
                    return(PFRF.CreateBeginsWithRule(paramId, RuleValue));

                case RuleCriteraNames.Contains:
                    return(PFRF.CreateContainsRule(paramId, RuleValue));

                case RuleCriteraNames.EndsWith:
                    return(PFRF.CreateEndsWithRule(paramId, RuleValue));

                case RuleCriteraNames.Equals_:
                    return(PFRF.CreateEqualsRule(paramId, RuleValue));

                case RuleCriteraNames.Greater:
                    return(PFRF.CreateGreaterRule(paramId, RuleValue));

                case RuleCriteraNames.GreaterOrEqual:
                    return(PFRF.CreateGreaterOrEqualRule(paramId, RuleValue));

                case RuleCriteraNames.Less:
                    return(PFRF.CreateLessRule(paramId, RuleValue));

                case RuleCriteraNames.LessOrEqual:
                    return(PFRF.CreateLessOrEqualRule(paramId, RuleValue));

                case RuleCriteraNames.NotBeginWith:
                    return(PFRF.CreateNotBeginsWithRule(paramId, RuleValue));

                case RuleCriteraNames.NotContains:
                    return(PFRF.CreateNotContainsRule(paramId, RuleValue));

                case RuleCriteraNames.NotEndsWith:
                    return(PFRF.CreateNotEndsWithRule(paramId, RuleValue));

                case RuleCriteraNames.NotEquals:
                    return(PFRF.CreateNotEqualsRule(paramId, RuleValue));
                }
            }
            else if (ParamType == StorageType.Double)
            {
                switch (RuleCriteria)
                {
                case RuleCriteraNames.Equals_:
                    return(PFRF.CreateEqualsRule(paramId, double.Parse(RuleValue), Epsilon));

                case RuleCriteraNames.Greater:
                    return(PFRF.CreateGreaterRule(paramId, double.Parse(RuleValue), Epsilon));

                case RuleCriteraNames.GreaterOrEqual:
                    return(PFRF.CreateGreaterOrEqualRule(paramId, double.Parse(RuleValue), Epsilon));

                case RuleCriteraNames.Less:
                    return(PFRF.CreateLessRule(paramId, double.Parse(RuleValue), Epsilon));

                case RuleCriteraNames.LessOrEqual:
                    return(PFRF.CreateLessOrEqualRule(paramId, double.Parse(RuleValue), Epsilon));

                case RuleCriteraNames.NotEquals:
                    return(PFRF.CreateNotEqualsRule(paramId, double.Parse(RuleValue), Epsilon));
                }
            }
            else if (ParamType == StorageType.Integer)
            {
                switch (RuleCriteria)
                {
                case RuleCriteraNames.Equals_:
                    return(PFRF.CreateEqualsRule(paramId, int.Parse(RuleValue)));

                case RuleCriteraNames.Greater:
                    return(PFRF.CreateGreaterRule(paramId, int.Parse(RuleValue)));

                case RuleCriteraNames.GreaterOrEqual:
                    return(PFRF.CreateGreaterOrEqualRule(paramId, int.Parse(RuleValue)));

                case RuleCriteraNames.Less:
                    return(PFRF.CreateLessRule(paramId, int.Parse(RuleValue)));

                case RuleCriteraNames.LessOrEqual:
                    return(PFRF.CreateLessOrEqualRule(paramId, int.Parse(RuleValue)));

                case RuleCriteraNames.NotEquals:
                    return(PFRF.CreateNotEqualsRule(paramId, int.Parse(RuleValue)));
                }
            }
            else if (ParamType == StorageType.ElementId)
            {
                switch (RuleCriteria)
                {
                case RuleCriteraNames.Equals_:
                    return(PFRF.CreateEqualsRule(paramId, ElementId.Parse(RuleValue)));

                case RuleCriteraNames.Greater:
                    return(PFRF.CreateGreaterRule(paramId, ElementId.Parse(RuleValue)));

                case RuleCriteraNames.GreaterOrEqual:
                    return(PFRF.CreateGreaterOrEqualRule(paramId, ElementId.Parse(RuleValue)));

                case RuleCriteraNames.Less:
                    return(PFRF.CreateLessRule(paramId, ElementId.Parse(RuleValue)));

                case RuleCriteraNames.LessOrEqual:
                    return(PFRF.CreateLessOrEqualRule(paramId, ElementId.Parse(RuleValue)));

                case RuleCriteraNames.NotEquals:
                    return(PFRF.CreateNotEqualsRule(paramId, ElementId.Parse(RuleValue)));
                }
            }
            //
            // Throw exception for others
            throw new System.NotImplementedException("This filter rule or criteria is not implemented yet.");
        }