Recently I
was working on a project and I had to use TinSurfaceTriangle object
to access the Surface triangle vertices. You might be knowing already that TinSurfaceTriangle
class encapsulates a triangle in a TinSurface in AutoCAD Civil 3D.
TinSurfaceTriangle type exposes the following members –
Vertex1 – > Gets the first vertex in the
triangle.
Vertex2 – > Gets the second vertex in the
triangle.
Vertex3 – > Gets the third vertex in the
triangle.
One question
came up during our discussion – in which direction (clock-wise or
anti-clockwise) these vertex points are counted. So, to figure out that I did a
quick test to iterate through the vertices and see which direction they are
returned by Civil 3D API. Here is the result which shows us the direction :
And the C# .NET code snippet I used :
using (Transaction trans = db.TransactionManager.StartTransaction())
{
TinSurface surface = trans.GetObject(surfaceId, OpenMode.ForRead) as TinSurface;
TinSurfaceTriangleCollection tinSurfTrianglColl = surface.GetTriangles(true);
if (tinSurfTrianglColl.Count > 0)
{
foreach (TinSurfaceTriangle tinsurfTriangle in tinSurfTrianglColl)
{
// Vertex1
Point3d pnt3d = tinsurfTriangle.Vertex1.Location;
ed.WriteMessage("n Vertex1 :: X1 : " + pnt3d.X.ToString() +
" Y1 : " + pnt3d.Y.ToString() +
" Z1 : " + pnt3d.Z.ToString());
// Vertex2
pnt3d = tinsurfTriangle.Vertex2.Location;
ed.WriteMessage("n Vertex2 :: X1 : " + pnt3d.X.ToString() +
" Y1 : " + pnt3d.Y.ToString() +
" Z1 : " + pnt3d.Z.ToString());
// Vertex3
pnt3d = tinsurfTriangle.Vertex3.Location;
ed.WriteMessage("n Vertex3 :: X1 : " + pnt3d.X.ToString() +
" Y1 : " + pnt3d.Y.ToString() +
" Z1 : " + pnt3d.Z.ToString());
}
}
trans.Commit();
}
Hope this is
useful to you!


Leave a Reply