| STL to Solid
| |
Info & Tags |
| |
| Article #: |
4 |
| Created: |
2010-02-15 |
| Modified: |
2010-05-19 |
| Tags: |
eyeshot3, solid |
|
To perform a boolean operation on a model imported via STL file format you need first to convert it to Solid.
The following code snippet provides the basic steps to read a STL file from disk, convert it to Solid and make a boolean cut on it.
| C# |
Entity[] entList;
viewport.ReadSTL("c:\\test.stl", out entList);
StlModel stlModel = (StlModel) entList[0];
Mesh asMesh = stlModel.ConvertToMesh();
Solid asSolid = new Solid();
asSolid.FromTriangles(asMesh.Vertices, asMesh.Triangles);
Solid tool = new Box(80, 200, 200);
viewport.Entities.Add(tool, 0, Color.FromArgb(100, Color.Green));
Solid[] cut = viewport.Difference(asSolid, tool);
viewport.Entities.AddRange(cut, 0, Color.DimGray); |
| Visual Basic |
Dim entList As Entity()
viewport.ReadSTL("c:\test.stl", entList)
Dim stlModel As StlModel = DirectCast(entList(0), StlModel)
Dim asMesh As Mesh = stlModel.ConvertToMesh()
Dim asSolid As New Solid()
asSolid.FromTriangles(asMesh.Vertices, asMesh.Triangles)
Dim tool As Solid = New Box(80, 200, 200)
viewport.Entities.Add(tool, 0, Color.FromArgb(100, Color.Green))
Dim cut As Solid() = viewport.Difference(asSolid, tool)
viewport.Entities.AddRange(cut, 0, Color.DimGray) |
|