FlipMatrix Python does not work? bug?

Hi everyone
flipmatrix Python does not work? bug? Not defined in c # flipmatrix?


import ghpythonlib as gh
a=gh.components.FlipMatrix(x)

flip matrix.gh (10.2 KB)

Try to add trees before flipmatrix

How?
Can you do?

gh.components.trees it will appear when you type

1 Like

hi not work! flip matrix.-tree.gh (10.3 KB) tree

import rhinoscriptsyntax as rs
import ghpythonlib.components as gh
b=gh.tree(x)
a=gh.FlipMatrix(b)

Hi @Rh-3d-p,

Instead of trying to get node-in-code going, you simply implement the matrix transposition yourself:

from ghpythonlib import treehelpers

matrix = treehelpers.tree_to_list(tree, lambda x: x[0])  # lambda here flattens the tree input (can be removed if manually simplifying the input)
print(matrix)

transposed = [[matrix[j][i] for j in xrange(len(matrix))] for i in xrange(len(matrix[0]))]
print(transposed)

a = treehelpers.list_to_tree(transposed)

I don’t know about Tree Sloth, but you might be able to replace that as well with Python code.

transpose_matrix.gh (8.8 KB)

3 Likes

thank you :heart_eyes:

1 Like

Change x input to Trees Access

image

Just to add, an ultra terse method for transposing a Python list matrix is using zip(*matrix):


210331_TransposeMatrixWithZip_00.gh (5.2 KB)

4 Likes

Another quick solution :pray:

1 Like

Is it possible to control Undo and Redo via slider in Python? (In Gosphaper)


undo+redo.gh (3.9 KB)
@AndersDeleuran
@diff-arch

Thanks a lot, after considerable time, this is still quite useful.

1 Like