Rhino inside Revit ShrinkWrap problem

I load one .3dm file containing a mesh. Everything seem ok until last line.

var rhinoDocument = Rhino.RhinoDoc.ActiveDoc;
Rhino.FileIO.File3dm result = Rhino.FileIO.File3dm.Read(@"d:\data\2.3dm");

           
     foreach (Rhino.FileIO.File3dmObject geometry in result.Objects)
            {
            var boundingBox = geometry.Geometry.GetBoundingBox(true);
            Rhino.Geometry.Mesh mesh = geometry.Geometry as Rhino.Geometry.Mesh;
            rhinoDocument.Objects.Add(mesh);
            List <Rhino.Geometry.Mesh> meshes = new List< Rhino.Geometry.Mesh >();
            meshes.Add(mesh);

            ShrinkWrapParameters shrinkWrapParameters = new ShrinkWrapParameters();
            shrinkWrapParameters.Offset = 1;
            shrinkWrapParameters.PolygonOptimization = 100;
            Rhino.Geometry.Mesh meshshrinked = 
            Rhino.Geometry.Mesh.ShrinkWrap(meshes,shrinkWrapParameters); 

image

I’m not having any issues from inside of Rhino with your code. Can you post the file?

Thank you very much for you answer. The file :
2.3dm (2.1 MB)
I did my own investigation on this file and it is the best one. Lots of not manifold vertices.
That could have been the reason.
I CGAL 3d wrapping swallow everything and makes a 2-manifold object. Anyway i liked this shis better because of the negative offfset,

Tommy

Tried with a 100 perfect closed mesh ans still the same error.

If you try this from within Rhino does it work as expected?

Things I notice.

  1. your code example was incomplete

Here’s the example code I am testing.

      var rhinoDocument = Rhino.RhinoDoc.ActiveDoc;
      Rhino.FileIO.File3dm result = Rhino.FileIO.File3dm.Read(@"e:\2.3dm");
      List<Rhino.Geometry.Mesh> meshes = new List<Rhino.Geometry.Mesh>();

        foreach (Rhino.FileIO.File3dmObject geometry in result.Objects)
        {
          Rhino.Geometry.Mesh mesh = geometry.Geometry as Rhino.Geometry.Mesh;
          rhinoDocument.Objects.Add(mesh);
          meshes.Add(mesh);
        }
        
        ShrinkWrapParameters shrinkWrapParameters = new ShrinkWrapParameters();
        shrinkWrapParameters.Offset = 1;
        shrinkWrapParameters.TargetEdgeLength = 10;
        shrinkWrapParameters.PolygonOptimization = 100;
        Rhino.Geometry.Mesh meshshrinked = Rhino.Geometry.Mesh.ShrinkWrap(meshes, shrinkWrapParameters);
        
        if(meshshrinked != null)
        {
          rhinoDocument.Objects.Add(meshshrinked);
        }
        rhinoDocument.Views.Redraw();
  1. You weren’t setting any target edge length. This will result in the default of 1 unit, and on an object of the size of 2.3dm this could be a mesh that’s too large for the system. I found 10 to produce a fairly large mesh. You might also want to add some code that looks at units and the bounding box size of the mesh you’re about to wrap. This will help avoid out of memory issues and or other problems in the event of something unexpected.

Thank you for your replay but will still not run from Revit. Will test from Rhino.