Hi everyone!
I wanna get a Triangles collection from Corridor design surface as I do from TINSurface like:
TinSufaceTriangleCollection triangles = surface.Triangles;
I have a Railroad line and a corridor based on design profile of that line and earth surface. I've used a very simple section construction assembled from elements of a base construction library.
As I can see my corridor literally have a suface and triangulation in it.
No matter how hard i've tried I didn't find a way to get this triangles. The most obvious for me was to get surfaces from corridor like:
CorridorSurfaceCollection corSfcs = corridor.CorridorSurfaces;
But there's two problems. First of all value returned by CorridorSurfaces property never have a surfaces inside. I mean the array is always empty. But even if it would contain a surface it will be CorridorSurface Type which have no property or method that will return triangle collection. Maybe I can use CorridorSurface.SurfaceId in which i'll get what i want but at first I need to get CorridorSurface.
I'm some kind of confused. Maybe I should create a surface some another way or smth? Can somebody point on where I'm going wrong way?
Regards!
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
If there is a corridor surface it will be listed in the CorridorSurfaces property. Here is an example which works using the tutorial Corridor - 5c.dwg.
Command: CORRIDORSURFACETEST
There are 4 surface defined in corridor Corridor - (1)
There are 3352 visible triangles in surface Corridor - (1) Top.
[CommandMethod("CorridorSurfaceTest")]
public void surftest()
{
string corridorSurfaceName = "Corridor - (1) Top";
string corridorName = "Corridor - (1)";
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
var _civilDoc = CivilApplication.ActiveDocument;
// get the CorridorSurface by name:
using (Transaction tr = db.TransactionManager.StartTransaction())
{
ObjectId corridorId = _civilDoc.CorridorCollection[corridorName];
Corridor corridor = tr.GetObject(corridorId, OpenMode.ForRead) as Corridor;
CorridorSurface corridorSurface = corridor.CorridorSurfaces[corridorSurfaceName];
TinSurface tinsurf = (TinSurface)tr.GetObject(corridorSurface.SurfaceId, OpenMode.ForRead);
var triangles = tinsurf.GetTriangles(false);
ed.WriteMessage("\nThere are {0} surface defined in corridor {1}", corridor.CorridorSurfaces.Count, corridorName);
ed.WriteMessage("\nThere are {0} visible triangles in surface {1}.", triangles.Count.ToString(), corridorSurfaceName);
tr.Commit();
}
}
Thanks a lot! That's exactly what I was looking for. I've created the corridor but didn't add a surfaces in corridor properties dialog. Now everything's fine! 😊