I am trying to do list operations in Python, however it keeps giving me errors. So, I downloaded the MathNet.Numerics on my desk top, but I have no idea how to install/import the package in Python. So, please if you have any suggestions please let me know. Thanks!

I found this resource on GH forum… as both use IronPython you may have a go

1 Like

The Grasshopper link helped, Thank you very much!

Hi @Emad_R I will be very interested to see some examples of use MathNet.Numerics with Dynamo project… so please share once you complete your task.

Will do, Thanks again!


I just tried one of the examples. It works in the IronPython console but not in Dynamo.


That’s the same problem I’m having, unfortunately I didn’t resolve it yet.
There is a Dynamo package, “DynamoMathematica”, if you want to give it a try. I looked for examples using the package, but again with no success, I couldn’t find any. If you find any solution or examples for both Python or the package, please let me know. Sorry for not being of much help.

It worked for me after I rebooted the computer


@ricardo Thanks a lot for sharing. it works!!


I’ve made some improvements so that the code accepts the vectors of the new base and the vector to get the coordinates relative to that base

import sys
sys.path.append("C:\Program Files (x86)\IronPython 2.7\Lib")

import os

import clr

# Import Dynamo Geometry Nodes
from Autodesk.DesignScript.Geometry import *

# Import Math.NET library
from clr import AddReferenceToFileAndPath as addref
location = os.path.join(os.path.expanduser("~"),
'D:\\Dropbox\\Dynamo Workspaces\\Nuget\MathNet.Numerics.4.5.1\\lib\\net40\\MathNet.Numerics.dll')

import MathNet.Numerics.LinearAlgebra as la

from System import Array as sys_array

def array(*x): 
    return sys_array[float](x) #float is equivalent to .Net double

newBaseVectors = IN[0]
newX = newBaseVectors[0]
newY = newBaseVectors[1]
newZ = newBaseVectors[2]

# Vector to get relative coordinates
vectorCoordinates = IN[1]

# Coordinates of V relative to World
Vx = vectorCoordinates.X
Vy = vectorCoordinates.Y
Vz = vectorCoordinates.Z

A = la.Double.Matrix.Build.DenseOfRowArrays(array(newX.X, newX.Y, newX.Z),array(newY.X,newY.Y,newY.Z),array(newZ.X,newZ.Y,newZ.Z))

B = la.Double.Vector.Build.DenseOfArray(array(Vx, Vy, Vz))

x = A.Solve(B)

OUT = x

But I got a strange result.

When I ask Dynamo to generate the point with the coordinates relative to the new base, the point appears elsewhere. When was it to appear in the same place.

What am I missing?

I found the right way.

I can not see why Dynamo is generating the point elsewhere via the Point.ByCartesianCoordinates node.