I am trying to code a floorplan with Python in rhino. I started out with a very simple task of separating the plan into 'mass' and 'space'. I am trying to generate an array in an array which is representative of a grid. Now, my problem is that I get a weird output in the following code:
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext
import System.Drawing as sd
grid_plane = [[0,0,0], [0,0,0], [0,0,0]]
grid_plane[0][0] = 'mass'
print grid_plane
grid_x = []
grid_y_and_x = []
for d in range(3):
grid_x.append(0)
print grid_x
for d in range(3):
grid_y_and_x.append(grid_x)
print grid_y_and_x
grid_y_and_x[0][0] = 'mass'
print grid_y_and_x
The outputs I get are as follows:
[['mass', 0, 0], [0, 0, 0], [0, 0, 0]]
[0, 0, 0]
[[0, 0, 0], [0, 0, 0], [0, 0, 0]]
[['mass', 0, 0], ['mass', 0, 0], ['mass', 0, 0]]
I do not understand why mass is added in every list as I only want to add it in the fist list at the first instance.
I was expecting the output to be: [['mass', 0, 0], [0, 0, 0], [0, 0, 0]]
for the second part.
but it is: [['mass', 0, 0], ['mass', 0, 0], ['mass', 0, 0]]