Message 1 of 6
Missing Triangles When Creating Surface
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When creating a TIN surface from a PolyFaceMesh using AddFromPolyFaces, not all triangles appear in the final surface, even though they are correctly defined in the mesh.
Missing triangles
Expected area
The issue can be reproduced via the following code:
[CommandMethod("Test")]
public void Test()
{
var doc = Autodesk.AutoCAD.ApplicationServices.Core.Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var civilDoc = CivilDocument.GetCivilDocument(db);
using (doc.LockDocument())
using (var tr = db.TransactionManager.StartTransaction())
{
var bt = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead);
var btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
var mesh = new PolyFaceMesh();
mesh.SetDatabaseDefaults();
btr.AppendEntity(mesh);
tr.AddNewlyCreatedDBObject(mesh, true);
var coords = new[]
{
new Point3d(281369.6831, 711012.3484, 32600),
new Point3d(554192.1153, 583139.5499, 32600),
new Point3d(447598.0605, 299186.0469, 32600),
new Point3d(360358.5154, 113734.1993, 32600),
new Point3d(177125.9921, 199246.3057, 32600),
new Point3d(159658.2854, 163972.7882, 32600),
new Point3d(58598.3385, 224746.4580, 32600),
};
foreach (var pt in coords)
{
var vtx = new PolyFaceMeshVertex(pt);
mesh.AppendVertex(vtx);
tr.AddNewlyCreatedDBObject(vtx, true);
}
var tris = new[]
{
new[] { 0, 1, 2 },
new[] { 0, 2, 3 },
new[] { 0, 3, 4 },
new[] { 0, 4, 5 },
new[] { 0, 5, 6 },
};
foreach (var t in tris)
{
var face = new FaceRecord((short)(t[0] + 1), (short)(t[1] + 1), (short)(t[2] + 1), 0);
mesh.AppendFaceRecord(face);
tr.AddNewlyCreatedDBObject(face, true);
}
var surfId = TinSurface.Create(db, "surfaceName");
var surface = (TinSurface)tr.GetObject(surfId, OpenMode.ForWrite);
surface.DrawingObjectsDefinition.AddFromPolyFaces(new ObjectIdCollection(new[] { mesh.ObjectId }), true, "desc");
var toDelete = surface.GetEdges().Where(e => !e.IsLocked).ToList();
if (toDelete.Count > 0) surface.DeleteLines(toDelete);
mesh.Erase();
surface.Rebuild();
tr.Commit();
}
}
##########
Ngu Soon Hui
##########
I'm the Benevolent Dictator for Life for MiTS Software. Read more here
I also setup Civil WHIZ in order to share what I learnt about Civil 3D
Ngu Soon Hui
##########
I'm the Benevolent Dictator for Life for MiTS Software. Read more here
I also setup Civil WHIZ in order to share what I learnt about Civil 3D