Exemple #1
0
        /// <summary>
        /// Structural connection elements selection function. It uses a customizable filter, so the user can only select allowed elements
        /// </summary>
        public static List <ElementId> SelectConnectionElements(UIDocument document, string prompt)
        {
            List <ElementId> elemIds = new List <ElementId>();

            // Create a filter for the allowed structural connection inputs.
            LogicalOrFilter connElemTypes = new LogicalOrFilter(new List <ElementFilter> {
                new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming),
                new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns),
                new ElementCategoryFilter(BuiltInCategory.OST_StructuralFoundation),
                new ElementCategoryFilter(BuiltInCategory.OST_Floors),
                new ElementCategoryFilter(BuiltInCategory.OST_Walls),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionPlates)
            });
            StructuralConnectionSelectionFilter elemFilter = new StructuralConnectionSelectionFilter(connElemTypes);
            List <Reference> refs = document.Selection.PickObjects(ObjectType.Element, elemFilter, prompt).ToList();

            elemIds = refs.Select(e => e.ElementId).ToList();
            return(elemIds);
        }
Exemple #2
0
        /// <summary>
        /// Structural connection selection function. It uses a customizable filter, so the user can only select connections
        /// </summary>
        public static StructuralConnectionHandler SelectConnection(UIDocument document)
        {
            StructuralConnectionHandler conn = null;
            // Create a filter for structural connections.
            LogicalOrFilter types = new LogicalOrFilter(new List <ElementFilter> {
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnections)
            });
            StructuralConnectionSelectionFilter filter = new StructuralConnectionSelectionFilter(types);
            Reference target = document.Selection.PickObject(ObjectType.Element, filter, "Select connection element :");

            if (target != null)
            {
                Element targetElement = document.Document.GetElement(target);
                if (targetElement != null)
                {
                    conn = targetElement as StructuralConnectionHandler;
                }
            }
            return(conn);
        }
Exemple #3
0
        /// <summary>
        /// Custom connection elements selection function. It uses a customizable filter, so the user can only select allowed elements
        /// </summary>
        public static List <Reference> SelectConnectionElementsCustom(UIDocument document)
        {
            List <ElementId> elemIds = new List <ElementId>();

            // Create a filter for the allowed structural connection inputs.
            LogicalOrFilter connElemTypes = new LogicalOrFilter(new List <ElementFilter> {
                new ElementCategoryFilter(BuiltInCategory.OST_StructuralFraming),
                new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionBolts),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionHoles),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionAnchors),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionShearStuds),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionWelds),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionModifiers),
                new ElementCategoryFilter(BuiltInCategory.OST_StructConnectionPlates)
            });
            StructuralConnectionSelectionFilter elemFilter = new StructuralConnectionSelectionFilter(connElemTypes);
            List <Reference> refs = document.Selection.PickObjects(ObjectType.Element, elemFilter, "Select elements to add to connection :").ToList();

            return(refs);
        }