【发布时间】:2021-12-28 20:53:42
【问题描述】:
我编写了一个程序,该程序使用对形状的面的引用来形成一个分割的表面。但是当应用于墙壁时(带有类别选择的搜索字符串在下面突出显示),程序什么也不做。如何将此程序仅应用于项目中的所有墙壁?
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication app = commandData.Application;
Document doc = app.ActiveUIDocument.Document;
Autodesk.Revit.Creation.Application creApp
= app.Application.Create;
try
{
FilteredElementCollector forms = new FilteredElementCollector(doc);
forms.OfCategory(BuiltInCategory.OST_CurtainGridsWall); // !!problem string!!
using (Transaction tx = new Transaction(doc))
{
tx.Start("Create Devided Surface");
foreach (Form form in forms)
{
FamilyItemFactory factory = doc.FamilyCreate;
Options options = creApp.NewGeometryOptions();
options.ComputeReferences = true;
options.View = doc.ActiveView;
GeometryElement element = form.get_Geometry(options);
foreach (GeometryObject geoObject in element) // 2013
{
Solid solid = geoObject as Solid;
foreach (Face face in solid.Faces)
{
if (face.Reference != null)
{
if (null != face)
{
}
}
}
}
}
tx.Commit();
}
return Result.Succeeded;
}
catch (Exception ex)
{
message = ex.Message;
return Result.Failed;
}
}
}
【问题讨论】: