Category Archives: 23-parametricobject

Amy Friedman

10 Feb 2015

Tweetable: “ProsthesianScan by @amy_friedmann customize your 3d prints biometrically”

1handScreen Shot 2015-02-10 at 3.50.22 AMAs stated in my ofxAddon project I aim to utilized the 3d scanned mesh/point cloud data from the Kinect to create customizable prosthetics. The mesh is imported into Rhino and called upon as the driving force for the customized object. With each new insert the object is transformed based on the mesh and randomized spherical sizing. I was going to trying to combine an exterior mesh and the interior 3d scanned mesh, but had trouble combining the two into a water-tight object. Currently the mesh is turned into a point cloud or a point cloud can be loaded and used to inform the shape. I will add more form additives, but I struggled with what way to go with the designs, and how to apply elements to a preexisting object or have the object subtract itself from the form. I want to push this further, this is only the beginning.

3

2

IMG_1802

import rhinoscriptsyntax as rs
import random

def drawObjects():
#get mesh to be used
objs = rs.GetObjects("Select mesh object", rs.filter.mesh, True)
if not objs: return

#offset mesh for better fitting
#offset = rs.GetInteger("offset mesh by",3,3,8)
#rs.MeshOffset( objs, offset)

vertices = rs.MeshVertices(objs)
if vertices:
pointcloud=rs.AddPointCloud(vertices)

points = rs.PointCloudPoints(pointcloud)
if points:
for point in points:
#print point
#for xn in range (0, points.length)
rad = random.randint(0,2)*.95
rad = rad*(.85)
x= point[0]
y=point[1]
z=point[2]
pt = (x,y,z)
sphere = rs.AddSphere(pt, rad)

rs.EnableRedraw(False)

drawObjects()

rs.Redraw()

Github Repository can be found here.

Epic Jefferson

10 Feb 2015

How to keep your favorite sound… forever. This rhinoPython script will make your sounds printable.

SoundCylinder_meh

 

[sketchfab id=”8637e796380b433d994b98991077c3f7″ start=”0″ spin=”” controls=”0″]

For a long time I’ve been interested in making sounds physical in some way, I suppose in a “more tangible” way since sound is already physical. I’ve always wondered what it takes to make one of these things and I’m eager to continue to explore.

Some sketches to get the thing going.

IMAG1632  IMAG1631

Problems – The library I used to process the soundfile (scipy) doesn’t run from rhinoPython, so the workaround was to run a separate script for audio analysis and write the results into a file, then read that file from rhinoPython script to apply those values along the shape’s Y axis. So that particular workflow sucks, but I guess this process doesn’t have to be optimized for now.

I got my audio processing base from http://samcarcagno.altervista.org/blog/basic-sound-processing-python/

#Analize Soundfile
from pylab import*
from scipy.io import wavfile

thickness = 160

sampFreq, snd = wavfile.read('440_sine.wav')
snd = abs((snd / (2.**15)*thickness))
s1 = snd[:,0]
levels = []
points = 40

step = 5060/40
avg = 0

for i in xrange(len(s1)/step):
avg = 0
begin = i * step
end = ((i + 1) * step - 1)
temp = s1[ begin : end]

for j in xrange(len(temp)):
avg += temp[j]
avg = avg/len(temp)
levels.append(avg)

file = open("sample.txt", "w")
for i in xrange(len(levels)):
file.write(str(levels[i]))
file.write('\n')
file.close()
#Create Cylinder
import rhinoscriptsyntax as rs
import random

pointList = []
ypointList = []

temp = open("sample.txt", "r")
for line in temp:
ypointList.append(line)
temp.close()

for i in range(40):
Y = ypointList[i]
pt = (i, Y, 0)

pointList.append(pt)

curve = rs.AddPolyline(pointList)
rs.AddRevSrf( curve, ((0,0,0), (40,0,0)))

 

John Choi

10 Feb 2015

Generative Tanks by John Choi is a series of parametric tanks created with Rhino and Python.

So I began this project with no idea what to do, and then suddenly I wanted to build a series of parametrized tanks.  I initially thought this was a great idea, but then Golan asked me, “Why tanks?”  To be completely honest, I had no idea how to respond to that question.  But this really struck a chord in my thinking.  While I didn’t change the theme of my project, I couldn’t help but keep thinking about it.  Indeed, why tanks?  

