本文整理汇总了C#中ExporterIFC.GetOrCreateFillPattern方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetOrCreateFillPattern方法的具体用法?C# ExporterIFC.GetOrCreateFillPattern怎么用?C# ExporterIFC.GetOrCreateFillPattern使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetOrCreateFillPattern方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOrCreateMaterialHandle
/// <summary>
/// Gets material handle from material id or creates one if there is none.
/// </summary>
/// <param name="exporterIFC">The ExporterIFC object.</param>
/// <param name="materialId">The material id.</param>
/// <returns>The handle.</returns>
public static IFCAnyHandle GetOrCreateMaterialHandle(ExporterIFC exporterIFC, ElementId materialId)
{
Document document = ExporterCacheManager.Document;
IFCAnyHandle materialNameHandle = ExporterCacheManager.MaterialHandleCache.Find(materialId);
if (IFCAnyHandleUtil.IsNullOrHasNoValue(materialNameHandle))
{
string materialName = " <Unnamed>";
if (materialId != ElementId.InvalidElementId)
{
Material material = document.GetElement(materialId) as Material;
if (material != null)
{
materialName = material.Name;
}
}
materialNameHandle = IFCInstanceExporter.CreateMaterial(exporterIFC.GetFile(), materialName);
ExporterCacheManager.MaterialHandleCache.Register(materialId, materialNameHandle);
// associate Material with SurfaceStyle if necessary.
IFCFile file = exporterIFC.GetFile();
if (materialId != ElementId.InvalidElementId && !ExporterCacheManager.ExportOptionsCache.ExportAs2x2 && materialNameHandle.HasValue)
{
HashSet<IFCAnyHandle> matRepHandles = IFCAnyHandleUtil.GetHasRepresentation(materialNameHandle);
if (matRepHandles.Count == 0)
{
Material matElem = document.GetElement(materialId) as Material;
ElementId fillPatternId = (matElem != null) ? matElem.CutPatternId : ElementId.InvalidElementId;
Autodesk.Revit.DB.Color color = (matElem != null) ? GetSafeColor(matElem.CutPatternColor) : new Color(0, 0, 0);
double planScale = 100.0;
HashSet<IFCAnyHandle> styles = new HashSet<IFCAnyHandle>();
bool hasFill = false;
IFCAnyHandle styledRepItem = null;
IFCAnyHandle matStyleHnd = CategoryUtil.GetOrCreateMaterialStyle(document, exporterIFC, materialId);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(matStyleHnd))
{
styles.Add(matStyleHnd);
bool supportCutStyles = !ExporterCacheManager.ExportOptionsCache.ExportAsCoordinationView2;
if (fillPatternId != ElementId.InvalidElementId && supportCutStyles)
{
IFCAnyHandle cutStyleHnd = exporterIFC.GetOrCreateFillPattern(fillPatternId, color, planScale);
if (cutStyleHnd.HasValue)
{
styles.Add(cutStyleHnd);
hasFill = true;
}
}
IFCAnyHandle presStyleHnd = IFCInstanceExporter.CreatePresentationStyleAssignment(file, styles);
HashSet<IFCAnyHandle> presStyleSet = new HashSet<IFCAnyHandle>();
presStyleSet.Add(presStyleHnd);
IFCAnyHandle styledItemHnd = IFCInstanceExporter.CreateStyledItem(file, styledRepItem, presStyleSet, null);
IFCAnyHandle contextOfItems = exporterIFC.Get3DContextHandle("");
string repId = "Style";
string repType = (hasFill) ? "Material and Cut Pattern" : "Material";
HashSet<IFCAnyHandle> repItems = new HashSet<IFCAnyHandle>();
repItems.Add(styledItemHnd);
IFCAnyHandle styleRepHnd = IFCInstanceExporter.CreateStyledRepresentation(file, contextOfItems, repId, repType, repItems);
List<IFCAnyHandle> repList = new List<IFCAnyHandle>();
repList.Add(styleRepHnd);
IFCAnyHandle matDefRepHnd = IFCInstanceExporter.CreateMaterialDefinitionRepresentation(file, null, null, repList, materialNameHandle);
}
}
}
}
return materialNameHandle;
}