Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to remove a Triangle from a Mesh

3 REPLIES 3
Reply
Message 1 of 4
sam.z
1649 Views, 3 Replies

How to remove a Triangle from a Mesh

Hello

I wish to remove a triangle from a Mesh. The mesh is part of a TopographySurface. How do you remove a triangle from a Mesh? There isn't a function to do this?

The following code can successfully retrieve a TopographySurface's Mesh and finds the triangle I wish to remove, but there isn't any function AFAIK that can remove a triangle from a mesh. I hope there is:

public static int removeTriangle(Document doc, ref TopographySurface surface, uint triangleIndex)
{
    Mesh mesh = null;
    Options op = new Options();
    op.ComputeReferences = true;
    IEnumerator<GeometryObject> geoObjects = surface.get_Geometry(op).GetEnumerator();
    
    while (geoObjects.MoveNext()) {
        GeometryObject geoObj = geoObjects.Current as GeometryObject;
        
        if (geoObj is Mesh) {
            mesh = geoObj as Mesh;
            break;
        }
    }
    
    if (mesh == null)
        return -1;

    MeshTriangle p1 = mesh.get_Triangle(triangleIndex);
    //mesh.removeTriangle(triangleIndex);

    return 1;
}

 

3 REPLIES 3
Message 2 of 4
jeremytammik
in reply to: sam.z

As far as I know, a mesh is a read-only geometrical object in the Revit API.

 

You can, however, edit the topography surface and remove individual points from it.

 

That ought to enable you to eliminate the unwanted mesh triangle.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4
Revitalizer
in reply to: jeremytammik

Hi Jeremy,

 

removing points from an existing TopoSurface wouldn't mean to cut holes into it.

Since TopoSurface uses some sort of convex hull, it would also affect neighboring triangles when removing shared vertices.

 

 

Best regards,

Revitalizer

 

P.S.: see you this Saturday 😉




Rudolf Honke
Software Developer
Mensch und Maschine





Message 4 of 4
jeremytammik
in reply to: Revitalizer

Dear Revitalizer,

 

Yes, absolutely. And no, not at all. If you wanted to fiddle with the mesh, you would have to redefine the triangles, of course. The topography surface just manages a bunch of points, though, and triangulates them itself, doesn't it? Looking frward to seeing you Saturday!

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community