14.09.2023 19:02
Автор темы
АВТОМАТИЗАЦИЯ
0
Сообщения
1
Пользователи
0
Лайки
146
Просмотры
0
Спецификации на листе мне "изловить" удалось. Как бы теперь добраться до фильтров оных? Для начала хотя бы прочитать. 🙂 Ну а потом уж - и изменить.
using System; using System.Linq; using System.Collections.Generic; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.DB.Structure; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; namespace XX.Functions.KJ { [Transaction(TransactionMode.Manual)] public class param_in_filter : IExternalCommand { public Result Execute(ExternalCommandData cmdData, ref string msg, ElementSet elems) { UIDocument uiDoc = cmdData.Application.ActiveUIDocument; ViewSheet selectedSheet = GetSelectedSheet(uiDoc); if (selectedSheet == null) { msg = "Выберите лист"; return Result.Cancelled; } // Получение спецификаций, вынесенных на выбранный лист IList<Element> specifications = GetSheetSpecifications(selectedSheet); return Result.Succeeded; } private ViewSheet GetSelectedSheet(UIDocument uiDoc) { // Получение выбранных элементов на виде ICollection<ElementId> selectedElementIds = uiDoc.Selection.GetElementIds(); // Проверка, является ли выбранный элемент листом foreach (ElementId elementId in selectedElementIds) { Element element = uiDoc.Document.GetElement(elementId); if (element is ViewSheet sheet) { return sheet; } } return null; } private IList<Element> GetSheetSpecifications(ViewSheet sheet) { // Получение графических элементов, размещенных на виде FilteredElementCollector collector = new FilteredElementCollector(sheet.Document, sheet.Id); IList<Element> elements = collector.WhereElementIsNotElementType().ToElements(); IList<Element> specifications = elements.Where(elem => elem.Category?.Name == "Графика спецификации").ToList(); return specifications; } private void ShowSpecificationsList(IList<string> specificationNames) { // Вывод списка спецификаций string listText = "Specifications:\n"; foreach (string specificationName in specificationNames) { listText += "- " + specificationName + "\n"; } TaskDialog.Show("Specifications List", listText ); } } }