public static IEnumerable <Autodesk.Revit.DB.Level> GetAllLevels() { var collector = new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); collector.OfClass(typeof(Autodesk.Revit.DB.Level)); return(collector.ToElements().Cast <Autodesk.Revit.DB.Level>()); }
protected override void TrySolveInstance(IGH_DataAccess DA) { if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc)) { return; } if (!Params.TryGetData(DA, "Name", out string name)) { return; } if (!Params.TryGetData(DA, "Filter", out DB.ElementFilter filter, x => x.IsValidObject)) { return; } using (var collector = new DB.FilteredElementCollector(doc)) { var locationsCollector = collector.WherePasses(ElementFilter); if (filter is object) { locationsCollector = locationsCollector.WherePasses(filter); } var locations = collector.Cast <DB.SiteLocation>(); if (name is object) { locations = locations.Where(x => x.Name.IsSymbolNameLike(name)); } DA.SetDataList("Site Locations", locations.Select(x => new Types.SiteLocation(x))); } }
public ADSK.FilteredElementCollector AddElementFilters(ADSK.FilteredElementCollector collector) { ADSK.ElementMulticategoryFilter filter = new ADSK.ElementMulticategoryFilter(new List <ADSK.BuiltInCategory> { ADSK.BuiltInCategory.OST_Columns, ADSK.BuiltInCategory.OST_StructuralColumns }, false); return(collector.WherePasses(filter)); }
protected override void TrySolveInstance(IGH_DataAccess DA) { if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc)) { return; } if (!Params.TryGetData(DA, "Name", out string name)) { return; } if (!Params.TryGetData(DA, "Elevation", out Interval? elevation, x => x.IsValid)) { return; } if (!Params.TryGetData(DA, "Filter", out DB.ElementFilter filter, x => x.IsValidObject)) { return; } using (var collector = new DB.FilteredElementCollector(doc)) { var gridsCollector = collector.WherePasses(ElementFilter); if (filter is object) { gridsCollector = gridsCollector.WherePasses(filter); } if (TryGetFilterStringParam(DB.BuiltInParameter.DATUM_TEXT, ref name, out var nameFilter)) { gridsCollector = gridsCollector.WherePasses(nameFilter); } var grids = gridsCollector.Cast <DB.Grid>(); if (!string.IsNullOrEmpty(name)) { grids = grids.Where(x => x.Name.IsSymbolNameLike(name)); } if (elevation.HasValue) { var height = elevation.Value.InHostUnits() + doc.GetBasePointLocation(Params.Input <Parameters.ElevationInterval>("Elevation").ElevationBase).Z; grids = grids.Where ( x => { var extents = x.GetExtents(); var interval = new Interval(extents.MinimumPoint.Z, extents.MaximumPoint.Z); return(Interval.FromIntersection(height, interval).IsValid); } ); } DA.SetDataList("Grids", grids); } }
private DB.Transform GetTransform() { if (InternalElement.Document.GetHashCode() == DocumentManager.Instance.CurrentDBDocument.GetHashCode()) { return(DB.Transform.Identity); } else { //Find the revit instance where we find the room DB.FilteredElementCollector collector = new DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); List <DB.RevitLinkInstance> linkInstances = collector.OfCategory(DB.BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements().Cast <DB.RevitLinkInstance>().ToList(); DB.RevitLinkInstance roomLinkInstance = linkInstances.FirstOrDefault(); foreach (DB.RevitLinkInstance linkInstance in linkInstances) { if (linkInstance.GetLinkDocument().GetHashCode() == InternalElement.Document.GetHashCode()) { roomLinkInstance = linkInstance; break; } } return(roomLinkInstance.GetTotalTransform()); } }
private void RefreshLevelList(ListBox listBox) { var doc = Revit.ActiveUIDocument.Document; listBox.SelectedIndexChanged -= ListBox_SelectedIndexChanged; listBox.DisplayMember = "DisplayName"; listBox.Items.Clear(); using (var collector = new DB.FilteredElementCollector(doc).OfClass(typeof(DB.Level))) { var levels = collector.Cast <DB.Level>(). OrderBy(x => x.GetHeight()). Select(x => new Types.Level(x)). ToList(); foreach (var level in levels) { listBox.Items.Add(level); } var selectedItems = levels.Intersect(PersistentData.OfType <Types.Level>()); foreach (var item in selectedItems) { listBox.SelectedItems.Add(item); } } listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged; }
public ADSK.ElementId[] ToRevit(Elements.Element hyparElement, LoadContext context) { var createdElements = new List <ADSK.ElementId>(); var floor = hyparElement as Elements.Floor; var curves = floor.Profile.Perimeter.ToRevitCurveArray(true); var floorType = new ADSK.FilteredElementCollector(context.Document) .OfClass(typeof(ADSK.FloorType)) .OfType <ADSK.FloorType>() .First(e => e.Name.Contains("Generic")); double offsetFromLevel = 0; var level = context.Level ?? FromHyparExtensions.GetLevelClosestToZ(Units.MetersToFeet(floor.Elevation), context.Document, out offsetFromLevel); var rvtFloor = context.Document.Create.NewFloor(curves, floorType, level, false, ADSK.XYZ.BasisZ); context.Document.Regenerate(); // we must regenerate the document before adding openings var allOpenings = floor.Openings.Select(o => o.Perimeter).Union(floor.Profile.Voids); foreach (var opening in allOpenings) { var openingProfile = opening.ToRevitCurveArray(true); var rvtOpen = context.Document.Create.NewOpening(rvtFloor, openingProfile, true); createdElements.Add(rvtOpen.Id); } offsetFromLevel += Units.MetersToFeet(floor.Thickness); rvtFloor.LookupParameter("Height Offset From Level")?.Set(Units.MetersToFeet(offsetFromLevel)); createdElements.Add(rvtFloor.Id); return(createdElements.ToArray()); }
private void InitializeListData() { if (null == m_wallTypeList || null == m_levelList) { throw new Exception("necessary data members don't initialize."); } RevitDB.Document document = m_commandData.Application.ActiveUIDocument.Document; RevitDB.FilteredElementCollector filteredElementCollector = new RevitDB.FilteredElementCollector(document); filteredElementCollector.OfClass(typeof(RevitDB.WallType)); m_wallTypeList = filteredElementCollector.Cast <RevitDB.WallType>().ToList <RevitDB.WallType>(); WallTypeComparer comparer = new WallTypeComparer(); m_wallTypeList.Sort(comparer); RevitDB.FilteredElementIterator iter = (new RevitDB.FilteredElementCollector(document)).OfClass(typeof(RevitDB.Level)).GetElementIterator(); iter.Reset(); while (iter.MoveNext()) { RevitDB.Level level = iter.Current as RevitDB.Level; if (null == level) { continue; } m_levelList.Add(level); } }
protected override void TrySolveInstance(IGH_DataAccess DA) { if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc)) { return; } DA.DisableGapLogic(); DB.ElementFilter filter = null; if (!DA.GetData("Filter", ref filter)) { return; } using (var collector = new DB.FilteredElementCollector(doc)) { DA.SetDataList ( "Elements", collector. WherePasses(ElementFilter). WherePasses(filter). Select(x => Types.Element.FromElement(x)) ); } }
protected override void Menu_AppendPromptOne(ToolStripDropDown menu) { if (SourceCount != 0) { return; } var listBox = new ListBox(); listBox.BorderStyle = BorderStyle.FixedSingle; listBox.Width = (int)(200 * GH_GraphicsUtil.UiScale); listBox.Height = (int)(100 * GH_GraphicsUtil.UiScale); listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged; listBox.Sorted = true; var materialCategoryBox = new ComboBox(); materialCategoryBox.DropDownStyle = ComboBoxStyle.DropDownList; materialCategoryBox.Width = (int)(200 * GH_GraphicsUtil.UiScale); materialCategoryBox.Tag = listBox; materialCategoryBox.SelectedIndexChanged += MaterialCategoryBox_SelectedIndexChanged; materialCategoryBox.SetCueBanner("Material class filter…"); materialCategoryBox.Sorted = true; using (var collector = new DB.FilteredElementCollector(Revit.ActiveUIDocument.Document)) { listBox.Items.Clear(); var materials = collector. OfClass(typeof(DB.Material)). Cast <DB.Material>(). GroupBy(x => x.MaterialClass); foreach (var cat in materials) { materialCategoryBox.Items.Add(cat.Key); } if (Current?.Value is DB.Material current) { var familyIndex = 0; foreach (var materialClass in materialCategoryBox.Items.Cast <string>()) { if (current.MaterialClass == materialClass) { materialCategoryBox.SelectedIndex = familyIndex; break; } familyIndex++; } } else { RefreshMaterialsList(listBox, default); } } Menu_AppendCustomItem(menu, materialCategoryBox); Menu_AppendCustomItem(menu, listBox); }
protected override void TrySolveInstance(IGH_DataAccess DA, DB.Document doc) { // grab wall system family from input var wallKind = DB.WallKind.Unknown; if (!DA.GetData("Wall System Family", ref wallKind)) { return; } // collect wall instances based on the given wallkind using (var collector = new DB.FilteredElementCollector(doc)) { IEnumerable <Types.Element> walls; if (wallKind == DB.WallKind.Basic) { walls = collector.OfClass(typeof(DB.Wall)) .Cast <DB.Wall>() .Where(x => x.WallType.Kind == wallKind && !x.IsStackedWallMember) .Select(x => Types.Element.FromElement(x)); } else { walls = collector.OfClass(typeof(DB.Wall)) .Where(x => ((DB.Wall)x).WallType.Kind == wallKind) .Select(x => Types.Element.FromElement(x)); } DA.SetDataList("Walls", walls); } }
public static IDictionary GetViewTemplates( [DefaultArgument("Synthetic.Revit.Document.Current()")] Autodesk.Revit.DB.Document doc ) { IList <ViewTemplate> templates = new List <ViewTemplate>(); IList <string> templateNames = new List <string>(); IList <revitDB.ElementId> templateIds = new List <revitDB.ElementId>(); if (doc != null) { revitDB.FilteredElementCollector collector = new revitDB.FilteredElementCollector(doc); List <revitDB.View> views = collector.OfClass(typeof(revitDB.View)) .Cast <revitDB.View>() .Where(view => view.IsTemplate) .Select(view => { templates.Add(new ViewTemplate(view)); templateNames.Add(view.Name); templateIds.Add(view.Id); return(view); }) .ToList <revitDB.View>(); } return(new Dictionary <string, object> { { "templates", templates }, { "template names", templateNames }, { "template IDs", templateIds } }); }
/// <summary> /// Populate the Dropdown menu /// </summary> public void PopulateItems() { if (this.ElementType != null) { // Clear the Items Items.Clear(); // Set up a new element collector using the Type field var fec = new RVT.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument).OfClass(ElementType); // If there is nothing in the collector add the missing Type message to the Dropdown menu. if (fec.ToElements().Count == 0) { Items.Add(new CoreNodeModels.DynamoDropDownItem(noTypes, null)); SelectedIndex = 0; return; } if (this.ElementType.FullName == "Autodesk.Revit.DB.Structure.RebarHookType") { Items.Add(new CoreNodeModels.DynamoDropDownItem("None", null)); } // Walk through all elements in the collector and add them to the dropdown foreach (var ft in fec.ToElements()) { Items.Add(new CoreNodeModels.DynamoDropDownItem(ft.Name, ft)); } Items = Items.OrderBy(x => x.Name).ToObservableCollection(); } }
protected override void TrySolveInstance(IGH_DataAccess DA) { var doc = Revit.ActiveDBDocument; var color = default(System.Drawing.Color); if (!DA.GetData("Color", ref color)) { return; } string name = color.A == 255 ? $"RGB {color.R} {color.G} {color.B}" : $"RGB {color.R} {color.G} {color.B} {color.A}"; var material = default(DB.Material); using (var collector = new DB.FilteredElementCollector(doc).OfClass(typeof(DB.Material))) material = collector.Where(x => x.Name == name).Cast <DB.Material>().FirstOrDefault(); bool materialIsNew = material is null; if (materialIsNew) { material = doc.GetElement(DB.Material.Create(doc, name)) as DB.Material; } if (material.MaterialClass != "RGB") { material.MaterialClass = "RGB"; } if (material.MaterialCategory != "RGB") { material.MaterialCategory = "RGB"; } var newColor = color.ToHost(); if (newColor.Red != material.Color.Red || newColor.Green != material.Color.Green || newColor.Blue != material.Color.Blue) { material.Color = newColor; } var newTransparency = (int)Math.Round((255 - color.A) * 100.0 / 255.0); if (material.Transparency != newTransparency) { material.Transparency = newTransparency; } var newShininess = (int)Math.Round(0.5 * 128.0); if (newShininess != material.Shininess) { material.Shininess = newShininess; } DA.SetData("Material", material); }
protected override void Menu_AppendPromptOne(ToolStripDropDown menu) { if (SourceCount != 0) { return; } var listBox = new ListBox(); listBox.BorderStyle = BorderStyle.FixedSingle; listBox.Width = (int)(200 * GH_GraphicsUtil.UiScale); listBox.Height = (int)(100 * GH_GraphicsUtil.UiScale); listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged; listBox.Sorted = true; var patternTargetBox = new ComboBox(); patternTargetBox.DropDownStyle = ComboBoxStyle.DropDownList; patternTargetBox.Width = (int)(200 * GH_GraphicsUtil.UiScale); patternTargetBox.Tag = listBox; patternTargetBox.SelectedIndexChanged += PatternTargetBox_SelectedIndexChanged; patternTargetBox.SetCueBanner("Fill Pattern target filter…"); patternTargetBox.Sorted = true; using (var collector = new DB.FilteredElementCollector(Revit.ActiveUIDocument.Document)) { listBox.Items.Clear(); var patterns = collector. OfClass(typeof(DB.FillPatternElement)). Cast <DB.FillPatternElement>(). GroupBy(x => x.GetFillPattern().Target); foreach (var pattern in patterns) { patternTargetBox.Items.Add(pattern.Key); } if (Current?.Value is DB.FillPatternElement current) { var targetIndex = 0; foreach (var patternTarget in patternTargetBox.Items.Cast <DB.FillPatternTarget>()) { if (current.GetFillPattern().Target == patternTarget) { patternTargetBox.SelectedIndex = targetIndex; break; } targetIndex++; } } else { patternTargetBox.SelectedIndex = (int)DB.FillPatternTarget.Drafting; } } Menu_AppendCustomItem(menu, patternTargetBox); Menu_AppendCustomItem(menu, listBox); }
protected override void TrySolveInstance(IGH_DataAccess DA) { // grab input DB.Wall wallInstance = default; if (!DA.GetData("Curtain Wall", ref wallInstance)) { return; } // only process curtain walls if (wallInstance.WallType.Kind == DB.WallKind.Curtain) { DA.SetData("Curtain Grid", new Types.DataObject <DB.CurtainGrid>(wallInstance.CurtainGrid, srcDocument: wallInstance.Document)); // determine if curtain wall is embeded in another wall // find all the wall elements that are intersecting the bbox of this wall var bbox = wallInstance.get_BoundingBox(null); var outline = new DB.Outline(bbox.Min, bbox.Max); var bbf = new DB.BoundingBoxIntersectsFilter(outline); var walls = new DB.FilteredElementCollector(wallInstance.Document).WherePasses(bbf).OfClass(typeof(DB.Wall)).ToElements(); // ask for embedded wall inserts from these instances foreach (DB.Wall wall in walls) { var embeddedWalls = wall.FindInserts(addRectOpenings: false, includeShadows: false, includeEmbeddedWalls: true, includeSharedEmbeddedInserts: false); if (embeddedWalls.Contains(wallInstance.Id)) { DA.SetData("Host Wall", Types.Element.FromElement(wall)); break; } } } }
protected override void TrySolveInstance(IGH_DataAccess DA, DB.Document doc) { string name = null; DA.GetData("Name", ref name); DB.ElementFilter filter = null; DA.GetData("Filter", ref filter); using (var collector = new DB.FilteredElementCollector(doc)) { var elementCollector = collector.WherePasses(ElementFilter); if (filter is object) { elementCollector = elementCollector.WherePasses(filter); } var elementTypes = elementCollector.Cast <DB.ElementType>(); var familiesSet = new HashSet <string>(elementTypes.Select(x => x.FamilyName)); var families = familiesSet.AsEnumerable().Where(x => x != string.Empty); if (name is object) { families = families.Where(x => x.IsSymbolNameLike(name)); } DA.SetDataList("Families", families); } }
private void RefreshViewsList(ListBox listBox, DB.ViewFamily viewFamily) { var doc = Revit.ActiveUIDocument.Document; listBox.SelectedIndexChanged -= ListBox_SelectedIndexChanged; listBox.Items.Clear(); using (var collector = new DB.FilteredElementCollector(doc)) { var views = collector. OfClass(typeof(DB.View)). Cast <DB.View>(). Where(x => !x.IsTemplate). Where(x => viewFamily == DB.ViewFamily.Invalid || x.Document.GetElement <DB.ViewFamilyType>(x.GetTypeId())?.ViewFamily == viewFamily); listBox.DisplayMember = "DisplayName"; foreach (var view in views) { listBox.Items.Add(new Types.View(view)); } } listBox.SelectedIndex = listBox.Items.OfType <Types.View>().IndexOf(Current, 0).FirstOr(-1); listBox.SelectedIndexChanged += ListBox_SelectedIndexChanged; }
/// <summary> /// Populate the Dropdown menu /// </summary> public override void PopulateItems() { if (this.ElementType != null) { // Clear the Items Items.Clear(); // Set up a new element collector using the Type field var fec = new RVT.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument).OfClass(ElementType); // If there is nothing in the collector add the missing Type message to the Dropdown menu. if (fec.ToElements().Count == 0) { Items.Add(new DSCoreNodesUI.DynamoDropDownItem(noTypes, null)); SelectedIndex = 0; return; } if (this.ElementType.FullName == "Autodesk.Revit.DB.Structure.RebarHookType") Items.Add(new DSCoreNodesUI.DynamoDropDownItem("None", null)); // Walk through all elements in the collector and add them to the dropdown foreach (var ft in fec.ToElements()) { Items.Add(new DSCoreNodesUI.DynamoDropDownItem(ft.Name, ft)); } Items = Items.OrderBy(x => x.Name).ToObservableCollection(); } }
/// <summary> /// Get Base or SurveyPoint /// </summary> /// <param name="surveypoint"></param> /// <returns></returns> private static Point GetBaseOrSurveyPoint(bool surveypoint) { // Get Base or Survey point category RVT.BuiltInCategory category = (surveypoint)? RVT.BuiltInCategory.OST_SharedBasePoint : RVT.BuiltInCategory.OST_ProjectBasePoint; // Get Revit document RVT.Document doc = RevitServices.Persistence.DocumentManager.Instance.CurrentDBDocument; // Get all elements of the previously selected category Autodesk.Revit.DB.FilteredElementCollector collector = new RVT.FilteredElementCollector(doc).OfCategory(category); // Get the first element (should only be one) RVT.BasePoint element = (RVT.BasePoint)collector.ToElements().FirstOrDefault(); if (element == null) { throw new Exception(Properties.Resources.CannotGetBaseOrSurveyPoint); } // Get the elements bounding box RVT.BoundingBoxXYZ box = element.get_BoundingBox(null); // Since the boundingbox is a point only, return Min or Max return(box.Max.ToPoint()); }
protected override void TrySolveInstance(IGH_DataAccess DA, DB.Document doc) { string name = null; DA.GetData("Name", ref name); DB.ElementFilter filter = null; DA.GetData("Filter", ref filter); using (var collector = new DB.FilteredElementCollector(doc)) { var viewsCollector = collector.WherePasses(ElementFilter); if (filter is object) { viewsCollector = viewsCollector.WherePasses(filter); } if (TryGetFilterStringParam(DB.BuiltInParameter.SYMBOL_NAME_PARAM, ref name, out var nameFilter)) { viewsCollector = viewsCollector.WherePasses(nameFilter); } var groupTypes = collector.Cast <DB.GroupType>(); if (!string.IsNullOrEmpty(name)) { groupTypes = groupTypes.Where(x => x.Name.IsSymbolNameLike(name)); } DA.SetDataList("GroupTypes", groupTypes); } }
static bool HasElementTypes(DB.ElementId categoryId) { using (var collector = new DB.FilteredElementCollector(Revit.ActiveUIDocument.Document)) { var elementCollector = collector.OfClass(typeof(R)).OfCategoryId(categoryId); return(elementCollector.GetElementCount() > 0); } }
public static Dictionary <string, DB.ElementId> GetMaterialIdsByName(DB.Document doc) { var collector = new DB.FilteredElementCollector(doc); return(collector.OfClass(typeof(DB.Material)).OfType <DB.Material>(). GroupBy(x => x.Name). ToDictionary(x => x.Key, x => x.First().Id)); }
private void button2_Click(object sender, EventArgs e) { label2.Text = ""; if (string.IsNullOrEmpty(textBox1.Text)) { MessageBox.Show("请选择文件"); } else { var doc = RevitCoreContext.Instance.Application.OpenDocumentFile(textBox1.Text); if (doc == null) { throw new InvalidOperationException(); } var elems = new RVDB.FilteredElementCollector(doc).WhereElementIsElementType().ToList(); progressBar1.Maximum = elems.Count; progressBar1.Step = 1; progressBar1.Visible = true;; label3.Visible = true; var length = elems.Count; int count = 0, n = 0; for (int i = 0; i < length; i++) { try { var elem = elems[i]; elem.AddEntityData(doc); count++; } catch { } //进度条 n++; progressBar1.Value = n; double percent = (n / length) * 100; label3.Text = string.Format(percent.ToString() + "%"); progressBar1.Refresh(); label3.Refresh(); } label2.Text = string.Format("搜索元素(包括不可见)共{0}个,成功标记个数共{1}", length, count); SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "revit文件|*.rvt"; sfd.FileName = "标记文件.rvt"; if (sfd.ShowDialog() == DialogResult.OK) { var workPath = sfd.FileName; doc.SaveAs(workPath, new RVDB.SaveAsOptions() { OverwriteExistingFile = true }); MessageBox.Show("成功"); doc.Close(false); } } }
protected static DB.PropertySetElement FindPropertySetElement(DB.Document doc, string name) { using (var collector = new DB.FilteredElementCollector(doc). OfClass(typeof(DB.PropertySetElement)). WhereParameterEqualsTo(DB.BuiltInParameter.PROPERTY_SET_NAME, name)) { return(collector.FirstElement() as DB.PropertySetElement); } }
public static Autodesk.Revit.UI.Result DoSend(ExternalCommandData commandData) { using (Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document)) { if (transaction.Start("changeParameters") == TransactionStatus.Started) { // ElementId activeOptId = Autodesk.Revit.DB.DesignOption.GetActiveDesignOptionId(commandData.Application.ActiveUIDocument.Document); //ElementDesignOptionFilter filter = new ElementDesignOptionFilter(activeOptId); COVER.Instance.View3D = null; COVER.Instance.LinkedFileName = ""; COVER.Instance.CurrentLink = null; COVER.Instance.LinkedDocumentID = 0; COVER.Instance.DocumentID = 0; COVER.Instance.documentList.Clear(); COVER.Instance.documentList.Add(commandData.Application.ActiveUIDocument.Document); Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(commandData.Application.ActiveUIDocument.Document); COVER.Instance.SendGeometry(collector./*WherePasses(filter).*/ WhereElementIsNotElementType().GetElementIterator(), commandData.Application.ActiveUIDocument, commandData.Application.ActiveUIDocument.Document); ElementClassFilter FamilyFilter = new ElementClassFilter(typeof(FamilySymbol)); FilteredElementCollector FamilyCollector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document); ICollection <Element> AllFamilies = FamilyCollector.WherePasses(FamilyFilter).ToElements(); foreach (FamilySymbol Fmly in AllFamilies) { COVER.Instance.sendFamilySymbolParameters(Fmly); /* string FamilyName = Fmly.Name; * foreach (Parameter Param in Fmly.Parameters) * { * string ParamName = Param.Definition.Name; * }*/ } /* * IEnumerable<Element> familiesCollector = * new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document).OfClass(typeof (FamilyInstance)) * .WhereElementIsNotElementType() * .Cast<FamilyInstance>() * .GroupBy(fi => fi.Symbol.Family) // (family,familyInstances) * .Select(f=>f.Key); * * foreach (var f in familiesCollector) * { * COVER.Instance.sendParameters(f); * }*/ if (TransactionStatus.Committed != transaction.Commit()) { TaskDialog.Show("Failure", "Transaction could not be committed"); } return(Autodesk.Revit.UI.Result.Succeeded); } } return(Autodesk.Revit.UI.Result.Failed); }
/// <summary> /// Gets all DesignOptionSets in the document /// </summary> /// <param name="document">A Autodesk.Revit.DB.Document object. This does not work with Dynamo document objects.</param> /// <returns name="DesignOptionSets">The design option sets in the document</returns> public static IList <revitElem> DesignOptionSets([DefaultArgument("Synthetic.Revit.Document.Current()")] revitDoc document) { revitDB.ElementCategoryFilter catFilter = new revitDB.ElementCategoryFilter(revitDB.BuiltInCategory.OST_DesignOptionSets); revitDB.FilteredElementCollector collectSets = new revitDB.FilteredElementCollector(document); return(collectSets .WherePasses(catFilter) .Cast <revitDB.Element>() .ToList()); }
/// <summary> /// Retrieve all materials in the document. /// </summary> /// <param name="document">>A Autodesk.Revit.DB.Document object. This does not work with Dynamo document objects.</param> /// <returns name="Materials">A list of Auotdesk.Revit.DB.Materials</returns> public static IEnumerable <RevitDB.Material> AllMaterials([DefaultArgument("Synthetic.Revit.Document.Current()")] RevitDoc document) { RevitFECollector collector = new RevitFECollector(document); return(collector .OfClass(typeof(RevitDB.Material)) .OfType <RevitDB.Material>()); }
protected override void TrySolveInstance(IGH_DataAccess DA, DB.Document doc) { var categoryId = default(DB.ElementId); DA.GetData("Category", ref categoryId); string familyName = null; DA.GetData("Family Name", ref familyName); string name = null; DA.GetData("Name", ref name); DB.ElementFilter filter = null; DA.GetData("Filter", ref filter); using (var collector = new DB.FilteredElementCollector(doc)) { var elementCollector = collector.WherePasses(ElementFilter); if (categoryId is object) { elementCollector.OfCategoryId(categoryId); } if (filter is object) { elementCollector = elementCollector.WherePasses(filter); } if (TryGetFilterStringParam(DB.BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM, ref familyName, out var familyNameFilter)) { elementCollector = elementCollector.WherePasses(familyNameFilter); } if (TryGetFilterStringParam(DB.BuiltInParameter.SYMBOL_NAME_PARAM, ref name, out var nameFilter)) { elementCollector = elementCollector.WherePasses(nameFilter); } var elementTypes = elementCollector.Cast <DB.ElementType>(); if (familyName is object) { elementTypes = elementTypes.Where(x => x.FamilyName.IsSymbolNameLike(familyName)); } if (name is object) { elementTypes = elementTypes.Where(x => x.Name.IsSymbolNameLike(name)); } DA.SetDataList("Types", elementTypes.Select(x => new Types.ElementType(x))); } }
internal static List <revitViewport> _renumberViewsOnSheet(FamilyType familyType, string xGridName, string yGridName, revitSheet rSheet, revitDoc document) { string transactionName = "Renumber views on sheet"; // Initialize variables revitFamilySymbol rFamilySymbol = (revitFamilySymbol)familyType.InternalElement; // Get all viewport ID's on the sheet. List <revitElemId> viewportIds = (List <revitElemId>)rSheet.GetAllViewports(); List <revitViewport> viewports = null; // Get the family Instances in view revitElemId symbolId = familyType.InternalElement.Id; revitCollector collector = new revitCollector(document, rSheet.Id); revitElementFilter filterInstance = new revitDB.FamilyInstanceFilter(document, symbolId); collector.OfClass(typeof(revitDB.FamilyInstance)).WherePasses(filterInstance); revitDB.FamilyInstance originFamily = (revitDB.FamilyInstance)collector.FirstElement(); // If family instance is found in the view // Then renumber views. if (originFamily != null) { revitDB.LocationPoint location = (revitDB.LocationPoint)originFamily.Location; revitXYZ originPoint = location.Point; double gridX = rFamilySymbol.LookupParameter(xGridName).AsDouble(); double gridY = rFamilySymbol.LookupParameter(yGridName).AsDouble(); // If the document is modifieable, // then a transaction is already open // and function uses the Dynamo Transaction Manager. // Else, open a new transaction. if (document.IsModifiable) { TransactionManager.Instance.EnsureInTransaction(document); viewports = View._tempRenumberViewports(viewportIds, document); viewports = View._renumberViewports(viewports, gridX, gridY, originPoint.X, originPoint.Y); TransactionManager.Instance.TransactionTaskDone(); } else { using (Autodesk.Revit.DB.Transaction trans = new Autodesk.Revit.DB.Transaction(document)) { trans.Start(transactionName); viewports = View._tempRenumberViewports(viewportIds, document); viewports = View._renumberViewports(viewports, gridX, gridY, originPoint.X, originPoint.Y); trans.Commit(); } } } return(viewports); }
protected override void TrySolveInstance(IGH_DataAccess DA) { if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc)) { return; } if (Params.TryGetData(DA, "Elevation", out Interval? elevation) && !elevation.Value.IsValid) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Elevation value is not valid."); return; } Params.TryGetData(DA, "Name", out string name); Params.TryGetData(DA, "Structural", out bool?structural); Params.TryGetData(DA, "Building Story", out bool?buildingStory); Params.TryGetData(DA, "Filter", out DB.ElementFilter filter); using (var collector = new DB.FilteredElementCollector(doc)) { var levelsCollector = collector.WherePasses(ElementFilter); if (filter is object) { levelsCollector = levelsCollector.WherePasses(filter); } if (elevation.HasValue && TryGetFilterDoubleParam(DB.BuiltInParameter.LEVEL_ELEV, elevation.Value.Mid / Revit.ModelUnits, Revit.VertexTolerance + (elevation.Value.Length * 0.5 / Revit.ModelUnits), out var elevationFilter)) { levelsCollector = levelsCollector.WherePasses(elevationFilter); } if (TryGetFilterStringParam(DB.BuiltInParameter.DATUM_TEXT, ref name, out var nameFilter)) { levelsCollector = levelsCollector.WherePasses(nameFilter); } if (structural.HasValue && TryGetFilterIntegerParam(DB.BuiltInParameter.LEVEL_IS_STRUCTURAL, structural.Value ? 1 : 0, out var structuralFilter)) { levelsCollector = levelsCollector.WherePasses(structuralFilter); } if (buildingStory.HasValue && TryGetFilterIntegerParam(DB.BuiltInParameter.LEVEL_IS_BUILDING_STORY, buildingStory.Value ? 1 : 0, out var buildingStoryilter)) { levelsCollector = levelsCollector.WherePasses(buildingStoryilter); } var levels = levelsCollector.Cast <DB.Level>(); if (!string.IsNullOrEmpty(name)) { levels = levels.Where(x => x.Name.IsSymbolNameLike(name)); } DA.SetDataList("Levels", levels); } }
/// <summary> /// Retrive family instance hosted in boundary elements /// This is the base function for Windows and Doors /// </summary> /// <param name="cat">The category of hosted elements</param> /// <returns></returns> private List<FamilyInstance> BoundaryFamilyInstance(DB.BuiltInCategory cat) { List<FamilyInstance> output = new List<FamilyInstance>(); //the document of the room DB.Document doc = InternalElement.Document; // DocumentManager.Instance.CurrentDBDocument; //Find boundary elements and their associated document List<DB.ElementId> boundaryElements = new List<DB.ElementId>(); List<DB.Document> boundaryDocuments = new List<DB.Document>(); foreach (DB.BoundarySegment segment in InternalBoundarySegments) { DB.Element boundaryElement = doc.GetElement(segment.ElementId); if (boundaryElement.GetType() == typeof(DB.RevitLinkInstance)) { DB.RevitLinkInstance linkInstance = boundaryElement as DB.RevitLinkInstance; boundaryDocuments.Add(linkInstance.GetLinkDocument()); boundaryElements.Add(segment.LinkElementId); } else { boundaryDocuments.Add(doc); boundaryElements.Add(segment.ElementId); } } // Create a category filter DB.ElementCategoryFilter filter = new DB.ElementCategoryFilter(cat); // Apply the filter to the elements in these documents, // Use shortcut WhereElementIsNotElementType() to find family instances in all boundary documents boundaryDocuments = boundaryDocuments.Distinct().ToList(); List<DB.FamilyInstance> familyInstances = new List<DB.FamilyInstance>(); foreach (DB.Document boundaryDocument in boundaryDocuments) { DB.FilteredElementCollector collector = new DB.FilteredElementCollector(boundaryDocument); familyInstances.AddRange(collector.WherePasses(filter).WhereElementIsNotElementType().ToElements().Cast<DB.FamilyInstance>().ToList()); } //Find all family instance hosted on a boundary element IEnumerable<DB.FamilyInstance> boundaryFamilyInstances = familyInstances.Where(s => boundaryElements.Contains(s.Host.Id)); //loop on these boundary family instance to find to and from room foreach (DB.FamilyInstance boundaryFamilyInstance in boundaryFamilyInstances) { DB.Phase familyInstancePhase = boundaryFamilyInstance.Document.GetElement(boundaryFamilyInstance.CreatedPhaseId) as DB.Phase; if (boundaryFamilyInstance.get_FromRoom(familyInstancePhase) != null) { if (boundaryFamilyInstance.get_FromRoom(familyInstancePhase).Id == InternalRoom.Id) { output.Add(ElementWrapper.ToDSType(boundaryFamilyInstance, true) as FamilyInstance); continue; } } if (boundaryFamilyInstance.get_ToRoom(familyInstancePhase) != null) { if (boundaryFamilyInstance.get_ToRoom(familyInstancePhase).Id == InternalRoom.Id) { output.Add(ElementWrapper.ToDSType(boundaryFamilyInstance, true) as FamilyInstance); } } } output = output.Distinct().ToList(); return output; }
/// <summary> /// Find the nearest level in the active document /// </summary> /// <param name="point">The reference point</param> /// <returns></returns> private static DB.Level GetNearestLevel(DB.XYZ point) { //find all level in the active document DB.Document doc = DocumentManager.Instance.CurrentDBDocument; DB.FilteredElementCollector collector = new DB.FilteredElementCollector(doc); List<DB.Level> activeLevels = collector.OfCategory(DB.BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements().Cast<DB.Level>().ToList(); DB.Level nearestLevel = activeLevels.FirstOrDefault(); double delta = Math.Abs(nearestLevel.ProjectElevation - point.Z); foreach (DB.Level currentLevel in activeLevels) { if (Math.Abs(currentLevel.ProjectElevation - point.Z) < delta) { nearestLevel = currentLevel; delta = Math.Abs(currentLevel.ProjectElevation - point.Z); } } return nearestLevel; }
private DB.Transform GetTransform() { if (InternalElement.Document.GetHashCode() == DocumentManager.Instance.CurrentDBDocument.GetHashCode()) { return DB.Transform.Identity; } else { //Find the revit instance where we find the room DB.FilteredElementCollector collector = new DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); List<DB.RevitLinkInstance> linkInstances = collector.OfCategory(DB.BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().ToElements().Cast<DB.RevitLinkInstance>().ToList(); DB.RevitLinkInstance roomLinkInstance = linkInstances.FirstOrDefault(); foreach (DB.RevitLinkInstance linkInstance in linkInstances) { if (linkInstance.GetLinkDocument().GetHashCode() == InternalElement.Document.GetHashCode()) { roomLinkInstance = linkInstance; break; } } return roomLinkInstance.GetTotalTransform(); } }
/// <summary> /// Initialize a GroupType element from a set of objects ids and a name /// </summary> /// <param name="ids"></param> /// <param name="name"></param> private void InitGroupType(ICollection<DB.ElementId> ids, string name) { DB.Document document = DocumentManager.Instance.CurrentDBDocument; //Find all groupType name in the document DB.FilteredElementCollector collector = new DB.FilteredElementCollector(document); List<string> groupTypeNames = collector.OfClass(typeof(DB.GroupType)).ToElements().Select(element => element.Name).ToList(); // This creates a new wall and deletes the old one TransactionManager.Instance.EnsureInTransaction(document); //Phase 1 - Check to see if the object exists and should be rebound var GroupTypeElem = ElementBinder.GetElementFromTrace<DB.GroupType>(document); if (GroupTypeElem == null) { GroupTypeElem = document.Create.NewGroup(ids).GroupType; if (!groupTypeNames.Contains(name)) { GroupTypeElem.Name = name; } else { GetNextFilename(name + " {0}", groupTypeNames); } } InternalSetGroupType(GroupTypeElem); TransactionManager.Instance.TransactionTaskDone(); if (GroupTypeElem != null) { ElementBinder.CleanupAndSetElementForTrace(document, this.InternalElement); } else { ElementBinder.SetElementForTrace(this.InternalElement); } }
public static IEnumerable<Autodesk.Revit.DB.Level> GetAllLevels() { var collector = new Autodesk.Revit.DB.FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument); collector.OfClass(typeof(Autodesk.Revit.DB.Level)); return collector.ToElements().Cast<Autodesk.Revit.DB.Level>(); }
void handleMessage(MessageBuffer buf, int msgType,Document doc,UIDocument uidoc, UIApplication app) { // create Avatar object if not present /* if (avatarObject == null) { createAvatar(doc,uidoc); }*/ switch ((MessageTypes)msgType) { case MessageTypes.Resend: { Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(uidoc.Document); COVER.Instance.SendGeometry(collector.WhereElementIsNotElementType().GetElementIterator(), app); ElementClassFilter FamilyFilter = new ElementClassFilter(typeof(FamilySymbol)); FilteredElementCollector FamilyCollector = new FilteredElementCollector(uidoc.Document); ICollection<Element> AllFamilies = FamilyCollector.WherePasses(FamilyFilter).ToElements(); foreach (FamilySymbol Fmly in AllFamilies) { COVER.Instance.sendFamilySymbolParameters(Fmly); } } break; case MessageTypes.SetParameter: { int elemID = buf.readInt(); int paramID = buf.readInt(); Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elemID); Autodesk.Revit.DB.Element elem = document.GetElement(id); foreach (Autodesk.Revit.DB.Parameter para in elem.Parameters) { if (para.Id.IntegerValue == paramID) { switch (para.StorageType) { case Autodesk.Revit.DB.StorageType.Double: double d = buf.readDouble(); try { para.Set(d); } catch { Autodesk.Revit.UI.TaskDialog.Show("Double", "para.Set failed"); } d = para.AsDouble(); break; case Autodesk.Revit.DB.StorageType.ElementId: //find out the name of the element int tmpid = buf.readInt(); Autodesk.Revit.DB.ElementId eleId = new Autodesk.Revit.DB.ElementId(tmpid); try { para.Set(eleId); } catch { Autodesk.Revit.UI.TaskDialog.Show("Double", "para.Set failed"); } break; case Autodesk.Revit.DB.StorageType.Integer: try { para.Set(buf.readInt()); } catch { Autodesk.Revit.UI.TaskDialog.Show("Double", "para.Set failed"); } break; case Autodesk.Revit.DB.StorageType.String: try { para.Set(buf.readString()); } catch { Autodesk.Revit.UI.TaskDialog.Show("Double", "para.Set failed"); } break; default: try { para.SetValueString(buf.readString()); } catch { Autodesk.Revit.UI.TaskDialog.Show("Double", "para.Set failed"); } break; } } } } break; case MessageTypes.SetTransform: { int elemID = buf.readInt(); double x = buf.readDouble(); double y = buf.readDouble(); double z = buf.readDouble(); Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elemID); Autodesk.Revit.DB.Element elem = document.GetElement(id); Autodesk.Revit.DB.XYZ translationVec = new Autodesk.Revit.DB.XYZ(x, y, z); Autodesk.Revit.DB.LocationCurve ElementPosCurve = elem.Location as Autodesk.Revit.DB.LocationCurve; if (ElementPosCurve != null) ElementPosCurve.Move(translationVec); Autodesk.Revit.DB.LocationPoint ElementPosPoint = elem.Location as Autodesk.Revit.DB.LocationPoint; if (ElementPosPoint != null) ElementPosPoint.Move(translationVec); } break; case MessageTypes.UpdateView: { int elemID = buf.readInt(); double ex = buf.readDouble(); double ey = buf.readDouble(); double ez = buf.readDouble(); double dx = buf.readDouble(); double dy = buf.readDouble(); double dz = buf.readDouble(); double ux = buf.readDouble(); double uy = buf.readDouble(); double uz = buf.readDouble(); Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elemID); Autodesk.Revit.DB.Element elem = document.GetElement(id); Autodesk.Revit.DB.View3D v3d = (Autodesk.Revit.DB.View3D)elem; Autodesk.Revit.DB.ViewOrientation3D ori = new Autodesk.Revit.DB.ViewOrientation3D(new Autodesk.Revit.DB.XYZ(ex, ey, ez), new Autodesk.Revit.DB.XYZ(ux, uy, uz), new Autodesk.Revit.DB.XYZ(dx, dy, dz)); v3d.SetOrientation(ori); } break; case MessageTypes.NewAnnotation: { int labelNumber = buf.readInt(); double x = buf.readDouble(); double y = buf.readDouble(); double z = buf.readDouble(); double h = buf.readDouble(); double p = buf.readDouble(); double r = buf.readDouble(); string labelText = buf.readString(); Autodesk.Revit.DB.XYZ translationVec = new Autodesk.Revit.DB.XYZ(x, y, z); Autodesk.Revit.DB.View view = document.ActiveView; ElementId currentTextTypeId = document.GetDefaultElementTypeId(ElementTypeGroup.TextNoteType); Autodesk.Revit.DB.TextNote tn = Autodesk.Revit.DB.TextNote.Create(document, view.Id, translationVec, labelText, currentTextTypeId); // send back revit ID corresponding to this annotationID // the mapping of annotationIDs to Revit element IDs is done in OpenCOVER MessageBuffer mb = new MessageBuffer(); mb.add(labelNumber); mb.add(tn.Id.IntegerValue); sendMessage(mb.buf, MessageTypes.NewAnnotationID); } break; case MessageTypes.ChangeAnnotation: { int elemID = buf.readInt(); double x = buf.readDouble(); double y = buf.readDouble(); double z = buf.readDouble(); double h = buf.readDouble(); double p = buf.readDouble(); double r = buf.readDouble(); Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elemID); Autodesk.Revit.DB.Element elem = document.GetElement(id); Autodesk.Revit.DB.TextNote tn = elem as Autodesk.Revit.DB.TextNote; if (tn != null) { Autodesk.Revit.DB.XYZ translationVec = new Autodesk.Revit.DB.XYZ(x, y, z); tn.Coord = translationVec; } } break; case MessageTypes.SetView: { int currentView = buf.readInt(); List<View3D> views = new List<View3D>( new FilteredElementCollector(doc) .OfClass(typeof(View3D)) .Cast<View3D>() .Where<View3D>(v => v.CanBePrinted && !v.IsTemplate)); int n = 0; foreach (View3D v in views) { if (n == currentView) { try { uidoc.ActiveView = v; } catch (Autodesk.Revit.Exceptions.ArgumentNullException e) { Console.WriteLine("Exception information: {0}", e); } catch (Autodesk.Revit.Exceptions.ArgumentException e) { Console.WriteLine("Exception information: {0}", e); } catch (Autodesk.Revit.Exceptions.InvalidOperationException e) { Console.WriteLine("Exception information: {0}", e); } break; } n++; } } break; case MessageTypes.ChangeAnnotationText: { int elemID = buf.readInt(); string labelText = buf.readString(); Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(elemID); Autodesk.Revit.DB.Element elem = document.GetElement(id); Autodesk.Revit.DB.TextNote tn = elem as Autodesk.Revit.DB.TextNote; if (tn != null) { tn.Text = labelText; } } break; case MessageTypes.AvatarPosition: { double ex = buf.readDouble(); double ey = buf.readDouble(); double ez = buf.readDouble(); double dx = buf.readDouble(); double dy = buf.readDouble(); double dz = buf.readDouble(); Level currentLevel = getLevel(doc, ez); string lev = ""; if (currentLevel != null) { lev = currentLevel.Name; } Room testRaum = null; Room currentRoom = null; try { XYZ point = new XYZ(ex, ey, ez); currentRoom = doc.GetRoomAtPoint(point); if (currentRoom == null && (currentLevel != null)) { point = new XYZ(ex, ey, currentLevel.ProjectElevation); currentRoom = doc.GetRoomAtPoint(point); if (currentRoom == null) { testRaum = getRoom(doc, ex, ey, ez); currentRoom = testRaum; } } } catch { } if (currentRoom != null) { string nr = currentRoom.Number; string name = currentRoom.Name; double area = currentRoom.Area; MessageBuffer mb = new MessageBuffer(); mb.add(nr); mb.add(name); mb.add(area); mb.add(lev); sendMessage(mb.buf, MessageTypes.RoomInfo); } else { string nr = "-1"; string name = "No Room"; double area = 0.0; MessageBuffer mb = new MessageBuffer(); mb.add(nr); mb.add(name); mb.add(area); mb.add(lev); sendMessage(mb.buf, MessageTypes.RoomInfo); } if (avatarObject != null) { /* Autodesk.Revit.DB.LocationCurve ElementPosCurve = avatarObject.Location as Autodesk.Revit.DB.LocationCurve; Autodesk.Revit.DB.XYZ translationVec = new Autodesk.Revit.DB.XYZ(ex, ey, ez); ElementPosCurve.Move(translationVec);*/ } } break; } }
/// <summary> /// Implement this method as an external command for Revit. /// </summary> /// <param name="commandData">An object that is passed to the external application /// which contains data related to the command, /// such as the application object and active view.</param> /// <param name="message">A message that can be set by the external application /// which will be displayed if a failure or cancellation is returned by /// the external command.</param> /// <param name="elements">A set of elements to which the external application /// can add elements that are to be highlighted in case of failure or cancellation.</param> /// <returns>Return the status of the external command. /// A result of Succeeded means that the API external method functioned as expected. /// Cancelled can be used to signify that the user cancelled the external operation /// at some point. Failure should be returned if the application is unable to proceed with /// the operation.</returns> public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { using (Transaction transaction = new Transaction(commandData.Application.ActiveUIDocument.Document)) { if (transaction.Start("changeParameters") == TransactionStatus.Started) { // ElementId activeOptId = Autodesk.Revit.DB.DesignOption.GetActiveDesignOptionId(commandData.Application.ActiveUIDocument.Document); //ElementDesignOptionFilter filter = new ElementDesignOptionFilter(activeOptId); Autodesk.Revit.DB.FilteredElementCollector collector = new Autodesk.Revit.DB.FilteredElementCollector(commandData.Application.ActiveUIDocument.Document); COVER.Instance.SendGeometry(collector./*WherePasses(filter).*/WhereElementIsNotElementType().GetElementIterator(), commandData.Application.ActiveUIDocument.Document); ElementClassFilter FamilyFilter = new ElementClassFilter(typeof(FamilySymbol)); FilteredElementCollector FamilyCollector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document); ICollection<Element> AllFamilies = FamilyCollector.WherePasses(FamilyFilter).ToElements(); foreach (FamilySymbol Fmly in AllFamilies) { COVER.Instance.sendFamilySymbolParameters(Fmly); /* string FamilyName = Fmly.Name; foreach (Parameter Param in Fmly.Parameters) { string ParamName = Param.Definition.Name; }*/ } /* IEnumerable<Element> familiesCollector = new FilteredElementCollector(commandData.Application.ActiveUIDocument.Document).OfClass(typeof (FamilyInstance)) .WhereElementIsNotElementType() .Cast<FamilyInstance>() .GroupBy(fi => fi.Symbol.Family) // (family,familyInstances) .Select(f=>f.Key); foreach (var f in familiesCollector) { COVER.Instance.sendParameters(f); }*/ if (TransactionStatus.Committed != transaction.Commit()) { TaskDialog.Show("Failure", "Transaction could not be committed"); } return Autodesk.Revit.UI.Result.Succeeded; } } return Autodesk.Revit.UI.Result.Failed; }