public Result OnStartup(Autodesk.Revit.UI.UIControlledApplication application) { Form1 form1 = new Form1(); form1.Show(); // Register wall updater with Revit WallUpdater updater = new WallUpdater(application.ActiveAddInId, form1); UpdaterRegistry.RegisterUpdater(updater); List <BuiltInCategory> builtInCats = new List <BuiltInCategory>(); builtInCats.Add(BuiltInCategory.OST_Walls); builtInCats.Add(BuiltInCategory.OST_StructuralColumns); builtInCats.Add(BuiltInCategory.OST_Floors); builtInCats.Add(BuiltInCategory.OST_StructuralFoundation); builtInCats.Add(BuiltInCategory.OST_StructuralFraming); ElementMulticategoryFilter filter1 = new ElementMulticategoryFilter(builtInCats); UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter1, Element.GetChangeTypeElementAddition()); return(Result.Succeeded); }
private static void CmdGetWindow(UIDocument uiDoc, Transaction t) { var doc = uiDoc.Document; t.Start("Get Window from Legend"); var selection = doc.GetElement(uiDoc.Selection.GetElementIds().FirstOrDefault()); var getFamilyId = selection.get_Parameter(BuiltInParameter.LEGEND_COMPONENT).AsElementId(); var instancesList = new List <ElementId>(); var categories = new List <BuiltInCategory> { BuiltInCategory.OST_Windows, BuiltInCategory.OST_Doors }; ElementMulticategoryFilter elementMulticategoryFilter = new ElementMulticategoryFilter(categories); var elementList = new FilteredElementCollector(doc) .OfClass(typeof(FamilyInstance)) .WherePasses(elementMulticategoryFilter) .Cast <FamilyInstance>() .ToList(); foreach (var element in elementList) { var typeId = element.GetTypeId(); if (typeId == getFamilyId) { instancesList.Add(element.Id); } } uiDoc.Selection.SetElementIds(instancesList); t.Commit(); }
protected override Result ProcessCommand(ExternalCommandData commandData, ref string message, ElementSet elements) { // Tag All Door var listCategory = new List <BuiltInCategory>() { BuiltInCategory.OST_Doors, BuiltInCategory.OST_Windows }; var filter = new ElementMulticategoryFilter(listCategory); var elementLists = new FilteredElementCollector(_activeDocument, _activeDocument.ActiveView.Id) .WherePasses(filter) .WhereElementIsNotElementType() .ToElements(); using (Transaction trans = new Transaction(_activeDocument, "Create View Plan")) { trans.Start(); foreach (var element in elementLists) { var reference = new Reference(element); var loc = element.Location as LocationPoint; var pos = loc.Point; var tagNode = IndependentTag.Create(_activeDocument, _activeDocument.ActiveView.Id, reference, true, TagMode.TM_ADDBY_CATEGORY, TagOrientation.Horizontal, pos); } trans.Commit(); } return(Result.Succeeded); }
public virtual ElementFilter GetFilter() { var cats = new BuiltInCategory[] { BuiltInCategory.OST_DuctCurves, BuiltInCategory.OST_PipeCurves, BuiltInCategory.OST_CableTray }; var emcf = new ElementMulticategoryFilter(cats); return(emcf); }
public static List <Element> GetTargetedElements(string documentGuid, string ruleGuid) { RegexRule regexRule = RegularApp.RegexRuleCacheService.GetRegexRule(documentGuid, ruleGuid); if (regexRule == null) { return(null); } Document document = RegularApp.DocumentCacheService.GetDocument(documentGuid); ElementMulticategoryFilter elementMulticategoryFilter = new ElementMulticategoryFilter( regexRule.TargetCategoryObjects .Where(x => x.IsChecked) .Select(x => Category.GetCategory(document, new ElementId(x.CategoryObjectId))) .Select(CategoryUtils.GetBuiltInCategoryFromCategory) .ToList()); List <Element> targetedElements = new FilteredElementCollector(document) .WhereElementIsNotElementType() .WherePasses(elementMulticategoryFilter) .Where(x => x.GroupId == ElementId.InvalidElementId) .ToList(); return(targetedElements); }
public override ElementFilter GetFilter() { var cats = new BuiltInCategory[] { BuiltInCategory.OST_ElectricalEquipment, BuiltInCategory.OST_ElectricalFixtures, BuiltInCategory.OST_LightingDevices, BuiltInCategory.OST_LightingFixtures, BuiltInCategory.OST_SecurityDevices, BuiltInCategory.OST_DataDevices, BuiltInCategory.OST_FireAlarmDevices, BuiltInCategory.OST_CommunicationDevices, BuiltInCategory.OST_NurseCallDevices, BuiltInCategory.OST_TelephoneDevices }; var emcf = new ElementMulticategoryFilter(cats); return(emcf); }
public ElementFilter GetFilter() { var cats = new BuiltInCategory[] { BuiltInCategory.OST_MEPSpaces, BuiltInCategory.OST_Rooms }; var emcf = new ElementMulticategoryFilter(cats); return(emcf); }
//---------------------------------------------------------- public void Get_Family() { try { string category_name = ""; if (door.IsChecked == true) { category_name = door.Content.ToString(); } else if (window.IsChecked == true) { category_name = window.Content.ToString(); } else { category_name = generic_model.Content.ToString(); } ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(mySource.my_BuiltInCategory.Where(x => Category.GetCategory(doc, x).Name == category_name).ToList()); my_family_data = new ObservableCollection <family_data>(new FilteredElementCollector(doc) .WherePasses(filter_category) .WhereElementIsElementType() .Cast <ElementType>() .GroupBy(x => new { x.FamilyName, }) .ToList().Select(x => new family_data() { single_value = x.Key.FamilyName, path_image = myFunctionSupport.CreatePreview(x.First(), myAll_Data), types = x.Select(y => y).ToList() }).OrderBy(x => x.single_value)); if (my_family_data.Count() == 0) { my_family_data = new ObservableCollection <family_data>() { new family_data() { single_value = "", path_image = "", types = new List <ElementType>() } }; } family.ItemsSource = my_family_data; family.SelectedIndex = 0; CollectionView view = (CollectionView)CollectionViewSource.GetDefaultView(family.ItemsSource); view.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
/// <summary> /// Return wall openings using GetDependentElements /// </summary> static IList <ElementId> GetOpenings(Wall wall) { ElementMulticategoryFilter emcf = new ElementMulticategoryFilter( new List <ElementId>() { new ElementId(BuiltInCategory.OST_Windows), new ElementId(BuiltInCategory.OST_Doors) }); return(wall.GetDependentElements(emcf)); }
static IList <ElementId> GetOpenings(Wall wall) { var listWindowCategoryID = new ElementId(BuiltInCategory.OST_Windows); var listDoorCategoryID = new ElementId(BuiltInCategory.OST_Doors); var listElementId = new List <ElementId>() { listDoorCategoryID, listWindowCategoryID }; var emcf = new ElementMulticategoryFilter(listElementId); return(wall.GetDependentElements(emcf)); }
public void Publish(RevitToGraphPublisherSettings settings, IGraphDBClient client) { var meGraph = new MEPRevitGraph(); MEPRevitGraphWriter mps = new MEPRevitGraphWriter(meGraph); if (settings.IncludeElectrical) { mps.Parsers.Add(new Parsers.MEPGraphParserElectrical()); } if (settings.IncludeMechanical) { mps.Parsers.Add(new Parsers.MEPGraphParserConnectors()); } if (settings.IncludeBoundaries) { mps.Parsers.Add(new Parsers.MEPGraphParserSpaces()); } //if (settings.IncludeBoundaries) mps.Parsers.Add(new Parsers.ClashDetection()); mps.Parsers.Add(new Parsers.MEPGraphParserIoT()); if (mps.Parsers.Count == 0) { return; } var mecFEc = new FilteredElementCollector(_rdoc); var mecFilter = mps.GetFilterForAllParsers; var mecElements = mecFEc.WherePasses(mecFilter).WhereElementIsNotElementType().ToElements(); var wfic = new FilteredElementCollector(_rdoc); var geoElementsFilter = new ElementMulticategoryFilter(new BuiltInCategory[] { BuiltInCategory.OST_Floors, BuiltInCategory.OST_Roofs, BuiltInCategory.OST_Windows, BuiltInCategory.OST_Doors, BuiltInCategory.OST_MEPSpaces, BuiltInCategory.OST_Rooms }); var geoElements = wfic.WherePasses(geoElementsFilter).WhereElementIsNotElementType().ToElements(); using (Transaction tx = new Transaction(_rdoc, "Build graph")) { tx.Start("Build graph"); mps.Write(mecElements, geoElements, -1, true, _rdoc); tx.Commit(); } MEPGraphWriter wre = new MEPGraphWriter(client); wre.Write(meGraph, _rdoc); //var bc = new HLApps.Cloud.BuildingGraph.BuildingGraphClient(@"http://*****:*****@"C:\src\HLApps\GraphData-MEP\HLApps.Revit.Graph\RevitToGraphQLMappings.json"); //var bgmap = new HLApps.Cloud.BuildingGraph.Introspection.BuildingGraphMapping(json); //gqlWrtier.Write(meGraph, bgmap, _rdoc); }
/// <summary> /// The GetElementOfCategories /// </summary> /// <param name="doc">The doc<see cref="Document"/></param> /// <returns>The <see cref="IList{Element}"/></returns> public static IList <Element> GetElementOfCategories(Document doc) { //Créer une liste de catégories IList <BuiltInCategory> catList = new List <BuiltInCategory>(); //ajout catégorie dans liste catList.Add(BuiltInCategory.OST_Doors); catList.Add(BuiltInCategory.OST_Windows); catList.Add(BuiltInCategory.OST_Walls); catList.Add(BuiltInCategory.OST_StructuralColumns); catList.Add(BuiltInCategory.OST_StructuralFraming); catList.Add(BuiltInCategory.OST_GenericModel); catList.Add(BuiltInCategory.OST_Columns); catList.Add(BuiltInCategory.OST_StructuralFoundation); catList.Add(BuiltInCategory.OST_Ceilings); catList.Add(BuiltInCategory.OST_Floors); catList.Add(BuiltInCategory.OST_Stairs); catList.Add(BuiltInCategory.OST_SpecialityEquipment); catList.Add(BuiltInCategory.OST_Roofs); //****************catégories SYSTEMES****************** catList.Add(BuiltInCategory.OST_DuctCurves); //Gaine catList.Add(BuiltInCategory.OST_PlaceHolderDucts); // espace réservés aux gaines---VERIFIE catList.Add(BuiltInCategory.OST_DuctFitting); //raccords de gaine---VERIFIE catList.Add(BuiltInCategory.OST_DuctAccessory); //accessoir de gaineOST_FlexDuctCurves---VERIFIE catList.Add(BuiltInCategory.OST_FlexDuctCurves); //gaine flexible---VERIFIE catList.Add(BuiltInCategory.OST_DuctTerminal); //Bouche d'aération ---VERIFIE catList.Add(BuiltInCategory.OST_PipeCurves); //Canalisation---VERIFIE catList.Add(BuiltInCategory.OST_PipeFitting); //Raccord de canalisation---VERIFIE catList.Add(BuiltInCategory.OST_PlumbingFixtures); //Appareil sanitairesOST_Sprinklers---VERIFIE catList.Add(BuiltInCategory.OST_PlumbingFixtures); //OST_Sprinklers---VERIFIE catList.Add(BuiltInCategory.OST_CableTray); // chemin de câble---VERIFIE catList.Add(BuiltInCategory.OST_Conduit); //Conduits ***Note fait jusqu'à raccordement chemin à câble---VERIFIE catList.Add(BuiltInCategory.OST_CableTrayFitting); //Raccord chemin de câble catList.Add(BuiltInCategory.OST_LightingFixtures); //Luminaires //PLB catList.Add(BuiltInCategory.OST_MechanicalEquipment); //Equipement génie climatique catList.Add(BuiltInCategory.OST_PipeAccessory); // asscessoir de canalisation // Créer filtre de plusieurs catégorie //ELE catList.Add(BuiltInCategory.OST_ElectricalEquipment); catList.Add(BuiltInCategory.OST_ElectricalFixtures); catList.Add(BuiltInCategory.OST_LightingDevices); catList.Add(BuiltInCategory.OST_DataDevices); catList.Add(BuiltInCategory.OST_CommunicationDevices); catList.Add(BuiltInCategory.OST_FireAlarmDevices); catList.Add(BuiltInCategory.OST_SecurityDevices); ElementMulticategoryFilter multiCatFilter = new ElementMulticategoryFilter(catList); return(new FilteredElementCollector(doc).WhereElementIsNotElementType().WherePasses(multiCatFilter).ToElements()); }
protected internal static Parameter GetLODparameter(Document doc, Definition def) { FilteredElementCollector val = new FilteredElementCollector(doc); ElementMulticategoryFilter val2 = new ElementMulticategoryFilter((ICollection <BuiltInCategory>)lodCatArray); val.WherePasses(val2); foreach (Element item in val) { if (item != null) { return(item.get_Parameter(def)); } } throw new NullReferenceException("Document must have an object with the LOD parameterin order to get the Parameter"); }
protected internal static Parameter GetLODparameter(Document doc, string name) { FilteredElementCollector val = new FilteredElementCollector(doc); ElementMulticategoryFilter val2 = new ElementMulticategoryFilter((ICollection <BuiltInCategory>)lodCatArray); val.WherePasses(val2); foreach (Element item in val) { if (item != null) { return(item.LookupParameter(name)); } } throw new NullReferenceException("Document must have an object with the LOD parameterin order to get the Parameter. Or perhaps you spelled the parameter name wrong."); }
public static (Dictionary <string, double>, Dictionary <int, string>) metregardecorps(List <Document> docs) { Dictionary <string, double> typegardecorps = new Dictionary <string, double>(); Dictionary <int, string> erreursgc = new Dictionary <int, string>(); int erreurgardecorps = 0; foreach (Document doc in docs) { ElementMulticategoryFilter multigc = new ElementMulticategoryFilter(new BuiltInCategory[] { BuiltInCategory.OST_Railings, BuiltInCategory.OST_StairsRailing }); IList <Element> gardecorps = new FilteredElementCollector(doc).WherePasses(multigc).WhereElementIsNotElementType().ToList(); //TaskDialog.Show("Nombre garde corps", string.Format("Lien Revit: {0};" +Environment.NewLine+ "Nombre de type de garde corps: {1}",titredoc,gardecorps.Count)); foreach (Element rail in gardecorps) { string typegarde = rail.Name; int gardeid = rail.GetTypeId().IntegerValue; double longueur = 0; try { longueur = rail.LookupParameter("Longueur").AsDouble();// getparameter (longueur) pour les garde corps n'existe pas...) ne fonctionne donc pas en anglais longueur = UnitUtils.ConvertFromInternalUnits(longueur, DisplayUnitType.DUT_METERS); longueur = Math.Round(longueur, 2); if (typegardecorps.ContainsKey(typegarde)) { typegardecorps[typegarde] += longueur; } else { typegardecorps.Add(typegarde, longueur); } } catch { if (typegarde == "") { typegarde = "AUCUN NOM DE TYPE"; } erreurgardecorps += 1; if (erreursgc.ContainsKey(gardeid) == false) { erreursgc.Add(gardeid, typegarde); } } } } return(typegardecorps, erreursgc); }
private ObservableCollection <ElementItem> GetViews() { List <BuiltInCategory> builtInCategory = new List <BuiltInCategory>(); builtInCategory.Add(BuiltInCategory.OST_Views); ElementMulticategoryFilter multuFilter = new ElementMulticategoryFilter(builtInCategory); var elements = new FilteredElementCollector(_doc) .WherePasses(multuFilter) .WhereElementIsNotElementType() .ToElements() .Select(x => new ElementItem(x.Id, x.Name)) .Convert <ElementItem>(); return(elements); }
public void Get_Element() { try { family_data item_family = (family_data)family.SelectedItem; type_data item_type = (type_data)type.SelectedItem; ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(mySource.my_BuiltInCategory); element = new FilteredElementCollector(doc) .WherePasses(filter_category) .WhereElementIsNotElementType() .First(x => x.Name == item_type.single_value && x.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsValueString() == item_family.single_value) as FamilyInstance; } catch (Exception ex) { //MessageBox.Show(ex.Message); } }
private ElementMulticategoryFilter GetCategoryFilter() { foreach (var itemBuilt in Enum.GetValues(typeof(BuiltInCategory))) { foreach (var itemString in CategoryList) { string s = itemBuilt.ToString(); if (s == itemString) { builtInCategories.Add((BuiltInCategory)itemBuilt); } } } var multiCat = new ElementMulticategoryFilter(builtInCategories); return(multiCat); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { // get UIdocument UIDocument uidoc = commandData.Application.ActiveUIDocument; //get document Document doc = uidoc.Document; //Tag parameters TagMode tmode = TagMode.TM_ADDBY_CATEGORY; TagOrientation torient = TagOrientation.Horizontal; List <BuiltInCategory> cats = new List <BuiltInCategory>(); cats.Add(BuiltInCategory.OST_Windows); cats.Add(BuiltInCategory.OST_Doors); ElementMulticategoryFilter filter = new ElementMulticategoryFilter(cats); IList <Element> telements = new FilteredElementCollector(doc, doc.ActiveView.Id) .WherePasses(filter) .WhereElementIsNotElementType() .ToElements(); try { using (Transaction trans = new Transaction(doc, "create plan view")) { trans.Start(); // tag elements foreach (Element ele in telements) { Reference refe = new Reference(ele); LocationPoint loc = ele.Location as LocationPoint; XYZ point = loc.Point; IndependentTag tag = IndependentTag.Create(doc, doc.ActiveView.Id, refe, true, tmode, torient, point); } trans.Commit(); } return(Result.Succeeded); } catch (Exception e) { message = e.Message; return(Result.Failed); } }
public static (Dictionary <string, double>, Dictionary <int, string>) metregardecorps(List <Document> docs) { Dictionary <string, double> typegardecorps = new Dictionary <string, double>(); Dictionary <int, string> erreursgc = new Dictionary <int, string>(); int erreurgardecorps = 0; foreach (Document doc in docs) { ElementMulticategoryFilter multigc = new ElementMulticategoryFilter(new BuiltInCategory[] { BuiltInCategory.OST_Railings, BuiltInCategory.OST_StairsRailing }); IList <Element> gardecorps = new FilteredElementCollector(doc).WherePasses(multigc).WhereElementIsNotElementType().ToList(); foreach (Element rail in gardecorps) { string typegarde = rail.Name; int gardeid = rail.GetTypeId().IntegerValue; try { double longueur = rail.LookupParameter("Longueur").AsDouble(); longueur = UnitUtils.ConvertFromInternalUnits(longueur, DisplayUnitType.DUT_METERS); longueur = Math.Round(longueur, 2); if (typegardecorps.ContainsKey(typegarde)) { typegardecorps[typegarde] += longueur; } else { typegardecorps.Add(typegarde, longueur); } } catch { if (typegarde == "") { typegarde = "AUCUN NOM DE TYPE"; } erreurgardecorps += 1; if (erreursgc.ContainsKey(gardeid) == false) { erreursgc.Add(gardeid, typegarde); } } } } return(typegardecorps, erreursgc); }
public void Publish(RevitToGraphPublisherSettings settings, Neo4jClient client) { var meGraph = new MEPRevitGraph(); MEPRevitGraphWriter mps = new MEPRevitGraphWriter(meGraph); if (settings.IncludeElectrical) { mps.Parsers.Add(new Parsers.MEPGraphParserElectrical()); } if (settings.IncludeMechanical) { mps.Parsers.Add(new Parsers.MEPGraphParserConnectors()); } if (settings.IncludeBoundaries) { mps.Parsers.Add(new Parsers.MEPGraphParserSpaces()); } //if (settings.IncludeBoundaries) mps.Parsers.Add(new Parsers.ClashDetection()); mps.Parsers.Add(new Parsers.MEPGraphParserIoT()); if (mps.Parsers.Count == 0) { return; } var mecFEc = new FilteredElementCollector(_rdoc); var mecFilter = mps.GetFilterForAllParsers; var mecElements = mecFEc.WherePasses(mecFilter).WhereElementIsNotElementType().ToElements(); var wfic = new FilteredElementCollector(_rdoc); var geoElementsFilter = new ElementMulticategoryFilter(new BuiltInCategory[] { BuiltInCategory.OST_Floors, BuiltInCategory.OST_Roofs, BuiltInCategory.OST_Windows, BuiltInCategory.OST_Doors, BuiltInCategory.OST_MEPSpaces, BuiltInCategory.OST_Rooms }); var geoElements = wfic.WherePasses(geoElementsFilter).WhereElementIsNotElementType().ToElements(); using (Transaction tx = new Transaction(_rdoc, "Build graph")) { tx.Start("Build graph"); mps.Write(mecElements, geoElements, -1, true, _rdoc); tx.Commit(); } MEPGraphWriter wre = new MEPGraphWriter(client); wre.Write(meGraph, _rdoc); }
public ObservableCollection <ElementItem> ElementListData() { ObservableCollection <ElementItem> elementItems = new ObservableCollection <ElementItem>(); List <BuiltInCategory> builtInCategory = new List <BuiltInCategory>(); builtInCategory.Add(BuiltInCategory.OST_Walls); builtInCategory.Add(BuiltInCategory.OST_Floors); ElementMulticategoryFilter multuFilter = new ElementMulticategoryFilter(builtInCategory); IList <Element> elements = new FilteredElementCollector(DOC).WherePasses(multuFilter).WhereElementIsNotElementType().ToElements(); foreach (var element in elements) { ElementItem elementItem = new ElementItem(); elementItem.ModelId = element.Id; elementItem.ItemName = element.Name; elementItems.Add(elementItem); } return(elementItems); }
bool CreateGeneralDrawing(Document sourceDocument, Document destinationDocument, ElementId titleBlockTypeId, ViewSheet viewSheet) { try { ViewSheet destiationView = ViewSheet.Create(destinationDocument, titleBlockTypeId); destiationView.SheetNumber = viewSheet.SheetNumber.Replace("D1_", "").Replace("D2_", ""); destiationView.Name = viewSheet.Name; IList <ElementId> copyElemIdList = new List <ElementId>(); ElementMulticategoryFilter categoryFilter = new ElementMulticategoryFilter(new List <BuiltInCategory> { BuiltInCategory.OST_LegendComponents, BuiltInCategory.OST_TextNotes, BuiltInCategory.OST_Lines, BuiltInCategory.OST_GenericAnnotation, BuiltInCategory.OST_InsulationLines, BuiltInCategory.OST_Dimensions, BuiltInCategory.OST_IOSDetailGroups, BuiltInCategory.OST_RevisionClouds, BuiltInCategory.OST_RevisionCloudTags, BuiltInCategory.OST_DetailComponents, BuiltInCategory.OST_DetailComponentTags }); FilteredElementCollector elems = new FilteredElementCollector(sourceDocument, viewSheet.Id); foreach (Element elem in elems.WherePasses(categoryFilter)) { if (elem.GroupId.IntegerValue == -1) { copyElemIdList.Add(elem.Id); } } CopyPasteOptions options = new CopyPasteOptions(); options.SetDuplicateTypeNamesHandler(new ElementCopyCoverHandler()); ElementTransformUtils.CopyElements(viewSheet, copyElemIdList, destiationView, Transform.CreateTranslation(new XYZ(0, 0, 0)), options); } catch { return(false); } return(true); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Application app = commandData.Application.Application; UIDocument uidoc = commandData.Application.ActiveUIDocument; Document doc = uidoc.Document; ICollection<ElementId> selectedIds = uidoc.Selection.GetElementIds(); if (selectedIds.Any()) { List<ElementId> selectedCategories = selectedIds.ToList().Select(x => doc.GetElement(x)).Select(x => x.Category.Id).Distinct().ToList(); ElementMulticategoryFilter multiCategoryFilter = new ElementMulticategoryFilter(selectedCategories); ICollection<ElementId> idsToSelect = new FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(multiCategoryFilter).ToElementIds(); uidoc.Selection.SetElementIds(idsToSelect); } else { return Result.Failed; } return Result.Succeeded; }
public SpeckleConversionFixture() { ElementMulticategoryFilter filter = new ElementMulticategoryFilter(Categories); //get selection before opening docs, if any Selection = xru.GetActiveSelection(); SourceDoc = xru.OpenDoc(TestFile); if (UpdatedTestFile != null) { UpdatedDoc = xru.OpenDoc(UpdatedTestFile); UpdatedRevitElements = new FilteredElementCollector(UpdatedDoc).WhereElementIsNotElementType().WherePasses(filter).ToElements(); } if (NewFile != null) { NewDoc = xru.CreateNewDoc(TemplateFile, NewFile); } RevitElements = new FilteredElementCollector(SourceDoc).WhereElementIsNotElementType().WherePasses(filter).ToElements(); }
/// <summary> /// Lấy về tất cả Column/Wall đụng e theo phương đứng /// </summary> /// <param name="e"></param> /// <returns></returns> internal List <ElementId> GetColumnWallBoundingBoxIntersects(Element e) { ICollection <BuiltInCategory> categories = new List <BuiltInCategory>(); categories.Add(BuiltInCategory.OST_StructuralColumns); categories.Add(BuiltInCategory.OST_Columns); categories.Add(BuiltInCategory.OST_Walls); ElementMulticategoryFilter categoryFilter = new ElementMulticategoryFilter(categories); BoundingBoxXYZ box = e.get_BoundingBox(null); XYZ min = new XYZ( box.Min.X + DLQUnitUtils.MmToFeet(10), box.Min.Y + DLQUnitUtils.MmToFeet(10), box.Min.Z - DLQUnitUtils.MmToFeet(10)); XYZ max = new XYZ( box.Max.X - DLQUnitUtils.MmToFeet(10), box.Max.Y - DLQUnitUtils.MmToFeet(10), box.Max.Z + DLQUnitUtils.MmToFeet(10)); Outline outline = new Outline(min, max); BoundingBoxIntersectsFilter bbFilter = new BoundingBoxIntersectsFilter(outline); LogicalAndFilter logicalAndFilter = new LogicalAndFilter(bbFilter, categoryFilter); return(new FilteredElementCollector(e.Document) .WherePasses(logicalAndFilter) .Excluding(new List <ElementId>() { e.Id }) .Select(el => el.Id) .ToList()); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Application app = uiapp.Application; Document doc = uidoc.Document; //access to the Revit selection methods Autodesk.Revit.UI.Selection.Selection sel = uidoc.Selection; //provides a filtered selection ElementMulticategoryFilter multicategoryFilter = new ElementMulticategoryFilter(TargetCategories()); var filter = Utilities.SelFilter.GetElementFilter(multicategoryFilter); //prompt the user for a selection IList <Reference> selectionReference; try { selectionReference = sel.PickObjects(ObjectType.Element, filter); } catch (Exception) { //land here if someone cancels the pick operation return(Result.Cancelled); } //try to export to JSON on the desktop bool result = RevitElementsToHypar(doc, selectionReference.Select(e => e.ElementId).ToList()); if (result) { return(Result.Succeeded); } return(Result.Failed); }
//---------------------------------------------------------- public void Get_Family(Document doc, ComboBox category, ComboBox family, All_Data myAll_Data) { mySupport_All = new Support_All(); try { category_data item = (category_data)category.SelectedItem; ElementMulticategoryFilter filter_category = new ElementMulticategoryFilter(new List <BuiltInCategory>() { item.builtin }); my_family_data = new ObservableCollection <family_data>(new FilteredElementCollector(doc) .WherePasses(filter_category) .WhereElementIsElementType() .Cast <ElementType>() .GroupBy(x => new { x.FamilyName, }) .ToList().Select(x => new family_data() { single_value = x.Key.FamilyName, path_image = mySupport_All.CreatePreview(x.First(), myAll_Data), types = x.Select(y => y).ToList() }).OrderBy(x => x.single_value)); family.ItemsSource = my_family_data; family.SelectedIndex = 0; CollectionView view_family = (CollectionView)CollectionViewSource.GetDefaultView(family.ItemsSource); view_family.SortDescriptions.Add(new SortDescription("single_value", ListSortDirection.Ascending)); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public Result OnStartup(UIControlledApplication application) { if (!Directory.Exists(Utills.path)) { Directory.CreateDirectory(Utills.path); } application.ControlledApplication.DocumentChanged += ControlledApplication_DocumentChanged; updater = new UpdaterDeleted(new AddInId(new Guid("023e2e36-adc7-3448-b1e0-d851ac1c40c0"))); UpdaterRegistry.RegisterUpdater(updater, false); List <BuiltInCategory> inCategories = new List <BuiltInCategory>(); inCategories.Add(BuiltInCategory.OST_Floors); inCategories.Add(BuiltInCategory.OST_Walls); inCategories.Add(BuiltInCategory.OST_Conduit); inCategories.Add(BuiltInCategory.OST_StructuralFraming); inCategories.Add(BuiltInCategory.OST_PipeCurves); inCategories.Add(BuiltInCategory.OST_PipeFitting); inCategories.Add(BuiltInCategory.OST_DuctFitting); inCategories.Add(BuiltInCategory.OST_DuctCurves); inCategories.Add(BuiltInCategory.OST_CableTray); inCategories.Add(BuiltInCategory.OST_CableTrayFitting); inCategories.Add(BuiltInCategory.OST_GenericAnnotation); inCategories.Add(BuiltInCategory.OST_WallTags); inCategories.Add(BuiltInCategory.OST_Windows); inCategories.Add(BuiltInCategory.OST_Ceilings); ElementMulticategoryFilter multi = new ElementMulticategoryFilter(inCategories); UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), multi, Element.GetChangeTypeElementDeletion()); return(Result.Succeeded); }
/// <summary> /// Gets element filter that match certain types. /// </summary> /// <param name="forSpatialElements">True if to get filter for spatial element, false for other elements.</param> /// <returns>The element filter.</returns> private static ElementFilter GetClassFilter(bool forSpatialElements) { if (forSpatialElements) { return new ElementClassFilter(typeof(SpatialElement)); } else { List<Type> excludedTypes = new List<Type>(); // FamilyInstances are handled in separate filter. excludedTypes.Add(typeof(FamilyInstance)); excludedTypes.Add(typeof(SpatialElement)); if (!ExporterCacheManager.ExportOptionsCache.ExportAnnotations) excludedTypes.Add(typeof(CurveElement)); excludedTypes.Add(typeof(ElementType)); excludedTypes.Add(typeof(Group)); excludedTypes.Add(typeof(BaseArray)); excludedTypes.Add(typeof(FillPatternElement)); excludedTypes.Add(typeof(LinePatternElement)); excludedTypes.Add(typeof(Material)); excludedTypes.Add(typeof(GraphicsStyle)); excludedTypes.Add(typeof(Family)); excludedTypes.Add(typeof(SketchPlane)); excludedTypes.Add(typeof(View)); excludedTypes.Add(typeof(Autodesk.Revit.DB.Structure.LoadBase)); excludedTypes.Add(typeof(BeamSystem)); // curtain wall sub-types we are ignoring. excludedTypes.Add(typeof(CurtainGridLine)); // excludedTypes.Add(typeof(Mullion)); // this will be gotten from the element(s) it cuts. excludedTypes.Add(typeof(Opening)); // 2D types we are ignoring excludedTypes.Add(typeof(SketchBase)); excludedTypes.Add(typeof(FaceSplitter)); // 2D types covered by the element owner view filter excludedTypes.Add(typeof(TextNote)); excludedTypes.Add(typeof(FilledRegion)); // exclude levels that are covered in BeginExport excludedTypes.Add(typeof(Level)); // exclude analytical models excludedTypes.Add(typeof(Autodesk.Revit.DB.Structure.AnalyticalModel)); ElementFilter excludedClassFilter = new ElementMulticlassFilter(excludedTypes, true); List<BuiltInCategory> excludedCategories = new List<BuiltInCategory>(); // Native Revit types without match in API excludedCategories.Add(BuiltInCategory.OST_Property); excludedCategories.Add(BuiltInCategory.OST_SiteProperty); excludedCategories.Add(BuiltInCategory.OST_SitePropertyLineSegment); excludedCategories.Add(BuiltInCategory.OST_Viewports); excludedCategories.Add(BuiltInCategory.OST_Views); excludedCategories.Add(BuiltInCategory.OST_IOS_GeoLocations); excludedCategories.Add(BuiltInCategory.OST_RvtLinks); excludedCategories.Add(BuiltInCategory.OST_DecalElement); //excludedCategories.Add(BuiltInCategory.OST_Parts); excludedCategories.Add(BuiltInCategory.OST_DuctCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_DuctFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_PipeCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_PipeFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_ConduitCenterLine); excludedCategories.Add(BuiltInCategory.OST_ConduitFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_FlexDuctCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_FlexPipeCurvesCenterLine); ElementMulticategoryFilter excludedCategoryFilter = new ElementMulticategoryFilter(excludedCategories, true); LogicalAndFilter exclusionFilter = new LogicalAndFilter(excludedClassFilter, excludedCategoryFilter); ElementOwnerViewFilter ownerViewFilter = new ElementOwnerViewFilter(ElementId.InvalidElementId); LogicalAndFilter returnedFilter = new LogicalAndFilter(exclusionFilter, ownerViewFilter); return returnedFilter; } }
/// <summary> /// Gets element filter that match certain types. /// </summary> /// <param name="forSpatialElements">True if to get filter for spatial element, false for other elements.</param> /// <returns>The element filter.</returns> private static ElementFilter GetClassFilter(bool forSpatialElements) { if (forSpatialElements) { return(new ElementClassFilter(typeof(SpatialElement))); } else { List <Type> excludedTypes = new List <Type>(); // FamilyInstances are handled in separate filter. excludedTypes.Add(typeof(FamilyInstance)); // Spatial element are exported in a separate pass. excludedTypes.Add(typeof(SpatialElement)); // AreaScheme elements are exported as groups after all Areas have been exported. excludedTypes.Add(typeof(AreaScheme)); // FabricArea elements are exported as groups after all FabricSheets have been exported. excludedTypes.Add(typeof(FabricArea)); if (!ExporterCacheManager.ExportOptionsCache.ExportAnnotations) { excludedTypes.Add(typeof(CurveElement)); } excludedTypes.Add(typeof(ElementType)); excludedTypes.Add(typeof(BaseArray)); excludedTypes.Add(typeof(FillPatternElement)); excludedTypes.Add(typeof(LinePatternElement)); excludedTypes.Add(typeof(Material)); excludedTypes.Add(typeof(GraphicsStyle)); excludedTypes.Add(typeof(Family)); excludedTypes.Add(typeof(SketchPlane)); excludedTypes.Add(typeof(View)); excludedTypes.Add(typeof(Autodesk.Revit.DB.Structure.LoadBase)); // curtain wall sub-types we are ignoring. excludedTypes.Add(typeof(CurtainGridLine)); // excludedTypes.Add(typeof(Mullion)); // this will be gotten from the element(s) it cuts. excludedTypes.Add(typeof(Opening)); // 2D types we are ignoring excludedTypes.Add(typeof(SketchBase)); excludedTypes.Add(typeof(FaceSplitter)); // 2D types covered by the element owner view filter excludedTypes.Add(typeof(TextNote)); excludedTypes.Add(typeof(FilledRegion)); // exclude levels that are covered in BeginExport excludedTypes.Add(typeof(Level)); // exclude analytical models excludedTypes.Add(typeof(Autodesk.Revit.DB.Structure.AnalyticalElement)); ElementFilter excludedClassFilter = new ElementMulticlassFilter(excludedTypes, true); List <BuiltInCategory> excludedCategories = new List <BuiltInCategory>(); // Native Revit types without match in API excludedCategories.Add(BuiltInCategory.OST_ConduitCenterLine); excludedCategories.Add(BuiltInCategory.OST_ConduitFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_DecalElement); //excludedCategories.Add(BuiltInCategory.OST_Parts); //excludedCategories.Add(BuiltInCategory.OST_RvtLinks); excludedCategories.Add(BuiltInCategory.OST_DuctCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_DuctFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_FlexDuctCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_FlexPipeCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_IOS_GeoLocations); excludedCategories.Add(BuiltInCategory.OST_PipeCurvesCenterLine); excludedCategories.Add(BuiltInCategory.OST_PipeFittingCenterLine); excludedCategories.Add(BuiltInCategory.OST_Property); excludedCategories.Add(BuiltInCategory.OST_SiteProperty); excludedCategories.Add(BuiltInCategory.OST_SitePropertyLineSegment); excludedCategories.Add(BuiltInCategory.OST_TopographyContours); excludedCategories.Add(BuiltInCategory.OST_Viewports); excludedCategories.Add(BuiltInCategory.OST_Views); // Exclude elements with no category. excludedCategories.Add(BuiltInCategory.INVALID); ElementMulticategoryFilter excludedCategoryFilter = new ElementMulticategoryFilter(excludedCategories, true); LogicalAndFilter exclusionFilter = new LogicalAndFilter(excludedClassFilter, excludedCategoryFilter); ElementOwnerViewFilter ownerViewFilter = new ElementOwnerViewFilter(ElementId.InvalidElementId); LogicalAndFilter returnedFilter = new LogicalAndFilter(exclusionFilter, ownerViewFilter); return(returnedFilter); } }