Brick Pattern help

I trying to create a bring pattern on a dynamic surface and split the surface with smaller surfaces with four points each to place a adaptive component on each surface.I am stuck in creating the pattern on the surface, any help is really appreciated.

Here is where I am currently ( trying to do it on a flat surface first)

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN

# Place your code below this line
surface = IN[0]

u = IN[1]
v = IN[2]
# Assign your output to the OUT variable.

PointSet = []


for i in u:
	Points = []
	for j in v:
		index = v.IndexOf(j)
		if u.IndexOf(j) % 2 != 0:
				Points.append(Surface.PointAtParameter(surface,i,j-v[index-1]/2+v[index-1]/2))
				
		else:
			Points.append(Surface.PointAtParameter(surface,i,j))
		
	PointSet.append(Points)
OUT = PointSet

I am trying to create something similar to this:
image

Let’s consider the UV values as a list to start with.

uSet = u0, u1, u2, u3… uN
vSet = v0, v1, v2, v3… vN

Next’s let’s consider a single brick, starting at u0,v0 because why not.

Looking at that first brick, the first UV is u0-v0. Moving clockwise the next is v1-u0. Next is u2-v1. Then finally u2-v0.

Looking at the next brick, we have u2-v0, u2-v1, u4-v1, u4-v0.

Then u4-v0 u4-v1 u6-v1 u6-v0.

Notice the pattern? The U value always steps by two, and the V increments by one.

Ok moving up a row to the half offset bricks…
u0-v1, u-0,v2, u1-v2, u1-v1.
u1-v1, u1-v2, u3-v2, u3-v1.
u3-v1, u3-v2, u5-v2, u5-v1

Other than the first brick where we have a single step, the U always offsets by 2.

Going to the third row we repeat the first set of U values, but omit add two to the first set of V values. Same with the fourth row adding to the 3rd.

So we have to build a pattern of u and v values as a start, then increment each. Start with the U set first as the V set is quite easy.

Building the U sets feels complex at first, but is pretty easy with Python’s slicing capability.

uSet1 = uValues[::2] #take every other item in the list
uSet2 = [u+1 for u in uSet1] #add one to each value in the initial uSet to force the offset.

from there you need to ensure that the first and last value in each U set is always u0 and uN, as we want to ensure those values are present. You can do an if statement, but since we only have two lists I would just merge the lists and take the set in Python (the Dynamo equivalent of List.Join and List.Unique items).

uSet1 = set([u0]+uSet1+[uN]) #this may require forcing a list format in some cases. Add list() around the expression if you get stuck.
uSet2 = set([u0]+uSet2+[uN])

Now that we have the U values - might as well force them into one list to make them easier to call.
uSets = [uSet1,uSet2]

vSets are much easier. The first is always the iteration, and the second is one more than that, so we can start our looping.

for i in range(len(vValues)-1):
    v1 = vValues[i]
    v2 = vValies[i+1]
    uSet = uSets[i%2]
    for j in range(len(uSet)-1):
         uvVals = [uSet[j]-v1, uSet[j]-v2, uSet[j+1]-v2, uSet[j+1]-v1]

Now none of this is real code, but hopefully it helps you get started on how you could map the UV values to UV sets which you can use to build points. I recommend starting with a set of 5 rows with 5 bricks per row to keep the values as some thing you can verify manually.

1 Like