更新
This commit is contained in:
35
RevitAddin/Revit/Commands/Command.cs
Normal file
35
RevitAddin/Revit/Commands/Command.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user