Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetAllElementsVisibleInActiveView only returns IDs from the main model #1399

Closed
vietle-bh opened this issue Aug 30, 2023 · 0 comments · Fixed by #1400
Closed

GetAllElementsVisibleInActiveView only returns IDs from the main model #1399

vietle-bh opened this issue Aug 30, 2023 · 0 comments · Fixed by #1400
Assignees
Labels
type:bug Error or unexpected behaviour

Comments

@vietle-bh
Copy link
Contributor

Description:

GetAllElementsVisibleInActiveView() from ActiveViewVisibilityContext is supposed to return visible element IDs grouped by their host documents. Currently, it only returns IDs from the active document. IDs from links are missing.

[Description("Returns ids of all elements visible in the active view of the host document. The ids are grouped by document they belong to.")]
public Dictionary<Document, HashSet<ElementId>> GetAllElementsVisibleInActiveView()
{
if (m_TargetDocument != null)
{
BH.Engine.Base.Compute.RecordError($"The context has been processed with a single target document. Please run again making sure that the target document parameter in the context constructor is null.");
return null;
}
else
return m_DocumentLookup.ToDictionary(x => x.Value, x => m_Elements[x.Key]);
}

Steps to reproduce:

Run the method on any Revit file with a visible link in the current view to observe the symptom above. This is because m_DocumentLookup[linkInstance.Document.PathName] = linkInstance.Document; in the method below wont' add the link's document to m_DocumentLookup. linkInstance.Document should have been linkInstance.GetLinkDocument().

public RenderNodeAction OnElementBegin(ElementId elementId)
{
Document doc = m_Documents.Peek();
m_Elements[doc.PathName].Add(elementId);
Element element = doc.GetElement(elementId);
if (element is RevitLinkInstance)
{
RevitLinkInstance linkInstance = (RevitLinkInstance)element;
if (m_TargetDocument == null || m_TargetDocument.PathName == linkInstance.GetLinkDocument().PathName)
{
m_DocumentLookup[linkInstance.Document.PathName] = linkInstance.Document;
return RenderNodeAction.Proceed;
}
}
return RenderNodeAction.Skip;
}

Expected behaviour:

Test file(s):

@vietle-bh vietle-bh added the type:bug Error or unexpected behaviour label Aug 30, 2023
@vietle-bh vietle-bh self-assigned this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error or unexpected behaviour
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant