# Mesh.WithDisplacement Erro

**URL:** <https://discourse.mcneel.com/t/mesh-withdisplacement-erro/200453>\
**Category:** Rhino Developer\
**Tags:** windows, rhinocommon, rhino7\
**Created:** [February 27, 2025, 3:35pm UTC](https://discourse.mcneel.com/t/mesh-withdisplacement-erro/200453 "2025-02-27T15:35:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![JimmyF](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/jimmyf/32/639494_2.png) [@JimmyF](https://discourse.mcneel.com/u/JimmyF)\
**Post date:** [February 27, 2025, 3:35pm UTC](https://discourse.mcneel.com/t/mesh-withdisplacement-erro/200453/1 "2025-02-27T15:35:38Z")

</div>

I want to aplly image texture to a mesh,and use the code below,but return nothing,Can you help me?@Dale

 ![微信截图_20250227232509](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/9/4/1/941993e5c6bb652abfd91855164acbadc63caf7a.jpeg)  
 ![微信截图_20250227232943](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/3/f/3/3f358af8f5cd29054a02ecf111570ef9622c698e.jpeg)  
[mesh.stl](https://discourse.mcneel.com/uploads/short-url/2UpZzwC78VISPW1PZw8ajaBMPvK.stl) (7.8 MB)  
 ![texture](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/e/3/2e3487fc54b06b8dac541065c30288d8cf7d9dec.jpeg)

```auto
            var go = new GetObject();
            go.GeometryFilter = Rhino.DocObjects.ObjectType.Mesh;
            go.SetCommandPrompt("Select mesh");
            var res = go.Get();
            if (go.ObjectCount == 0) return Result.Failure;
            Mesh targetMesh = go.Object(0).Mesh();
            if(targetMesh ==null) return Result.Failure;
            string imagePath = "C:\\Users\\Administrator\\Desktop\\texture.jpg";
            Bitmap bitmap = new Bitmap(imagePath);
            Rhino.Render.RenderTexture texture = RenderTexture.NewBitmapTexture(bitmap,doc);
            MeshDisplacementInfo info = new MeshDisplacementInfo(texture,TextureMapping.CreateCustomMeshMapping(targetMesh));
            
            info.FaceLimit = int.MaxValue;
            info.BlackMove = 0.5;
            info.MemoryLimit = int.MaxValue;

            Mesh newMesh = targetMesh.WithDisplacement(info);
            doc.Objects.AddMesh(newMesh);
            doc.Views.Redraw();
            return Result.Success;

```
