One of the supreme beings that I used to work with at CASE built a means of doing this in Dynamo.
This is a simple routine that finds these and eradicates them from your model...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Transaction(TransactionMode.Manual)] | |
public class CmdMain : IExternalCommand | |
{ | |
/// <summary> | |
/// Command | |
/// </summary> | |
/// <param name="commandData"></param> | |
/// <param name="message"></param> | |
/// <param name="elements"></param> | |
/// <returns></returns> | |
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | |
{ | |
try | |
{ | |
Document m_doc = commandData.Application.ActiveUIDocument.Document; | |
int m_cnt = 0; | |
IEnumerable<ElevationMarker> m_elem = from e in new FilteredElementCollector(m_doc) | |
.WhereElementIsNotElementType().OfClass(typeof (ElevationMarker)) | |
let em = e as ElevationMarker | |
where em.HasElevations() == false | |
select em; | |
using (Transaction t = new Transaction(m_doc)) | |
{ | |
if (t.Start("Delete Empty Elevation Marker Tags") == TransactionStatus.Started) | |
{ | |
foreach (var x in m_elem.ToList()) | |
{ | |
m_doc.Delete(x.Id); | |
m_cnt++; | |
} | |
t.Commit(); | |
} | |
} | |
// Results | |
clsUtility.ShowTaskDialog( | |
"Results", | |
"Deleted Elevation Markers", | |
string.Format("Removed {0} Empty Elevation Marker Tags", m_cnt)); | |
return Result.Succeeded; | |
} | |
catch (Exception ex) | |
{ | |
clsUtility.ShowTaskDialog( | |
"Failure", | |
"Deleting Elevation Markers", | |
string.Format("Failed: \n{0}", ex)); | |
return Result.Cancelled; | |
} | |
} | |
} | |
/// <summary> | |
/// Quick basic task dialog | |
/// </summary> | |
/// <param name="titleText"></param> | |
/// <param name="largeText"></param> | |
/// <param name="smallText"></param> | |
internal static void ShowTaskDialog(string titleText, string largeText, string smallText) | |
{ | |
using (TaskDialog td = new TaskDialog(titleText)) | |
{ | |
td.CommonButtons = TaskDialogCommonButtons.Ok; | |
td.DefaultButton = TaskDialogResult.Ok; | |
td.TitleAutoPrefix = false; | |
td.MainInstruction = largeText; | |
td.MainContent = smallText; | |
td.Show(); | |
} | |
} |
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.