本文整理汇总了C#中Revit.IFC.Export.Utility.ProductWrapper.ClearFinishMaterials方法的典型用法代码示例。如果您正苦于以下问题:C# ProductWrapper.ClearFinishMaterials方法的具体用法?C# ProductWrapper.ClearFinishMaterials怎么用?C# ProductWrapper.ClearFinishMaterials使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Revit.IFC.Export.Utility.ProductWrapper
的用法示例。
在下文中一共展示了ProductWrapper.ClearFinishMaterials方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExportHostObjectMaterials
/// <summary>
/// Exports materials for host object.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="hostObject">The host object.</param>
/// <param name="elemHnds">The host IFC handles.</param>
/// <param name="geometryElement">The geometry element.</param>
/// <param name="productWrapper">The ProductWrapper.</param>
/// <param name="levelId">The level id.</param>
/// <param name="direction">The IFCLayerSetDirection.</param>
/// <param name="containsBRepGeometry">True if the geometry contains BRep geoemtry. If so, we will export an IfcMaterialList</param>
/// <returns>True if exported successfully, false otherwise.</returns>
public static bool ExportHostObjectMaterials(ExporterIFC exporterIFC, HostObject hostObject,
IList<IFCAnyHandle> elemHnds, GeometryElement geometryElement, ProductWrapper productWrapper,
ElementId levelId, Toolkit.IFCLayerSetDirection direction, bool containsBRepGeometry)
{
if (hostObject == null)
return true; //nothing to do
if (elemHnds == null || (elemHnds.Count == 0))
return true; //nothing to do
IFCFile file = exporterIFC.GetFile();
using (IFCTransaction tr = new IFCTransaction(file))
{
if (productWrapper != null)
productWrapper.ClearFinishMaterials();
double scaledOffset = 0.0, scaledWallWidth = 0.0, wallHeight = 0.0;
Wall wall = hostObject as Wall;
if (wall != null)
{
scaledWallWidth = UnitUtil.ScaleLength(wall.Width);
scaledOffset = -scaledWallWidth / 2.0;
BoundingBoxXYZ boundingBox = wall.get_BoundingBox(null);
if (boundingBox != null)
wallHeight = boundingBox.Max.Z - boundingBox.Min.Z;
}
ElementId typeElemId = hostObject.GetTypeId();
IFCAnyHandle materialLayerSet = ExporterCacheManager.MaterialLayerSetCache.Find(typeElemId);
// Roofs with no components are only allowed one material. We will arbitrarily choose the thickest material.
IFCAnyHandle primaryMaterialHnd = ExporterCacheManager.MaterialLayerSetCache.FindPrimaryMaterialHnd(typeElemId);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(materialLayerSet))
{
HostObjAttributes hostObjAttr = hostObject.Document.GetElement(typeElemId) as HostObjAttributes;
if (hostObjAttr == null)
return true; //nothing to do
List<ElementId> matIds = new List<ElementId>();
List<double> widths = new List<double>();
List<MaterialFunctionAssignment> functions = new List<MaterialFunctionAssignment>();
ElementId baseMatId = CategoryUtil.GetBaseMaterialIdForElement(hostObject);
CompoundStructure cs = hostObjAttr.GetCompoundStructure();
if (cs != null)
{
//TODO: Vertically compound structures are not yet supported by export.
if (!cs.IsVerticallyHomogeneous() && !MathUtil.IsAlmostZero(wallHeight))
cs = cs.GetSimpleCompoundStructure(wallHeight, wallHeight / 2.0);
for (int i = 0; i < cs.LayerCount; ++i)
{
ElementId matId = cs.GetMaterialId(i);
if (matId != ElementId.InvalidElementId)
{
matIds.Add(matId);
}
else
{
matIds.Add(baseMatId);
}
widths.Add(cs.GetLayerWidth(i));
// save layer function into ProductWrapper,
// it's used while exporting "Function" of Pset_CoveringCommon
functions.Add(cs.GetLayerFunction(i));
}
}
if (matIds.Count == 0)
{
matIds.Add(baseMatId);
widths.Add(cs != null ? cs.GetWidth() : 0);
functions.Add(MaterialFunctionAssignment.None);
}
// We can't create IfcMaterialLayers without creating an IfcMaterialLayerSet. So we will simply collate here.
IList<IFCAnyHandle> materialHnds = new List<IFCAnyHandle>();
IList<int> widthIndices = new List<int>();
double thickestLayer = 0.0;
for (int ii = 0; ii < matIds.Count; ++ii)
{
// Require positive width for IFC2x3 and before, and non-negative width for IFC4.
if (widths[ii] < -MathUtil.Eps())
continue;
bool almostZeroWidth = MathUtil.IsAlmostZero(widths[ii]);
if (ExporterCacheManager.ExportOptionsCache.FileVersion != IFCVersion.IFC4 && almostZeroWidth)
continue;
if (almostZeroWidth)
//.........这里部分代码省略.........