Our Sheets use instances of "Manual_Revision" annotation symbols to document revision date, notes etc.
This code extract returns some, but not all, of these revisions.
Does anybody have any idea why I'm not picking them all up?
Public Shared Function GetRevisions(doc As Document, frm As frmSheets) As String ' Creates a FamilyInstance filter for elements that are family instances of the given family symbol in the document ' Find all family symbols whose name is "Manual_Revision" Dim collector As New FilteredElementCollector(doc) collector = collector.OfClass(GetType(FamilySymbol)) ' Get Element Id for family symbol which will be used to find family instances Dim query = From element In collector Where element.Name = "Manual_Revision" Dim famSyms As List(Of Element) = query.ToList() '(Of Element)() Dim symbolId As ElementId = famSyms(0).Id ' Create a FamilyInstance filter with the FamilySymbol Id Dim filter As New FamilyInstanceFilter(doc, symbolId) ' Apply the filter to the elements in the active document collector = New FilteredElementCollector(doc) Dim familyInstances As ICollection(Of Element) = collector.WherePasses(filter).ToElements() ' Prompt typical revision ParseRevisions(frm, familyInstances(0), True) For Each ele As Element In familyInstances ParseRevisions(frm, ele, False) Next Return "Found " & familyInstances.Count & " Revisions in Project" End Function
The famSyms list alaways has only 1 element? Or do you have a .rtv with this? Which Revit version are you using?
I agree with Augusto, it looks like you only do one type. I suggest
Public Shared Function GetRevisions(doc As Document, frm As frmSheets) As String ' Creates a FamilyInstance filter for elements that are family instances of the given family symbol in the document ' Find all family symbols whose name is "Manual_Revision" Dim collector As New FilteredElementCollector(doc) collector = collector.OfClass(GetType(FamilySymbol)) ' Get Element Id for family symbol which will be used to find family instances Dim query = From element In collector Where element.Name = "Manual_Revision" Dim famSyms As List(Of Element) = query.ToList() '(Of Element)() foreach symbolId As ELementId in famSyms 'Dim symbolId As ElementId = famSyms(0).Id ' Create a FamilyInstance filter with the FamilySymbol Id Dim filter As New FamilyInstanceFilter(doc, symbolId) ' Apply the filter to the elements in the active document collector = New FilteredElementCollector(doc) Dim familyInstances As ICollection(Of Element) = collector.WherePasses(filter).ToElements() ' Prompt typical revision ParseRevisions(frm, familyInstances(0), True) For Each ele As Element In familyInstances ParseRevisions(frm, ele, False) Next Next Return "Found " & familyInstances.Count & " Revisions in Project" End Function
Thanks for the suggestion. I simplified my code and inserted a loop over my filtered list of famsyms with name "Manual_Revision" as shown.
Public Shared Function GetRevisions(doc As Document) As String Dim iRevisions As Integer = 0 ' Creates a FamilyInstance filter for elements that are 'family instances of the given family symbol in the document Dim faminsts As ICollection(Of Element) ' Find all family symbols whose name is "Manual_Revision" Dim collector As New FilteredElementCollector(doc) collector = collector.OfClass(GetType(FamilySymbol)) ' Get Element Id for family symbol which will be used to find family instances Dim query = From element In collector Where element.Name = "Manual_Revision" Dim famSyms As List(Of Element) = query.ToList() '(Of Element)() 'famsyms.count is 1 so the For each symbol loop is only passed once Debug.Print("Found " & famSyms.Count & " family symbols where element.Name = 'Manual_Revision'") For Each symbol As Element In famSyms ' Create a FamilyInstance filter with the FamilySymbol Id Dim filter As New FamilyInstanceFilter(doc, symbol.Id) ' Apply the filter to the elements in the active document collector = New FilteredElementCollector(doc) faminsts = collector.WherePasses(filter).ToElements() For Each ele As Element In faminsts 'ParseRevisions(frm, ele, False) iRevisions += 1 Next Next Return "Found " & iRevisions & " instances of FamilySymbol Manual_revision" End Function
This made no difference as there was only one match:
Found 1 family symbols where element.Name = 'Manual_Revision'
Found 173 instances of FamilySymbol Manual_revision
The 172 instances I found only included, for instance about 3 of the notes on this sheet snip. There was no revision with [Revision No] parameter value "C05" found in the entire project.
I'm missing something pretty obvious in my parsing of the Revit project!
Your assistance is appreciated!
Steve
CZWG Architects LLP
LONDON
Can't find what you're looking for? Ask the community or share your knowledge.