Hi, I am trying to convert a tin to a 3D polygon feature class. Could someone help me with this code? I am not sure it is correct.

I got this error "The geometry has null Z values" on the line "Set pFeat.Shape = pPoly"

Hope Neil to be there!!! Thanks, Mar

Dim pSxDoc As ISxDocument

Set pSxDoc = ThisDocument

Dim pScene As IScene

Set pScene = pSxDoc.Scene

Dim pTinLayer As ITinLayer

Set pTinLayer = pScene.Layer(0)

Dim pTin As ITin

Set pTin = pTinLayer.Dataset

Dim pTinAdv As ITinAdvanced2

Set pTinAdv = pTin

Dim pTinTriangle As ITinTriangle

Dim pTinPoly As ITinPolygon

Dim pPoly As IPolygon5

Dim pZAware As IZAware

Dim pPolyLayer As IFeatureLayer

Dim pPolyFC As IFeatureClass

Dim pFeat As IFeature

Dim pFunSurf As IFunctionalSurface

Dim pIZ As IZ

Dim i As Long

For i = 1 To pTinAdv.TriangleCount

Set pTinTriangle = pTinAdv.GetTriangle(i)

Set pTinPoly = pTinAdv.ExtractPolygon(pTinTriangle, Nothing, False)

Set pPoly = pTinPoly.AsPolygon(Nothing, True)

Set pPolyLayer = pScene.Layer(1)

Set pPolyFC = pPolyLayer.FeatureClass

Set pZAware = pPoly

pZAware.ZAware = True

Set pFunSurf = pTin

Set pIZ = pPoly

pIZ.InterpolateFromSurface pFunSurf

Set pFeat = pPolyFC.CreateFeature

Set pFeat.Shape = pPoly "The geometry has null Z values"

pFeat.Store

Next

I got this error "The geometry has null Z values" on the line "Set pFeat.Shape = pPoly"

Hope Neil to be there!!! Thanks, Mar

Dim pSxDoc As ISxDocument

Set pSxDoc = ThisDocument

Dim pScene As IScene

Set pScene = pSxDoc.Scene

Dim pTinLayer As ITinLayer

Set pTinLayer = pScene.Layer(0)

Dim pTin As ITin

Set pTin = pTinLayer.Dataset

Dim pTinAdv As ITinAdvanced2

Set pTinAdv = pTin

Dim pTinTriangle As ITinTriangle

Dim pTinPoly As ITinPolygon

Dim pPoly As IPolygon5

Dim pZAware As IZAware

Dim pPolyLayer As IFeatureLayer

Dim pPolyFC As IFeatureClass

Dim pFeat As IFeature

Dim pFunSurf As IFunctionalSurface

Dim pIZ As IZ

Dim i As Long

For i = 1 To pTinAdv.TriangleCount

Set pTinTriangle = pTinAdv.GetTriangle(i)

Set pTinPoly = pTinAdv.ExtractPolygon(pTinTriangle, Nothing, False)

Set pPoly = pTinPoly.AsPolygon(Nothing, True)

Set pPolyLayer = pScene.Layer(1)

Set pPolyFC = pPolyLayer.FeatureClass

Set pZAware = pPoly

pZAware.ZAware = True

Set pFunSurf = pTin

Set pIZ = pPoly

pIZ.InterpolateFromSurface pFunSurf

Set pFeat = pPolyFC.CreateFeature

Set pFeat.Shape = pPoly "The geometry has null Z values"

pFeat.Store

Next

It also concerns me that you are looping through all the triangles and calling extract polygon with the triangle and no filter and stop at edge false. That means that if your TIN is a continuous surface, you will get a polygon representing the entire surface for each call to extract polygon.

If your intention is to create a triangular polygon for each triangle of the TIN, I think you are better off creating a new polygon for each triangle and adding the three nodes of the triangle as points to that polygon.