Hi all,

I am looking for a command that deconstruct a matrix in rhinocommon like the grasshopper componant deconstruct matrix.

I could not find that in the matrix class. Is there something similar ?.

Cheers,

Ghaith

Hi all,

I am looking for a command that deconstruct a matrix in rhinocommon like the grasshopper componant deconstruct matrix.

I could not find that in the matrix class. Is there something similar ?.

Cheers,

Ghaith

Hi @tish.ghaith,

I haven’t tested this. But this *should* be the C# equivalent:

```
public static double[] DeconstructMatrix(
Rhino.Geometry.Matrix matrix,
out int rowCount,
out int colCount
)
{
rowCount = colCount = 0;
if (null == matrix)
throw new System.ArgumentNullException(nameof(matrix));
rowCount = matrix.RowCount;
colCount = matrix.ColumnCount;
var values = new System.Collections.Generic.List<double>(rowCount * colCount);
for (var r = 0; r < rowCount; r++)
{
for (var c = 0; c < colCount; c++)
values.Add(matrix[r, c]);
}
return values.ToArray();
}
```

– Dale

1 Like

Many Thanks!. It looks like we can access the matrix like if it is a list of lists already. The matrix type basically inherits from List Type or ? I have seen it inherits from Idisposable pattern. such things I find a bit confusing in the documentatoin. It might be helpful maybe if we can tell from the description the behavioure of the objects. “Just a suggestion”

Hi @tish.ghaith,

When you see a RhinoCommon class that inherits from IDisposible, then the class is a wrapper for one Rhino’s core SDK class., ON_Matrix in this case.

– Dale

1 Like