private void CollectElementMaps() { try { var hostDoc = Instance.Document; var categoryIds = Categories.Keys.ToList(); foreach (var catId in categoryIds) { var collector = new FilteredElementCollector(hostDoc); var elements = collector.OfCategoryId(catId).WhereElementIsNotElementType().ToElements().ToList(); var elementWithEntities = from element in elements where element.GetEntitySchemaGuids().Count > 0 select element; if (elementWithEntities.Count() > 0) { elements = elementWithEntities.ToList(); } foreach (var element in elements) { if (null == element.Location) { continue; } // unplaced rooms var linkInfo = MoverDataStorageUtil.GetLinkedElementInfo(element); if (null != linkInfo) { if (linkInfo.SourceLinkInstanceId != InstanceId) { continue; } if (element.Id != linkInfo.LinkedElementId) { continue; } var sourceElement = LinkedDocument.GetElement(linkInfo.SourceElementId); if (null != sourceElement) { linkInfo = new LinkedElementInfo(linkInfo.LinkElementType, sourceElement, element, InstanceId, TransformValue); if (!LinkedElements.ContainsKey(linkInfo.LinkedElementId)) { LinkedElements.Add(linkInfo.LinkedElementId, linkInfo); } } } } } } catch (Exception ex) { MessageBox.Show("Failed to collect element maps.\n" + ex.Message, "Collect Element Maps", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void CollectFamilyMaps() { try { var hostDoc = Instance.Document; var categoryIds = Categories.Keys.ToList(); foreach (var catId in categoryIds) { var collector = new FilteredElementCollector(hostDoc); var elements = collector.OfCategoryId(catId).WhereElementIsElementType().ToElements().ToList(); foreach (var element in elements) { var elementType = element as ElementType; if (null != elementType) { var familyInfo = MoverDataStorageUtil.GetLinkedFamilyInfo(elementType); if (null != familyInfo) { if (familyInfo.SourceLinkInstanceId != InstanceId) { continue; } if (element.Id != familyInfo.TargetTypeId) { continue; } var sourceType = LinkedDocument.GetElement(familyInfo.SourceTypeId) as ElementType; if (null != sourceType) { var sourceTypeInfo = new ElementTypeInfo(sourceType); var targetTypeInfo = new ElementTypeInfo(elementType); familyInfo = new LinkedFamilyInfo(familyInfo.SourceLinkInstanceId, sourceTypeInfo, targetTypeInfo); if (!LinkedFamilies.ContainsKey(familyInfo.TargetTypeId)) { LinkedFamilies.Add(familyInfo.TargetTypeId, familyInfo); } } } } } } } catch (Exception ex) { MessageBox.Show("Failed to collect family maps.\n" + ex.Message, "Collect Family Maps", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public bool AllowReference(Reference r, XYZ p) { LinkedDocument = null; Element e = _doc.GetElement(r); if (e is RevitLinkInstance) { RevitLinkInstance li = e as RevitLinkInstance; LinkedDocument = li.GetLinkDocument(); e = LinkedDocument.GetElement(r.LinkedElementId); } return(e is T); }