Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a section with some project elements, and a linked file loaded with some elements in the view, as shown in the attached photo. I need to check which elements of the linked file are present in this section, but I'm having difficulties.
I tried to check if the elements are inside the view's BoundingBox, but without success:
foreach (RevitLinkInstance docsVinculados in vinculosCarregados)
{
Document doc_vinculo = docsVinculados.GetLinkDocument();
RevitLinkType type = Doc.Document.GetElement(docsVinculados.GetTypeId()) as RevitLinkType;
if (RevitLinkType.IsLoaded(Doc.Document, type.Id))
{
Transform posicao_vinculo = docsVinculados.GetTransform();
ICollection<Element> conexoes_vinculo =
new FilteredElementCollector(doc_vinculo).OfCategory(BuiltInCategory.OST_PipeFitting).ToElements().Where(x => x is FamilyInstance).ToList();
foreach (FamilyInstance itemconex in conexoes_vinculo)
{
var posicaoTagConex = itemconex.get_BoundingBox(Doc.Document.ActiveView).Max.Add(posicao_vinculo.Origin);
var posicaominimaConex = itemconex.get_BoundingBox(Doc.Document.ActiveView).Min.Add(posicao_vinculo.Origin);
var DifPosX = (posicaoTagConex.X - posicaominimaConex.X);
var DifPosY = (posicaoTagConex.Y - posicaominimaConex.Y);
var DifPosZ = (posicaoTagConex.Z - posicaominimaConex.Z);
XYZ PosicaoFinal = new XYZ(posicaoTagConex.X - (DifPosX / 2), posicaoTagConex.Y - (DifPosY / 2), posicaoTagConex.Z - (DifPosZ / 2));
BoundingBoxXYZ boundingBox_view = Config.doc.ActiveView.get_BoundingBox(Config.doc.ActiveView);
Then I tried to apply the solution present here:
https://forums.autodesk.com/t5/revit-api-forum/check-to-see-if-a-point-is-inside-bounding-box/td-p/4354446
if (BoundingBoxXyzContains(boundingBox_view, PosicaoFinal))
{
}
}
}
}
Looks like the position returned in BoundingBox is outside of view. I use this solution to apply tags to linked elements without any problems (I left the code below just for example, as it is not part of the question):
Reference refe = new
Reference(itemconex)
.CreateLinkReference(docsVinculados);
IndependentTag tagConexao = IndependentTag.Create(
Doc.Document, TagConexSelecionada.Id, Doc.ActiveView.Id, refe,
true, TagOrientation.Horizontal, PosicaoFinal);
Solved! Go to Solution.