Skip to content

Commit

Permalink
PlanViewRange - Add functionality (#84)
Browse files Browse the repository at this point in the history
* Get SectionDatas from TableData

* If get element fails, try get category, since the method SupportedColorFillCategoryIds returns category ids

* PlanViewRange - Add functionality to retrieve levels and offsets

Co-authored-by: michaelcoffey <[email protected]>
  • Loading branch information
RevitArkitek and michaelcoffey authored Jun 7, 2021
1 parent c812f73 commit 4b7b03a
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CS/Snoop/CollectorExts/DataFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public Data.Data Create(MethodInfo mi)
return new TableDataSectionData(methodInfo.Name, (TableData)elem);
}

if (declaringType == typeof(PlanViewRange) && methodInfo.Name == nameof(PlanViewRange.GetLevelId))
return new PlanViewRangeGetLevelId(methodInfo.Name, (PlanViewRange) elem, application.ActiveUIDocument.Document);

if (declaringType == typeof(PlanViewRange) && methodInfo.Name == nameof(PlanViewRange.GetOffset))
return new PlanViewRangeGetOffset(methodInfo.Name, (PlanViewRange)elem);

if (declaringType == typeof (Document) && methodInfo.Name == nameof(Document.Close))
return null;

Expand Down
50 changes: 50 additions & 0 deletions CS/Snoop/Data/PlanViewRangeGetLevelId.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;

namespace RevitLookup.Snoop.Data
{
public class PlanViewRangeGetLevelId : Data
{
private readonly PlanViewRange _planViewRange;
private readonly Document _document;

public PlanViewRangeGetLevelId(string label, PlanViewRange planViewRange, Document doc) : base(label)
{
_planViewRange = planViewRange;
_document = doc;
}

public override string StrValue()
{
return "< Get Level Ids >";
}

public override bool HasDrillDown => _planViewRange != null;

public override void DrillDown()
{
if (!HasDrillDown) return;

var sectionDataObjects = new List<SnoopableObjectWrapper>();

foreach (PlanViewPlane type in Enum.GetValues(typeof(PlanViewPlane)))
{
var levelId = _planViewRange.GetLevelId(type);
if (levelId != null && levelId != Autodesk.Revit.DB.ElementId.InvalidElementId)
{
var level = _document.GetElement(levelId) as Level;
sectionDataObjects.Add(new SnoopableObjectWrapper(type.ToString(), level));
}
else
sectionDataObjects.Add(new SnoopableObjectWrapper(type.ToString(), levelId));
}

if (!sectionDataObjects.Any()) return;

var form = new Forms.Objects(sectionDataObjects);
form.ShowDialog();
}
}
}
42 changes: 42 additions & 0 deletions CS/Snoop/Data/PlanViewRangeGetOffset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;

namespace RevitLookup.Snoop.Data
{
public class PlanViewRangeGetOffset : Data
{
private readonly PlanViewRange _planViewRange;

public PlanViewRangeGetOffset(string label, PlanViewRange planViewRange) : base(label)
{
_planViewRange = planViewRange;
}

public override string StrValue()
{
return "< Get Offsets >";
}

public override bool HasDrillDown => _planViewRange != null;

public override void DrillDown()
{
if (!HasDrillDown) return;

var sectionDataObjects = new List<SnoopableObjectWrapper>();

foreach (PlanViewPlane type in Enum.GetValues(typeof(PlanViewPlane)))
{
var offset = _planViewRange.GetOffset(type);
sectionDataObjects.Add(new SnoopableObjectWrapper(type.ToString(), offset));
}

if (!sectionDataObjects.Any()) return;

var form = new Forms.Objects(sectionDataObjects);
form.ShowDialog();
}
}
}

0 comments on commit 4b7b03a

Please sign in to comment.