Autodesk.Revit.DB.SolidOptions是一个类,用于定义创建Solid的选项。SolidOptions是Solid.Create方法的参数之一。
public bool ComputeReferences { get; set; }
如果设置为true,则Solid对象将计算其相应参考的引用。默认为false。
public ViewDetailLevel DetailLevel { get; set; }
定义创建Solid的视图详细级别。默认为Medium。
public bool VisibleEdgesOnly { get; set; }
如果设置为true,则只显示可见的边。默认为false。
以下示例演示如何创建一个Solid对象,并使用SolidOptions指定选项:
Element elem = ...
GeometryElement geomElem = elem.get_Geometry(new Options());
foreach (GeometryObject geomObj in geomElem)
{
Solid solid = geomObj as Solid;
if (null != solid && solid.Volume > 0)
{
SolidOptions options = new SolidOptions();
options.ComputeReferences = true;
options.DetailLevel = ViewDetailLevel.Fine;
options.VisibleEdgesOnly = false;
ElementId categoryId = ...
using (Transaction tx = new Transaction(doc))
{
tx.Start("Create Solid");
DirectShape ds = DirectShape.CreateElement(doc, categoryId, elem.Id);
ds.SetShape(new GeometryObject[] { solid }, options);
doc.Regenerate();
tx.Commit();
}
break;
}
}
在上面的示例中,首先获取与要素相关联的GeometryElement。然后遍历GeometryElement,找到一个具有正体积的Solid对象。接下来,创建SolidOptions对象,并为选项设置适当的值。最后,使用SetShape方法将Solid对象添加到DirectShape对象中。