For me, it was a natural choice.  Ever since I made a report on World War II during the fifth grade as a history assignment, I’ve been enamored by the topic, particularly on the evolution of military vehicles.  Now, I know pretty much every major tank, plane and battleship used during the war.  But even so, there seems to be something more to this, something deeper within the human psyche that gets awed by the idea of giant, powerful war machines.  Personally, I think it’s the same reason why many young boys have certain affinities for things that are destructive and terrifying, like Tyrannosaurs, fighter jets and missiles.  In any case, I think my project went pretty well.  We can get pretty standard looking tanks here, and also triple barreled monstrosities with puny chassis.  In terms of scripting, some things were pretty annoying with Rhino Python, since I had assumed every included Rhino command was also a Rhino Python command, which was not the case as I had to do some interesting workarounds.  In the end, I still made it through, along with series of tanks ranging form realistic to cartoonish.

Here are some renderings:

Tank 1
tank1

Tank 3
tank3

Tank 8
tank8

Here are some 3D tanks with SketchFab:

Tank 6

Tank 7

Here is a concept sketch:
sketch

Here is the Rhino Python code:

import rhinoscriptsyntax as rs
import random

#helper to get and assign parts
def makePart(name,group):
    obj = rs.ObjectsByName(name)[0]
    group.append(obj)
    return obj

# turret parts:
turretParts = []
turretPoint = makePart("turretPoint",turretParts)
turretPivot = makePart("turretPivot",turretParts)
barrelPivot = makePart("barrelPivot",turretParts)
barrelStart = makePart("barrelStart",turretParts)
turretHull = makePart("turretHull",turretParts)
topHatch = makePart("topHatch",turretParts)
barrel = makePart("barrel",turretParts)
# hull parts:
hullParts = []
sidePort = makePart("sidePort",hullParts)
hull = makePart("hull",hullParts)
# track parts:
trackParts = []
trackPiece = makePart("trackPiece",trackParts)
trackFront = makePart("trackFront",trackParts)
trackBack = makePart("trackBack",trackParts)
trackMid = makePart("trackMid",trackParts)
sprocketFrontParts = []
sprocketBackParts = []
#Sprocket Parts:
spf = []
for i in range(0,5):
    spf.append(makePart("spf"+str(i),sprocketFrontParts))
sprocketFront = makePart("sprocketFront",sprocketFrontParts)
sprocketFrontPoint = makePart("sprocketFrontPoint",sprocketFrontParts)
spb = []
for i in range(0,5):
    spb.append(makePart("spb"+str(i),sprocketBackParts))
sprocketBack = makePart("sprocketBack",sprocketBackParts)
sprocketBackPoint = makePart("sprocketBackPoint",sprocketBackParts)
#Wheel Parts
wheel = makePart("wheel",trackParts)
wheelPoint = makePart("wheelPoint",trackParts)

#randomize?
randomize = 1

#turret variables:
barrelLength = 20.0 + random.uniform(-8,8)*randomize
barrelScale = 1.0 + random.uniform(-.5,1)*randomize
barrelCount = 1 + random.randrange(0,3)*randomize
turretScale = 1.0 + random.uniform(-.2,.5)*randomize
#hull variables:
hullHeight = 10.0 + random.uniform(-4,6)*randomize
hullWidth = 20.0 + random.uniform(-8,8)*randomize
hullLength = 36.0 + random.uniform(-12,12)*randomize
portsPerSide = 1 + random.randrange(0,4)*randomize
#track variables:
wheelCount = 5 + random.randrange(-1,5)
wheelSprocketDistance = 8.0 + random.uniform(-4,4)*randomize
wheelScale = 1.0 + random.uniform(-.5,1)*randomize
sprocketScale = 1.0 + random.uniform(-.5,1)*randomize
suspension = 4.0 + random.uniform(-2,3)*randomize
trackHeight = 1.0 + random.uniform(-.4,.6)*randomize
trackLength = 2.0 + random.uniform(-.8,.8)*randomize
trackOffset = random.uniform(0,trackLength)*randomize
trackCount = 50 + random.randrange(-10,20)*randomize
#color variables
r = random.randrange(0,160)
g = random.randrange(0,160)
b = random.randrange(0,160)
hullColor1 = [r,g,b]
hullColor2 = [r*4/5,g*4/5,b*4/5]
hullColor3 = [r*3/5,g*3/5,b*3/5]
r1 = random.randrange(0,60)
g1 = random.randrange(0,60)
b1 = random.randrange(0,60)
wheelColor = [r1,g1,b1]
trackColor = [r1/2,g1/2,b1/2]

