Broken Mesh with TessellatedShapeBuilder

Broken Mesh with TessellatedShapeBuilder

Anonymous
Not applicable
1,119 Views
3 Replies
Message 1 of 4

Broken Mesh with TessellatedShapeBuilder

Anonymous
Not applicable

I am trying to create a mesh in Revit using TessellatedShapeBuilder, with the mesh data coming in from a different data model. I am creating faces and adding the faces to the shapebuilder. Please see the code attached.

 

1.PNG

 

In the end I add the mesh to the document using DirectShape. And the resulting mesh looks as shown in the picture. Why is the mesh all broken ? The source mesh is normal looking.. looks like a spaceship, but this one is broken. I thought maybe it has something to do with face normals ? Or is there some behavior of tessellatedshapebuilder that I am missing ? What am I doing wrong ?

 

2.PNG

0 Likes
1,120 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

I guess there are a lot of things you might be doing wrong.

 

No idea what they may be.

 

I cannot read your code from an image.

 

Here is a list of some issues I addressed and solved creating direct shape elements from quite complex OBJ source files:

 

http://thebuildingcoder.typepad.com/blog/2015/02/from-hack-to-app-obj-mesh-import-to-directshape.htm...

 

Cheers,

 

Jeremy



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

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi,

 

Here is the source code:

 

(ppm) => {
  rg.TessellatedShapeBuilder builder = new rg.TessellatedShapeBuilder();
  builder.OpenConnectedFaceSet(true);
  builder.Target = rg.TessellatedShapeBuilderTarget.Mesh;
  builder.Fallback = rg.TessellatedShapeBuilderFallback.Salvage;
  List<rg.XYZ> allVerts = ppm.Vertices.Select((pt) => ptConv.FromPipe<rg.XYZ, ppg.Vec>(pt)).ToList();
  foreach (var face in ppm.Faces)
  {
    List<rg.XYZ> faceVerts = new List<rg.XYZ>();
    foreach(ulong vertIndex in face)
    {
      faceVerts.Add(allVerts[(int)vertIndex]);
    }
    rg.TessellatedFace tface = new rg.TessellatedFace(faceVerts, rg.ElementId.InvalidElementId);
    //if (!builder.DoesFaceHaveEnoughLoopsAndVertices(tface)) { continue; }
    builder.AddFace(tface);
  }
  builder.CloseConnectedFaceSet();
  builder.Build();
  rg.TessellatedShapeBuilderResult result = builder.GetBuildResult();
  List<rg.GeometryObject> geoms = result.GetGeometricalObjects().ToList();
  return (rg.Mesh)geoms.FirstOrDefault();
}

 

I saw that article before and the airplane seems to be the closest match, which is caused by smoothing groups, but I don't have any smoothing groups.

Is there any other way to debug this and find out what exactly is going wrong with DirectShape ?!

Thanks !

0 Likes
Message 4 of 4

Anonymous
Not applicable

I was able to export simpler meshes (spheres and cubes) and they work just fine. So that eliminates the face normal issue. Its only happening with complex shapes.

0 Likes