# Draw Rect Lines

## Recommended Posts

Hey,

I am trying to reproduce this kind of structure that we can see on this website : http://acme-experience.com/ (under the menu in the bottom left corner).

So far I manage to create polylines between points of a grid (pic. 2). But I think this is not the way to go for this effect. Because my polylines have always the same size and they don't seems to come from the center to the outer as much as in the example.

I am not so far though but if u have any idea on how I could improve it let me know I am stuck since a day on it...

And as always take care

drawRectLines.hip

##### Share on other sites

```node = hou.pwd()
geo = node.geometry()

# Create Variables.
iterations = node.parm("iterations").eval()
originx = float(node.parm("originx").eval())
originy = float(node.parm("originy").eval())
point1x = float(node.parm("point1x").eval())
point1y = float(node.parm("point1y").eval())
point2x = float(node.parm("point2x").eval())
point2y = float(node.parm("point2y").eval())

# Import math for the hilbert function
import sys, math

# Create the class that does the heavy lifting for the Hilbert Curve
class Hilbert:
# Recieve the variables from Hilbertclass
def __init__(self, x0, y0, xi, xj, yi, yj, n):
# Send variables to hilbert function for math to be done
self.hilbert(x0, y0, xi, xj, yi, yj, n)
def hilbert(self, x0, y0, xi, xj, yi, yj, n):
if n <= 0:
X = x0 + (xi + yi)/2
Y = y0 + (xj + yj)/2
point = [X, Y, 0]
# Send data to data, which whill pass it back to Hilbertclass
self.data(point)
else:
# The fancy math. Thank you Malcolm Kesson!
self.hilbert(x0,               y0,               yi/2, yj/2, xi/2, xj/2, n - 1)
self.hilbert(x0 + xi/2,        y0 + xj/2,        xi/2, xj/2, yi/2, yj/2, n - 1)
self.hilbert(x0 + xi/2 + yi/2, y0 + xj/2 + yj/2, xi/2, xj/2, yi/2, yj/2, n - 1)
self.hilbert(x0 + xi/2 + yi,   y0 + xj/2 + yj,  -yi/2,-yj/2,-xi/2,-xj/2, n - 1)
def data(self, point):
# Pass data back to Hilbertclass
pass

# This is the class that creates the points for the Hilbert Curve
class Hilbertclass(Hilbert):
def __init__(self, x0, y0, xi, xj, yi, yj, n):
# Give the input data to the base class
Hilbert.__init__(self, x0, y0, xi, xj, yi, yj, n)
def data(self, point):
# Create the point
curve = geo.createPoint()
# Set the position of the point
curve.setPosition(point)
# Add this newly set point to the polygon

# Create a Polygon to hold the vertex data
poly = geo.createPolygon()
# Set the polygon to be open so it acts like a line
polygon = poly.setIsClosed(False)
# Call Hilbertclass to begin all the procedures
Hilbertclass(originx,originy, point1x,point1y,point2x,point2y, iterations)```

plus you have L-system that you can have more fun

Edited by Librarian
##### Share on other sites

Or just use this and have endless fun...but you must warm up the chair to get desire effect ...but when you have at the end oj oj Hope it Helps

OdforceUI.hipnc

##### Share on other sites

This look really cool, however I have to say this is too advanced stuff for me. But I will surely try to dive deeper on it once in a while. Maybe I am just trying to do something too complicated for my current skills...

Thank you again for sharing this which look tremendous!

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×