#print variables?
printvars = True
if (printvars):
    #turret variables
    print "barrelLength = "+str(barrelLength)
    print "barrelScale = "+str(barrelScale)
    print "barrelCount = "+str(barrelCount)
    print "turretScale = "+str(turretScale)
    #hull variables
    print "hullHeight = "+str(hullHeight)
    print "hullWidth = "+str(hullWidth)
    print "hullLength = "+str(hullLength)
    print "portsPerSide = "+str(portsPerSide)
    #track variables
    print "wheelCount = "+str(wheelCount)
    print "wheelSprocketDistance = "+str(wheelSprocketDistance)
    print "wheelScale = "+str(wheelScale)
    print "sprocketScale = "+str(sprocketScale)
    print "suspension = "+str(suspension)
    print "trackHeight = "+str(trackHeight) 
    print "trackLength = "+str(trackLength)
    print "trackOffset = "+str(trackOffset)
    print "trackCount = "+str(trackCount)
    #color variables
    print "(r,g,b) = "+str(r)+", "+str(g)+", "+str(b)
    print "(r1,g1,b1) = "+str(r1)+", "+str(g1)+", "+str(b1)

# --- color objects --- #
#hullColor1
for part in turretParts:
    rs.ObjectColor(part,hullColor1)
for part in hullParts:
    rs.ObjectColor(part,hullColor1)
#hullColor2
rs.ObjectColor(turretPivot,hullColor2)
rs.ObjectColor(barrelPivot,hullColor2)
#hullColor3
for part in trackParts:
    rs.ObjectColor(part,hullColor3)
#wheelColor
rs.ObjectColor(sprocketFront,wheelColor)
rs.ObjectColor(sprocketBack,wheelColor)
rs.ObjectColor(wheel,wheelColor)
#trackColor
rs.ObjectColor(trackPiece,trackColor)


# --- control hull --- #
#resize hull (hullLength,hullWidth,hullHeight)
(x,y,z) = [hullLength/36.0,hullWidth/20.0,hullHeight/10.0]
rs.ScaleObject(hullParts,(0,0,0),[x,y,z])
rs.ScaleObject(trackFront,(0,0,0),[x,1,z])
rs.ScaleObject(trackBack,(0,0,0),[x,1,z])
rs.ScaleObject(trackMid,(0,0,0),[x,1,z])
#move track parts to accommodate
rs.MoveObject(trackParts,[0,hullWidth/2.0-10.0,0])
rs.MoveObject(sprocketFrontParts,[0,hullWidth/2.0-10.0,0])
rs.MoveObject(sprocketBackParts,[0,hullWidth/2.0-10.0,0])
#move turret parts to accommodate
rs.MoveObject(turretParts,[0,0,hullHeight-10.0])
#move sprockets to accomodate
rs.MoveObject(sprocketFrontParts,[hullLength/2.0-18.0,0,0])
rs.MoveObject(sprocketBackParts,[-hullLength/2.0+18.0,0,0])
#make ports
if(portsPerSide > 1):
    rs.MoveObject(sidePort,[hullLength*.3,0,0])
    for i in range(1,portsPerSide):
        distance = (hullLength*.6)/(portsPerSide-1)*(-i) 
        rs.CopyObjects(sidePort,[distance,0,0]) 

# --- CONTROL WHEELS --- #
#scale wheels (wheelScale, sprocketScale)
rs.ScaleObject(sprocketFrontParts,sprocketFrontPoint,[sprocketScale,1,sprocketScale])
rs.ScaleObject(sprocketBackParts,sprocketBackPoint,[sprocketScale,1,sprocketScale])
rs.ScaleObject(wheel,wheelPoint,[wheelScale,1,wheelScale])

#move wheels down (suspension)
rs.MoveObject([wheel,wheelPoint],[0,0,-suspension])

#create wheels and curve(wheelCount, wheelSprocketDistance)
trackPoints = []
trackPoints.extend(spf)
sx = hullLength/2.0-wheelSprocketDistance
sy = hullWidth/2.0+2.5
sz = -wheelScale*2.5-suspension
trackPoints.append([sx+wheelSprocketDistance/4.0,sy,sz])
rs.MoveObject([wheel,wheelPoint],[hullLength/2.0-wheelSprocketDistance,0,0])
for i in range(1,wheelCount):
    distance = (hullLength-2.0*wheelSprocketDistance)/(wheelCount-1)*(-i)
    rs.CopyObjects([wheel,wheelPoint],[distance,0,0])
    trackPoints.append([sx + distance,sy,sz]) 
trackPoints.append([-sx-wheelSprocketDistance/4.0,sy,sz])
trackPoints.extend(spb)
trackPoints.append(spf[0])
trackCurve = rs.AddCurve(trackPoints)

# --- control turret --- #
#scale turret
rs.ScaleObject(turretParts,turretPoint,[turretScale,turretScale,turretScale])

#barrel (barrelLength, barrelCount)
rs.ScaleObject(barrel, barrelStart, [barrelLength/20.0,barrelScale,barrelScale])

