2

i'm trying to create navigation mesh on autodesk naviswork using Eyeshot.

convert vertices and IndexTriangle to vertice triangles, after create solid using Solid.FromTriangles().

var solidList = new List();
var Solid = Solid.FromTriangles(item.vertices, item.triangles);

but it doesn't work to boolean operators at i thought.

so i want extract region for using boolean operators.

how can i extract region to mesh or solid (or vertices triangles)?

abenci
  • 8,422
  • 19
  • 69
  • 134
Twily
  • 21
  • 2

1 Answers1

2

It is very easy to do. You have to make sure your region vertese are sorted otherwise you might have some issues with it down the line but it's a simple parameter. If the shape isn't hollow here is an example :

// the verteses has to be in order and direction doesn't matter here 
// i simply assume it's drawn on X/Y for the purpose of the example
public static Region CreateRegion(List<Point3D> verteses)
{
    // create a curve list representing
    var curves = new List<ICurve>();

    // for each vertex we add them to the list
    for (int i = 1; i < verteses.Count; i++)
    {
        curves.Add(new Line(verteses[i - 1], verteses[i]));
    }

    // close the region
    curves.Add(new Line(verteses.Last(), verteses[0]));

     return new Region(new CompositeCurve(curves, true), Plane.XY, true);
}

// this extrude in Z the region
public static Solid CreateSolidFromRegion(Region region, double extrudedHeight)
{
    // extrude toward Z by the amount
    return region.ExtrudeAsSolid(new Vector3D(0, 0, 1), extrudedHeight);
}

a simple example of creating a cube of 10 by 10 by 10 from vertese (there are much easier method to make a cube but for sake of simplicity i'll make a cube)

// create the 4 verteses
var verteses = new List<Point3D>()
{
    new Point3D(0, 0, 0),
    new Point3D(10, 0, 0),
    new Point3D(10, 10, 0),
    new Point3D(0, 10, 0)
}

// create the region on the XY plane using the static method
var region = CreateRegion(verteses);

// extrude the region in Z by 10 units
var solid = CreateSolidFromRegion(region, 10d);
Franck
  • 4,438
  • 1
  • 28
  • 55
  • thank you for answer and code sample! but my model (shape) is hollow :’( – Twily Jan 09 '19 at 08:03
  • @Twily this answer, answer exactly what you asked for. It create a solid from a region. now creating hollow solids is a totally different question that has nothing to do with regions. For that you create your solid then copy it, scale it down a bit and substract. – Franck Jan 09 '19 at 15:35