Hi Erik,
I remember muddling through this in the past, so here goes:
If bottomLevelId.IntegerValue = -1 Then
'unlimited view depth
ElseIf bottomLevelId.IntegerValue = -3 Then
'the same as the plan level
ElseIf bottomLevelId.IntegerValue = -4 Then
'the level below the plan level
End If
If topLevelId.IntegerValue = -1 Then
'unlimited view depth
ElseIf topLevelId.IntegerValue = -2 Then
'the level above
ElseIf topLevelId.IntegerValue = -3 Then
'the same as the plan level
End If
I had to manually work out the levels. To do this I just got a list of the levels sorted by elevation, and selected the appropriate one. I think I got the levels from existing plans, so the list omitted all non-plan intermediate levels.
''' <summary>
''' Returns a sorted list of level objects that have been used for a plan view.
''' </summary>
''' <param name="doc"></param>
''' <returns></returns>
''' <remarks></remarks>
Shared Function GetAllPlanLevels(ByVal doc As DB.Document) As List(Of DB.Level)
Dim collector As New DB.FilteredElementCollector(doc)
Dim comparer As New EqualityComparerLevel
Dim levels As List(Of DB.Level) = collector.OfClass(GetType(DB.ViewPlan)).Cast(Of DB.ViewPlan).Where(Function(v) _
Not v.IsTemplate AndAlso v.GenLevel IsNot Nothing).Select(Function(vp) vp.GenLevel).Distinct(comparer).ToList
'Dim allLevels As New List(Of DB.Level)
'For Each lev As DB.Level In levels
' allLevels.Add(lev)
'Next
levels = levels.OrderBy(Function(item) item.Elevation).ToList()
Return levels
End Function
Public Class EqualityComparerLevel
Implements IEqualityComparer(Of DB.Level)
Public Function Equals1(x As DB.Level, y As DB.Level) As Boolean Implements IEqualityComparer(Of DB.Level).Equals
Return x.Id.IntegerValue.Equals(y.Id.IntegerValue)
End Function
Public Function GetHashCode1(obj As DB.Level) As Integer Implements IEqualityComparer(Of DB.Level).GetHashCode
Return obj.Id.GetHashCode
End Function
End Class
Cheers,
-Matt
Cheers,
-Matt
_______________________________________________________________________________
Marking a post as a 'solution' helps the community. Giving a post 'Kudos' is as good as saying thanks. Why not do both?