Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2eb6e50361 |
@@ -331,8 +331,37 @@ internal sealed class RevitSendBinding : RevitBaseBinding, ISendBinding
|
||||
return;
|
||||
}
|
||||
|
||||
List<Element> elementsUsingMaterial = new List<Element>();
|
||||
|
||||
foreach (var changedElementId in ChangedObjectIds.Keys.ToArray())
|
||||
{
|
||||
var o = doc.GetElement(changedElementId);
|
||||
if (o is Material)
|
||||
{
|
||||
// Get all elements that might use materials (such as walls, floors, roofs, etc.)
|
||||
using var collector = new FilteredElementCollector(doc);
|
||||
var elements = collector
|
||||
.WhereElementIsNotElementType()
|
||||
.Where(e => e is FamilyInstance || e.Category != null && e.Category.Material != null);
|
||||
|
||||
foreach (var element in elements)
|
||||
{
|
||||
var materialIds = element.GetMaterialIds(false);
|
||||
if (materialIds.Contains(o.Id))
|
||||
{
|
||||
elementsUsingMaterial.Add(element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var objUniqueIds = new List<string>();
|
||||
|
||||
foreach (var element in elementsUsingMaterial)
|
||||
{
|
||||
ChangedObjectIds[element.Id] = 1;
|
||||
}
|
||||
|
||||
foreach (var sender in senders)
|
||||
{
|
||||
// if (sender.SendFilter is null) // NOTE: RunExpirationChecks sometimes triggered unnecessarily before send and, we didn't set up yet IdMap, if so we do not need to deal with it
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
// using System.Collections.Concurrent;
|
||||
// using System.Diagnostics.CodeAnalysis;
|
||||
// using Speckle.Sdk.Models;
|
||||
//
|
||||
// namespace Speckle.Connectors.Common.Caching;
|
||||
//
|
||||
// public class SendConversionCache2 : ISendConversionCache
|
||||
// {
|
||||
// public SendConversionCache2() { }
|
||||
//
|
||||
// private class CacheNode
|
||||
// {
|
||||
// public ObjectReference Value { get; }
|
||||
// public (string applicationId, string projectId) Key { get; } // Store the key in the node
|
||||
// public CacheNode? Parent { get; }
|
||||
// public ConcurrentDictionary<string, CacheNode> Children { get; } = new();
|
||||
//
|
||||
// public CacheNode(ObjectReference value, (string applicationId, string projectId) key, CacheNode? parent = null)
|
||||
// {
|
||||
// Value = value;
|
||||
// Key = key;
|
||||
// Parent = parent;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private ConcurrentDictionary<(string applicationId, string projectId), CacheNode> Cache { get; set; } = new();
|
||||
//
|
||||
// public void StoreSendResult(string projectId, IReadOnlyDictionary<string, ObjectReference> convertedReferences)
|
||||
// {
|
||||
// foreach (var kvp in convertedReferences)
|
||||
// {
|
||||
// var key = (kvp.Key, projectId);
|
||||
// var node = new CacheNode(kvp.Value, key);
|
||||
//
|
||||
// Cache.AddOrUpdate(key, node, (k, existingNode) => node);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void EvictObjects(IEnumerable<string> objectIds)
|
||||
// {
|
||||
// foreach (var objectId in objectIds)
|
||||
// {
|
||||
// var keysToRemove = Cache.Keys.Where(k => k.applicationId == objectId).ToList();
|
||||
//
|
||||
// foreach (var key in keysToRemove)
|
||||
// {
|
||||
// if (Cache.TryRemove(key, out var node))
|
||||
// {
|
||||
// InvalidateParent(node);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void InvalidateParent(CacheNode node)
|
||||
// {
|
||||
// var current = node.Parent;
|
||||
// while (current != null)
|
||||
// {
|
||||
// if (current.Children.IsEmpty)
|
||||
// {
|
||||
// if (Cache.TryRemove(current.Key, out var removedNode))
|
||||
// {
|
||||
// current = removedNode.Parent;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public void ClearCache() => Cache.Clear();
|
||||
//
|
||||
// public bool TryGetValue(
|
||||
// string projectId,
|
||||
// string applicationId,
|
||||
// [NotNullWhen(true)] out ObjectReference? objectReference
|
||||
// )
|
||||
// {
|
||||
// if (Cache.TryGetValue((applicationId, projectId), out var node))
|
||||
// {
|
||||
// objectReference = node.Value;
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// objectReference = null;
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
Reference in New Issue
Block a user