Function WithDisplacement problem

Hello every one, I attempt to using the following function to extrude a mesh.

Public Function WithDisplacement (displacement As MeshDisplacementInfo) As Mesh
    Dim k As Rhino.Geometry.MeshDisplacementInfo
    k.ChannelNumber = 1
    k.BlackMove() = 3
    Dim sdd As Mesh
    sdd = msh(0).WithDisplacement(k)
    RhinoDoc.ActiveDoc.Objects.AddMesh(sdd)
    RhinoDoc.ActiveDoc.Views.Redraw()

But the result show me that k is nothing? How to solve this problem?

thanks~~

Hi @jerry1,

Does this helps?

https://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_Geometry_MeshDisplacementInfo__ctor.htm

– Dale

Thanks. But I still have a problem. I modify my code:

    Dim s1 As Rhino.Render.RenderTexture
    Dim s2 As Rhino.Render.TextureMapping
    Dim k As New Rhino.Geometry.MeshDisplacementInfo(s1, s2)
    k.ChannelNumber = 1
    k.BlackMove = 3
    Dim sdd As Mesh
    sdd = msh(0).WithDisplacement(k)
    RhinoDoc.ActiveDoc.Objects.AddMesh(sdd)
    RhinoDoc.ActiveDoc.Views.Redraw()

    and the msh(0) already be added texture(see the figure). but I do not 
    know how to give s1 s2 value, how to do? many thanks. 

    ![r1|472x355](upload://kOnN9O5zgR6teIcVz643tAGPZe.jpeg)

r1

I think that the problem has be solved through modifying the code:

    Dim objj As Rhino.DocObjects.RhinoObject
    objj = meshObjRefs(0).Object
    Dim sindex As Integer
    sindex = objj.Attributes.MaterialIndex
    Dim matt As Rhino.DocObjects.Material
    matt = RhinoDoc.ActiveDoc.Materials(sindex)
    '
    Dim s1 As Rhino.Render.RenderTexture
    Dim s2 As Rhino.Render.TextureMapping
    '
    s1 = matt.RenderMaterial.GetTextureFromUsage(Rhino.Render.RenderMaterial.StandardChildSlots.Diffuse)

    '
    Dim k11() As Integer
    k11 = objj.GetTextureChannels()
    s2 = objj.GetTextureMapping(k11(0))

    '
    Dim k As New Rhino.Geometry.MeshDisplacementInfo(s1, s2)
    k.BlackMove = 0.5
    k.FaceLimit = 10000000
    Dim sdd As Mesh
    msh = kpk.Item(0).Geometry
    sdd = msh.WithDisplacement(k)
    RhinoDoc.ActiveDoc.Objects.AddMesh(sdd)
    RhinoDoc.ActiveDoc.Views.Redraw()

   but when I execute the withDisplacement(k) function.....appear the warning 
   message" -- mesh memory limit hit "?  could anyone help me?