更新
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Autodesk.Revit.DB;
|
||||
using Autodesk.Revit.DB.Architecture;
|
||||
using Autodesk.Revit.UI;
|
||||
using Autodesk.Revit.UI.Selection;
|
||||
using System;
|
||||
@@ -21,37 +22,38 @@ namespace TestTools
|
||||
Document doc = uidoc.Document;
|
||||
DocumentSet docset = uiapp.Application.Documents;
|
||||
|
||||
Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
|
||||
Element e = uidoc.Document.GetElement(refer);
|
||||
Options options = new Options()
|
||||
{
|
||||
ComputeReferences = true,
|
||||
DetailLevel = ViewDetailLevel.Fine,
|
||||
};
|
||||
var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options));
|
||||
uidoc.Selection.SetElementIds(eleIds);
|
||||
//Reference refer = uidoc.Selection.PickObject(ObjectType.Element, "请选择XXX");
|
||||
//Element e = uidoc.Document.GetElement(refer);
|
||||
//Options options = new Options()
|
||||
//{
|
||||
// ComputeReferences = true,
|
||||
// DetailLevel = ViewDetailLevel.Fine,
|
||||
//};
|
||||
//var eleIds = e.GetGeneratingElementIds(e.get_Geometry(options));
|
||||
//uidoc.Selection.SetElementIds(eleIds);
|
||||
|
||||
#region FilterExecute
|
||||
|
||||
//var walls = new FilteredElementCollector(doc).OfClass(typeof(Wall)).ToElements();
|
||||
//using (Transaction trans = new Transaction(doc, "default"))
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// trans.Start();
|
||||
// //Do Something.
|
||||
// trans.Commit();
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// message = ex.Message;
|
||||
// if (trans.GetStatus() == TransactionStatus.Started)
|
||||
// {
|
||||
// trans.RollBack();
|
||||
// }
|
||||
// return Result.Failed;
|
||||
// }
|
||||
//}
|
||||
var walls = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements();
|
||||
using (Transaction trans = new Transaction(doc, "default"))
|
||||
{
|
||||
try
|
||||
{
|
||||
trans.Start();
|
||||
var rooms = walls.Where(wall => wall.Name.Contains("房间")).Select(wall => wall.Id).ToList();
|
||||
doc.Delete(rooms);
|
||||
trans.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
message = ex.Message;
|
||||
if (trans.GetStatus() == TransactionStatus.Started)
|
||||
{
|
||||
trans.RollBack();
|
||||
}
|
||||
return Result.Failed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion FilterExecute
|
||||
|
||||
|
||||
Reference in New Issue
Block a user