本文整理汇总了C#中ExporterIFC.GetMaterialIdForCurrentExportState方法的典型用法代码示例。如果您正苦于以下问题:C# ExporterIFC.GetMaterialIdForCurrentExportState方法的具体用法?C# ExporterIFC.GetMaterialIdForCurrentExportState怎么用?C# ExporterIFC.GetMaterialIdForCurrentExportState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ExporterIFC
的用法示例。
在下文中一共展示了ExporterIFC.GetMaterialIdForCurrentExportState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateSurfaceStyleForRepItem
/// <summary>
/// Creates the related IfcSurfaceStyle for a representation item.
/// </summary>
/// <param name="exporterIFC">The exporter.</param>
/// <param name="document">The document.</param>
/// <param name="repItemHnd">The representation item.</param>
/// <param name="overrideMatId">The material id to use instead of the one in the exporter, if provided.</param>
/// <returns>The handle.</returns>
public static IFCAnyHandle CreateSurfaceStyleForRepItem(ExporterIFC exporterIFC, Document document, IFCAnyHandle repItemHnd,
ElementId overrideMatId)
{
if (repItemHnd == null || ExporterCacheManager.ExportOptionsCache.ExportAs2x2)
return null;
// Restrict material to proper subtypes.
if (!IFCAnyHandleUtil.IsSubTypeOf(repItemHnd, IFCEntityType.IfcSolidModel) &&
!IFCAnyHandleUtil.IsSubTypeOf(repItemHnd, IFCEntityType.IfcFaceBasedSurfaceModel) &&
!IFCAnyHandleUtil.IsSubTypeOf(repItemHnd, IFCEntityType.IfcShellBasedSurfaceModel) &&
!IFCAnyHandleUtil.IsSubTypeOf(repItemHnd, IFCEntityType.IfcSurface))
{
throw new InvalidOperationException("Attempting to set surface style for unknown item.");
}
IFCFile file = exporterIFC.GetFile();
ElementId materialId = (overrideMatId != ElementId.InvalidElementId) ? overrideMatId : exporterIFC.GetMaterialIdForCurrentExportState();
if (materialId == ElementId.InvalidElementId)
return null;
IFCAnyHandle presStyleHnd = ExporterCacheManager.PresentationStyleAssignmentCache.Find(materialId);
if (presStyleHnd == null)
{
IFCAnyHandle surfStyleHnd = CategoryUtil.GetOrCreateMaterialStyle(document, exporterIFC, materialId);
if (surfStyleHnd == null)
return null;
ICollection<IFCAnyHandle> styles = new HashSet<IFCAnyHandle>();
styles.Add(surfStyleHnd);
presStyleHnd = IFCInstanceExporter.CreatePresentationStyleAssignment(file, styles);
ExporterCacheManager.PresentationStyleAssignmentCache.Register(materialId, presStyleHnd);
}
HashSet<IFCAnyHandle> presStyleSet = new HashSet<IFCAnyHandle>();
presStyleSet.Add(presStyleHnd);
return IFCInstanceExporter.CreateStyledItem(file, repItemHnd, presStyleSet, null);
}
示例2: ExportBody
//.........这里部分代码省略.........
}
}
int numCreatedExtrusions = extrusionLists.Count;
for (int ii = 0; ii < numCreatedExtrusions && tryToExportAsExtrusion; ii++)
{
int geomIndex = exportAsExtrusion[ii];
ElementId matId = SetBestMaterialIdInExporter(geometryList[geomIndex], element, overrideMaterialId, exporterIFC);
if (matId != ElementId.InvalidElementId)
bodyData.AddMaterial(matId);
if (exportBodyParams != null && exportBodyParams.AreInnerRegionsOpenings)
{
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrudedDirection = extrusionLists[ii][0].ExtrusionDirection;
int numLoops = curveLoops.Count;
for (int jj = numLoops - 1; jj > 0; jj--)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][0], curveLoops[jj]);
extrusionLists[ii][0].RemoveLoopAt(jj);
}
}
bool exportedAsExtrusion = false;
IFCExtrusionBasis whichBasis = extrusionLists[ii][0].ExtrusionBasis;
if (whichBasis >= 0)
{
IFCAnyHandle extrusionHandle = ExtrusionExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, element, extrusionLists[ii][0]);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(extrusionHandle))
{
bodyItems.Add(extrusionHandle);
materialIdsForExtrusions.Add(exporterIFC.GetMaterialIdForCurrentExportState());
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrusionDirection = extrusionLists[ii][0].ExtrusionDirection;
if (exportBodyParams != null)
{
exportBodyParams.Slope = GeometryUtil.GetSimpleExtrusionSlope(extrusionDirection, whichBasis);
exportBodyParams.ScaledLength = extrusionLists[ii][0].ScaledExtrusionLength;
exportBodyParams.ExtrusionDirection = extrusionDirection;
for (int kk = 1; kk < extrusionLists[ii].Count; kk++)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][kk]);
}
Plane plane = null;
double height = 0.0, width = 0.0;
if (ExtrusionExporter.ComputeHeightWidthOfCurveLoop(curveLoops[0], plane, out height, out width))
{
exportBodyParams.ScaledHeight = UnitUtil.ScaleLength(height);
exportBodyParams.ScaledWidth = UnitUtil.ScaleLength(width);
}
double area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveLoops);
if (area > 0.0)
{
exportBodyParams.ScaledArea = UnitUtil.ScaleArea(area);
}
double innerPerimeter = ExtrusionExporter.ComputeInnerPerimeterOfCurveLoops(curveLoops);
double outerPerimeter = ExtrusionExporter.ComputeOuterPerimeterOfCurveLoops(curveLoops);
if (innerPerimeter > 0.0)
exportBodyParams.ScaledInnerPerimeter = UnitUtil.ScaleLength(innerPerimeter);
示例3: ExportBody
//.........这里部分代码省略.........
{
extrusionLists.Add(extrusionList);
exportAsExtrusion.Add(ii);
}
}
int numCreatedExtrusions = extrusionLists.Count;
for (int ii = 0; (ii < numCreatedExtrusions) && tryToExportAsExtrusion; ii++)
{
int geomIndex = exportAsExtrusion[ii];
bodyData.AddMaterial(SetBestMaterialIdInExporter(splitGeometryList[geomIndex], exporterIFC));
if (exportBodyParams != null && exportBodyParams.AreInnerRegionsOpenings)
{
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrudedDirection = extrusionLists[ii][0].ExtrusionDirection;
int numLoops = curveLoops.Count;
for (int jj = numLoops - 1; jj > 0; jj--)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][0], curveLoops[jj]);
extrusionLists[ii][0].RemoveLoopAt(jj);
}
}
bool exportedAsExtrusion = false;
IFCExtrusionBasis whichBasis = extrusionLists[ii][0].ExtrusionBasis;
if (whichBasis >= 0)
{
IFCAnyHandle extrusionHandle = ExtrusionExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, element, extrusionLists[ii][0]);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(extrusionHandle))
{
bodyItems.Add(extrusionHandle);
materialIdsForExtrusions.Add(exporterIFC.GetMaterialIdForCurrentExportState());
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrusionDirection = extrusionLists[ii][0].ExtrusionDirection;
if (exportBodyParams != null)
{
double zOff = (whichBasis == IFCExtrusionBasis.BasisZ) ? (1.0 - Math.Abs(extrusionDirection[2])) : Math.Abs(extrusionDirection[2]);
double scaledAngle = Math.Asin(zOff) * 180 / Math.PI;
exportBodyParams.Slope = scaledAngle;
exportBodyParams.ScaledLength = extrusionLists[ii][0].ScaledExtrusionLength;
exportBodyParams.ExtrusionDirection = extrusionDirection;
for (int kk = 1; kk < extrusionLists[ii].Count; kk++)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][kk]);
}
Plane plane = null;
double height = 0.0, width = 0.0;
if (ExtrusionExporter.ComputeHeightWidthOfCurveLoop(curveLoops[0], plane, out height, out width))
{
exportBodyParams.ScaledHeight = height * scale;
exportBodyParams.ScaledWidth = width * scale;
}
double area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveLoops);
if (area > 0.0)
{
exportBodyParams.ScaledArea = area * scale * scale;
}
double innerPerimeter = ExtrusionExporter.ComputeInnerPerimeterOfCurveLoops(curveLoops);
double outerPerimeter = ExtrusionExporter.ComputeOuterPerimeterOfCurveLoops(curveLoops);
示例4: ExportBody
//.........这里部分代码省略.........
}
}
int numCreatedExtrusions = extrusionLists.Count;
for (int ii = 0; ii < numCreatedExtrusions && tryToExportAsExtrusion; ii++)
{
int geomIndex = exportAsExtrusion[ii];
ElementId matId = SetBestMaterialIdInExporter(geometryList[geomIndex], element, overrideMaterialId, exporterIFC);
if (matId != ElementId.InvalidElementId)
bodyData.AddMaterial(matId);
if (exportBodyParams != null && exportBodyParams.AreInnerRegionsOpenings)
{
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrudedDirection = extrusionLists[ii][0].ExtrusionDirection;
int numLoops = curveLoops.Count;
for (int jj = numLoops - 1; jj > 0; jj--)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][0], curveLoops[jj]);
extrusionLists[ii][0].RemoveLoopAt(jj);
}
}
bool exportedAsExtrusion = false;
IFCExtrusionBasis whichBasis = extrusionLists[ii][0].ExtrusionBasis;
if (whichBasis >= 0)
{
IFCAnyHandle extrusionHandle = ExtrusionExporter.CreateExtrudedSolidFromExtrusionData(exporterIFC, element, extrusionLists[ii][0]);
if (!IFCAnyHandleUtil.IsNullOrHasNoValue(extrusionHandle))
{
bodyItems.Add(extrusionHandle);
materialIdsForExtrusions.Add(exporterIFC.GetMaterialIdForCurrentExportState());
IList<CurveLoop> curveLoops = extrusionLists[ii][0].GetLoops();
XYZ extrusionDirection = extrusionLists[ii][0].ExtrusionDirection;
if (exportBodyParams != null)
{
exportBodyParams.Slope = GeometryUtil.GetSimpleExtrusionSlope(extrusionDirection, whichBasis);
exportBodyParams.ScaledLength = extrusionLists[ii][0].ScaledExtrusionLength;
exportBodyParams.ExtrusionDirection = extrusionDirection;
for (int kk = 1; kk < extrusionLists[ii].Count; kk++)
{
ExtrusionExporter.AddOpeningData(exportBodyParams, extrusionLists[ii][kk]);
}
Plane plane = null;
double height = 0.0, width = 0.0;
if (ExtrusionExporter.ComputeHeightWidthOfCurveLoop(curveLoops[0], plane, out height, out width))
{
exportBodyParams.ScaledHeight = height * scale;
exportBodyParams.ScaledWidth = width * scale;
}
double area = ExporterIFCUtils.ComputeAreaOfCurveLoops(curveLoops);
if (area > 0.0)
{
exportBodyParams.ScaledArea = area * scale * scale;
}
double innerPerimeter = ExtrusionExporter.ComputeInnerPerimeterOfCurveLoops(curveLoops);
double outerPerimeter = ExtrusionExporter.ComputeOuterPerimeterOfCurveLoops(curveLoops);
if (innerPerimeter > 0.0)
exportBodyParams.ScaledInnerPerimeter = innerPerimeter * scale;