I’m currently writing a program to design a mass timber building. As part of that effort, one section of my python code is needed to build a 3D model of the building, which is essentially a series of various cuboids representing the beams, columns, and slabs, and looks as below:
My question is - what would be the most efficient way to draw such a structure? The data is generated within a Python node, so it might be preferable to keep the drawing within Python. Alternatively, I could output the data required and then use standard GH components to create the 3D view.
Currently I’m drawing this by creating a Python function which draws a mesh cuboid (mesh with 6 faces) and then looping over all the elements in a list to draw them all. Function is as follows:
> def DrawCube(c,x,y,z,Capped=True): > ErrorText = 'c should be a list or tuple of (x,y,z) coordinates' > if not isinstance(c,list) and not isinstance(c,tuple): > print ErrorText > if isinstance(c,list) or isinstance(c,tuple): > if len(c) != 3: > print ErrorText > dim = [x/2, > y/2, > z/2] > d = [[1,1,-1], > [-1,1,-1], > [-1,-1,-1], > [1,-1,-1], > [1,1,1], > [-1,1,1], > [-1,-1,1], > [1,-1,1]] > if Capped: > Faces = ((0,1,2,3), > (0,1,5,4), > (1,2,6,5), > (2,3,7,6), > (3,0,4,7), > (4,5,6,7)) > else: > Faces = ((0,1,2,3), > (0,1,5,4), > (1,2,6,5), > (2,3,7,6), > (3,0,4,7)) > Corners =  > for i in d: > V = [(i[j]*dim[j]+c[j]) for j in range(3)] > Corners.append(V) > Mesh = rs.AddMesh(Corners,Faces) > return Mesh
I then essentially loop over all building elements as below:
> Elements = [DrawCube(col) for col in columns]
I used a mesh rather than surfaces as I believed this would be faster, however not so sure anymore. Any advice greatly appreciated!
I’ve attached a vastly reduced version of the file which only deals with the rendering process if this will help.
Optimiser - Brief.gh (30.3 KB)