#make barrels (barrelCount)
if(barrelCount > 1):
    rs.MoveObject(barrel,[0,4,0])
    for i in range(1,barrelCount):
        distance = (8)/(barrelCount-1)*(-i) 
        rs.CopyObjects(barrel,[0,distance,0]) 


#create track pieces (trackCount, trackHeight, trackLength)
rs.ScaleObject(trackPiece,(0,hullWidth/2.0,0), [trackLength,1,trackHeight])
rs.MoveObject(trackPiece,[trackOffset,0,sprocketScale*2.5])

#these commands are not in Rhino Python.
rs.Command("ArrayCrv") # make track along curve.
rs.Command("RunScript") # Set Material Render Colors.
rs.Command("Mirror") # mirror features.

And finally, a 3D printed tank!
3dPrintedTank

rlciavar

10 Feb 2015

My parametric object was inspired by a bike mounted air planter my co-worker made to keep me company during my commute. http://www.instructables.com/id/3D-Printed-Bike-Planter/. Since then my air plant got stolen off my bike and my commutes have been quite lonely. (though I’m not sure the plant would have lasted through a Pittsburgh winter). I decided my bike needed a new friend and I designed a program in openSCAD to generate bike head tube ornaments featuring .stl files of your choice.

You can customize the head tube diameter to match your bike’s dimensions, scale the mount, scale the zip-tie holes and load your own stl file to mash-up. My bike head tube has a diameter of 1.5″. I decided to start with a unicorn, dinosaur, and mermaid for when I’m feeling nautical.

dino_bike mermaid_bike unicorn_bike

Here’s my code:

module example004()

{

tubeDiameter = 1.5;

height = 2.5;

depth = 1.25;

width = tubeDiameter+.75;

zipHeight=.3;

zipDepth=.15;

zipLength=width+1;

difference() {

translate([-depth/2,-width/2,-height/2]){

cube([depth,width,height]);}

translate([depth/2,0,-height/2-.5]){

cylinder (h = height+1, r=.75,$fn=100);}

translate([0,-width/2-.5,0]){

cube([zipDepth,zipLength,zipHeight]);}

}

union()

{

translate([-depth-.75,0,.5])scale([.2,.2,.2])rotate([0,0,-90])import("/Users/sebrandwarren 1/Documents/OpenSCAD/libraries/Unicorn_Head.stl");

}

}

example004();

 

ypag

10 Feb 2015

Twitter Text: Using growth algorithms to create insect wings.

My inspiration comes from insect wings.
Wing-insect

The veins form a peculiar pattern. I was initially lost to understand how to create these patterns. One idea was to hardcode the 8 main veins of a wing and then divide these veins further in lines with reduced lengths. That would’t have been parametric and also the next segment could be at any angle.
This is when I came across about L system in python. I tried to get the L system package work with Rhinopython, but it did not work out. Further, I came across growth functions on this site, which turned out to be a great resource for learning rhinopython. I have borrowed DLA algorithm from this site.

I have created multiple wing like patterns, which grow on a base surface so that it can be printable.

pattern
This one looks like a leaf.

pattern1

pattern2
Face of an insect- do you see two eyes and mouth?

This page by nervous system was very helpful in understanding what Diffused Aggregation Functions (DLA) are and how to write one. I understood the concept of seeds (Thanks to Madeline here) to create better growth patterns. To create above patterns I have changed the array of points and not used any advanced seed methods.

My files is 148 MB, which is way larger than sketchfab
‘s 50 MB upload limit. Hence can not provide a 3D link here.
Render of the last pattern I created:

Screen Shot 2015-02-10 at 1.04.01 AM

wings2

Code is here:

 
import rhinoscriptsyntax as rs
import random
 
def placePt(x_range,y_range,z_range):
    x = random.randrange(0,x_range,2)
    y = random.randrange(0,y_range,2S)
    z = random.randrange(0,y_range,2)
    pt = [x,y,z]
    return pt
 
rs.EnableRedraw(False)
 
ptZero = [100,250,50]
pts = []
pts.append(ptZero)
#circleZero = rs.AddCircle(ptZero,0.5)
sphereZero = rs.AddSphere(ptZero, 0.4)
 
 
 
for i in range(0,400):
    pt = rs.AddPoint(placePt(100,100,100))
    index = rs.PointArrayClosestPoint(pts,pt)
    cp = pts[index]
    vect = rs.VectorCreate(cp,pt)
    unitVect = rs.VectorUnitize(vect)
    subVect = vect - unitVect
    newPt = rs.MoveObject(pt,subVect)
    #rs.AddCircle(newPt,0.5)
    rs.AddSphere(newPt,0.5)
    pts.append(newPt)
 
rs.Redraw()