 # Mesh curvature Pythonscript code to .net

Hi,

I have a Pythonscript file , here is the code.

``````def CurvaM0(topvertex,connection):
type=Rhino.Geometry.Point3d
Kmax=[]
Kmin=[]
t=0
for i in connection:
points=[]
for j in i:
points.append(topvertex[j])
pts=Converts(points,type)
pt=Convert(topvertex[t],type)
ind=topvertex.MeshVertexIndices(t)
nn=mesh.Normals[ind]
nor=Rhino.Geometry.Point3d(nn.X+pt.X, nn.Y+pt.Y, nn.Z+pt.Z)
K=Curvature0(pts,pt,nor)
K.sort()
Kmax.append(K)
Kmin.append(K)
t=t+1
return Kmax,Kmin
``````
`````` topvertex  ---- MeshTopologyVertexList
connection ---- List(Of List(Of Integer))
nn              ---- Vector3d
nor             ---- Point3d
pt               ---- Point3d
``````

The result calculated based on the pythonscript code below is weird .

``````nor=Rhino.Geometry.Point3d(nn.X+pt.X, nn.Y+pt.Y, nn.Z+pt.Z)
``````

when I pass data into the code, for instance,

``````nn.X+pt.X= -0.9816897-35.1987609863281=-36.1804506778717
nn.Y+pt.Y= -0.0908464226052352-16.2358417510986=-16.2305486575
nn.Z+pt.Z= 0.995861129123327+0.114346027374268=0.304759517312
``````

but the result of nor based on the pythonscript actually is

``````nor.x=-0.00273924704027273
nor.y=-0.0908464226052352
nor.z=0.995861129123327
``````

BR

Kalvin

Can you please share the file (not just the function) and a sample if possible, so we can run at our end?

Hi,Rajaa

I’ve solved it ，the reaseon is I used the wrong variable scope.
Thank you for you help.

BG

Kalvin

1 Like