Rebar TAG Selection

Rebar TAG Selection

stefano.cartaKGT96
Advocate Advocate
870 Views
4 Replies
Message 1 of 5

Rebar TAG Selection

stefano.cartaKGT96
Advocate
Advocate

Hi..

 

I am trying to create a collection of all MultiReferenceAnnotations like the tag with 139

With Revitlookup I found that the id  of this annotation is -2000970

I tried the code below but the collection is nothing.

If I try to collect rebar tags (-2009020) like tag with 174, with the some code, work fine

Where I wrong?

Immagine 2021-03-27 214805.png

 

 

 

Dim tagColl As List(Of Element) = New FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(-2000970).Where(Function(x) TypeOf x Is IndependentTag).ToList()

 

 

 

 

0 Likes
Accepted solutions (1)
871 Views
4 Replies
Replies (4)
Message 2 of 5

architect.bim
Collaborator
Collaborator

Hi!

OfCategory method requires BuiltInCategory enumeration. In your case:

 

OfCategory(BuiltInCategory.OST_MultiReferenceAnnotations)

 

 

 

Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes
Message 3 of 5

stefano.cartaKGT96
Advocate
Advocate

Hi Maxim

Thanks for your quickly replay..

I will try it tomorrow...

 

Message 4 of 5

stefano.cartaKGT96
Advocate
Advocate

Hi..

I modified my code with "BuiltInCategory.OST_MultiReferenceAnnotations" but tagcoll is empty

 

Dim tavTAG As Boolean = Revit.ED_Utility.ElementIsTagged1(doc, ele, (BuiltInCategory.OST_MultiReferenceAnnotations), (BuiltInCategory.OST_Rebar))


  Public Shared Function ElementIsTagged1(ByVal doc As Document, ByVal ele As Element, ByVal eleTag As BuiltInCategory, ByVal eleElements As BuiltInCategory) As Boolean
            Dim tagColl As List(Of Element) = New FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(eleTag).Where(Function(x) TypeOf x Is IndependentTag).ToList()
            Dim eleColl As List(Of Element) = New FilteredElementCollector(doc, doc.ActiveView.Id).OfCategory(eleElements).ToList()
            Dim ids As List(Of ElementId) = New List(Of ElementId)()

            For Each e As Element In tagColl
                Dim tag As IndependentTag = TryCast(e, IndependentTag)
                Dim id As ElementId = tag.TaggedLocalElementId
                Dim aux1 As Integer = tag.TaggedLocalElementId.IntegerValue
                Dim aux2 As Boolean = ids.Contains(tag.TaggedLocalElementId)

                If (tag.TaggedLocalElementId.IntegerValue <> -1) AndAlso (ids.Contains(tag.TaggedLocalElementId) = False) Then
                    ids.Add(tag.TaggedLocalElementId)
                End If
            Next

            Dim uniqueIds As List(Of ElementId) = ids.Distinct().ToList()
            Dim eleIds As List(Of ElementId) = New List(Of ElementId)()

            For Each e As Element In eleColl
                eleIds.Add(e.Id)
            Next

            Dim idEleTag As List(Of ElementId) = New List(Of ElementId)()

            For Each id As ElementId In eleIds

                If uniqueIds.Contains(id) Then
                    idEleTag.Add(id)
                End If
            Next

            If idEleTag.Contains(ele.Id) Then
                Return True
            Else
                Return False
            End If
        End Function
0 Likes
Message 5 of 5

architect.bim
Collaborator
Collaborator
Accepted solution

Sorry, maybe I misunderstand the problem but in fact if you need to select all multireference annotations on view you can use either OfClass or OfCategory method. In both cases you get the same results:

 

 

# Python code
tags_of_class = FilteredElementCollector(doc, doc.ActiveView.Id) \
    .OfClass(DB.MultiReferenceAnnotation)

tags_of_category = FilteredElementCollector(doc, doc.ActiveView.Id) \
    .OfCategory(DB.BuiltInCategory.OST_MultiReferenceAnnotations) \
    .WhereElementIsNotElementType()

 

 

The elements you try to get do not belong to IndependendTag class. I think in your code the problem is there.


Maxim Stepannikov | Architect, BIM Manager, Instructor
0 Likes