36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
|
|
using System;
|
|||
|
|
|
|||
|
|
using Autodesk.Revit.Attributes;
|
|||
|
|
using Autodesk.Revit.DB;
|
|||
|
|
using Autodesk.Revit.UI;
|
|||
|
|
|
|||
|
|
namespace RevitAddin.Revit.Commands;
|
|||
|
|
[Transaction(TransactionMode.Manual)]
|
|||
|
|
public class Command : IExternalCommand
|
|||
|
|
{
|
|||
|
|
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementSet)
|
|||
|
|
{
|
|||
|
|
var doc = commandData.Application.ActiveUIDocument.Document;
|
|||
|
|
if (doc.IsFamilyDocument)
|
|||
|
|
{
|
|||
|
|
using (Transaction ts = new Transaction(doc, "删除空类型"))
|
|||
|
|
{
|
|||
|
|
ts.Start();
|
|||
|
|
var manager = doc.FamilyManager;
|
|||
|
|
foreach (FamilyType type in manager.Types)
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrWhiteSpace(type.Name))
|
|||
|
|
{
|
|||
|
|
manager.CurrentType= type;
|
|||
|
|
doc.Regenerate();
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
manager.DeleteCurrentType();
|
|||
|
|
ts.Commit();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
return Result.Succeeded;
|
|||
|
|
}
|
|||
|
|
}
|