This method is called when a tessellated polymesh of a 3d face is being output.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since: 2014
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- node
- Type: Autodesk.Revit.DBPolymeshTopology
A node representing topology of the polymesh
Examples

/// <summary>
/// This method is called up for every face that was processed and tessellated
/// </summary>
/// <remarks>
/// The node provides all information about geometric topology if the mesh.
/// It is assumed that a concrete exporter would consume the part it can
/// understand and/or support (vertices, normals, UVs, etc.) and convert
/// them into the final, export format.
/// </remarks>
public void OnPolymesh(PolymeshTopology node)
{
// Note: the current material will get applied to the polymesh.
// If a stack of transformation is maintained by the context object,
// the current combined transform will be applied to the points.
Transform currentTransform = m_TransformationStack.Peek();
// basic properties of the mesh
int numberOfFacet = node.NumberOfFacets;
int numberOfPoints = node.NumberOfPoints;
int numberOfUVs = node.NumberOfUVs;
int numberOfNormal = node.NumberOfNormals;
// Note: Normals are associated with either points or facets of the polymesh
// The export code must account for different processing of these two cases.
// A) process points of the polymesh
if( node.DistributionOfNormals == DistributionOfNormals.AtEachPoint )
{
ExportMeshPoints(node.GetPoints(), currentTransform, node.GetNormals() );
}
else if( node.DistributionOfNormals == DistributionOfNormals.OnePerFace )
{
ExportMeshPoints(node.GetPoints(), currentTransform, node.GetNormal(0) );
}
else // DistributionOfNormals.OnEachFacet
{
// In this case, there is normal vector associated with each facet
// Depending on the export, our format either support this case,
// of we would have to determine what normals to apply at each
// point by a way of combining normal of the surrounding facets.
ExportMeshPoints(node.GetPoints(), currentTransform );
}
// B Process facets of the polymesh
if( node.DistributionOfNormals == DistributionOfNormals.OnEachFacet )
{
ExportMeshFacets(node.GetFacets(), node.GetNormals() );
}
else
{
ExportMeshFacets(node.GetFacets(), null );
}
// B) Process UV coordinates if available (and applicable)
if( node.NumberOfUVs > 0 )
{
ExportMeshUVs( node.GetUVs() );
}
}
private void ExportMeshPoints(IList<XYZ> points, Transform trf, IList<XYZ> normals)
{
// process points with normals
}
private void ExportMeshPoints(IList<XYZ> points, Transform trf, XYZ normal)
{
// process points with only one normal vector (a planar face)
}
private void ExportMeshPoints(IList<XYZ> points, Transform trf)
{
// process points without normal (assuming normals are associated with facets instead)
}
private void ExportMeshFacets(IList<PolymeshFacet> facets, IList<XYZ> normals)
{
if (normals == null)
{
// process facets without normals (assuming normals are associated with points instead)
}
else
{
// process facets with normals
}
}
private void ExportMeshUVs(IList<UV> UVs)
{
// process UVs
}

' <summary>
' This method is called up for every face that was processed and tessellated
' </summary>
' <remarks>
' The node provides all information about geometric topology if the mesh.
' It is assumed that a concrete exporter would consume the part it can
' understand and/or support (vertices, normals, UVs, etc.) and convert
' them into the final, export format.
' </remarks>
Public Sub OnPolymesh(node As PolymeshTopology) Implements IExportContext.OnPolymesh
' Note: the current material will get applied to the polymesh.
' If a stack of transformation is maintained by the context object,
' the current combined transform will be applied to the points.
Dim currentTransform As Transform = m_TransformationStack.Peek()
' basic properties of the mesh
Dim numberOfFacet As Integer = node.NumberOfFacets
Dim numberOfPoints As Integer = node.NumberOfPoints
Dim numberOfUVs As Integer = node.NumberOfUVs
Dim numberOfNormal As Integer = node.NumberOfNormals
' Note: Normals are associated with either points or facets of the polymesh
' The export code must account for different processing of these two cases.
' A) process points of the polymesh
If node.DistributionOfNormals = DistributionOfNormals.AtEachPoint Then
ExportMeshPoints(node.GetPoints(), currentTransform, node.GetNormals())
ElseIf node.DistributionOfNormals = DistributionOfNormals.OnePerFace Then
ExportMeshPoints(node.GetPoints(), currentTransform, node.GetNormal(0))
Else
' DistributionOfNormals.OnEachFacet
' In this case, there is normal vector associated with each facet
' Depending on the export, our format either support this case,
' of we would have to determine what normals to apply at each
' point by a way of combining normal of the surrounding facets.
ExportMeshPoints(node.GetPoints(), currentTransform)
End If
' B Process facets of the polymesh
If node.DistributionOfNormals = DistributionOfNormals.OnEachFacet Then
ExportMeshFacets(node.GetFacets(), node.GetNormals())
Else
ExportMeshFacets(node.GetFacets(), Nothing)
End If
' B) Process UV coordinates if available (and applicable)
If node.NumberOfUVs > 0 Then
ExportMeshUVs(node.GetUVs())
End If
End Sub
Private Sub ExportMeshPoints(points As IList(Of XYZ), trf As Transform, normals As IList(Of XYZ))
' process points with normals
End Sub
Private Sub ExportMeshPoints(points As IList(Of XYZ), trf As Transform, normal As XYZ)
' process points with only one normal vector (a planar face)
End Sub
Private Sub ExportMeshPoints(points As IList(Of XYZ), trf As Transform)
' process points without normal (assuming normals are associated with facets instead)
End Sub
Private Sub ExportMeshFacets(facets As IList(Of PolymeshFacet), normals As IList(Of XYZ))
' process facets without normals (assuming normals are associated with points instead)
If normals Is Nothing Then
' process facets with normals
Else
End If
End Sub
Private Sub ExportMeshUVs(UVs As IList(Of UV))
' process UVs
End Sub