构件之间创建连接关系

 /// <summary>
        /// 创建连接
        /// </summary>
        /// <param name="activeDoc"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        private static void CreateDetailedStructuralConnection(UIDocument uidoc , ElementId elementId, List<ElementId> elementIds)
        {
            List<ElementId> ids;
            try
            {
                // 要生成Revit中其它的连接方式,只需修改familyname、guid这两个参数即可(如何获取这两个参数?在Reivt中创建一个连接然后用RevitLookUp查看即可)
                StructuralConnectionHandlerType connectionType = StructuralConnectionHandlerType.Create(uidoc.Document, "锯切 - 翼缘", new Guid("5930c793-e644-4b50-b68e-0841b71bbca2"), "锯切 - 翼缘");
                if (connectionType == null) throw new Exception("connectionType为空");
                if (elementId == null) return;
                foreach (var id in elementIds)
                {
                    if (!IfNeedCutBrace(activeDoc.Document, elementId, id))
                    {
                        ids = new List<ElementId>();
                        ids.Add(elementId);
                        ids.Add(id);
                        var conn = StructuralConnectionHandler.Create(activeDoc.Document, ids, connectionType.Id);
                    }
                }
            }
            catch (Exception e)
            {
                throw new Exception("连接端切割失败:" + e.Message);
            }
        }

创建连接关系

猜你喜欢

转载自blog.csdn.net/waiting233/article/details/116997692