Tag:

I’ve uploaded a new version of my unlekkerLib library. For some inexplicable reason version 0002 was missing some classes that were needed for certain examples to function. As a result the TileSaver class was broken, which was a serious omission.

You can download unlekkerLib-0003 from the Code & Form Google Code repository. I’ve added the missing classes, but otherwise the library is the same. If you still experience problems please report them here.

No Comments »

I just got an email from Casey saying that processinghacks.com has finally officially been integrated into the main Processing web site. The new URL is http://processing.org/hacks/. Processinghacks was a great initiative by Toxi and Tom Carden, but has ended up in an inactive limbo over the years. Wikis are perfect for letting users contribute their own content, but they also requires a dedicated community to work properly. Sadly, that never quite happened.

Hopefully, the integration into processing.org will provide a little extra motivation for would-be contributors to step up to the plate. There are already links to empty pages indicating topics that should be filled, giving some useful starting points. I know there are some things in unlekkerLib that would fit, but I’ll have to see when I have the time to write them up.

In any case, congratulations to the Processing team for adding a new feature, and thanks to Toxi and Tom Carden for having the Processing hacks idea in the first place…

No Comments »

As you might have noticed I’ve replaced the code formatting plugin that I use on the blog. I had trouble with the Geshi-based plugin I used before, so I replaced it with Alex Gorbatchev’s SyntaxHighlighter. This produces lovely formatting and works well - mostly.

SyntaxHighlighter hiccups when encountering the < character unless there is a blank space directly following it, most likely due to it being interpreted as the start of a HTML tag. Also, the "copy to clipboard function produces incorrect code because the text copied has < and > characters converted into the HTML entities &lt; and &gt;. However, I’m not sure if this is a problem with SyntaxHighlighter or with WordPress, since WordPress sometimes messes with formatting by automagically trying to provide good HTML substitutes for certain character combinations.

Most frustrating of all, WordPress has started replacing the ’s in “it’s” with a triple ellipsis character, as well as some other strangeness. Any tips for fool-proof plugins for posting properly formatted code would be most appreciated!

No Comments »

The following Processing example shows how to set up a separate thread for loading images into a sketch. I wrote it up in response to this post on the Processing forums, figuring it will be useful to some of my students too.

Code: ThreadImageLoader.pde

Read the rest of this entry »

5 Comments »

Turns out Java has no mechanism for discovering the names of disk volumes. You can use java.io.File.listRoots() to get the root paths for multiple disks, but you can’t auto-discover their names.

Here’s a quick hack that will work on Windows. It uses Runtime.getRuntime().exec() to run “cmd /c dir “, the output of which is parsed to get the volume name.

import java.io.*; 

void setup() {
  println("Testing getVolName");

  String path="D:";
  println("Volume name for "+path+" is: "+
    "'"+getDiskVolumeName(path)+"'");
}

public static String getDiskVolumeName(String path) {
  String volname="Unknown";
  String check="Volume in drive "+path.charAt(0)+" is ";
  try  {
    Process p=Runtime.getRuntime().exec("cmd /c dir "+path);
    //p.waitFor(); 

    BufferedReader reader=new BufferedReader(
      new InputStreamReader(p.getInputStream()));
    String line=reader.readLine();
    while(line!=null) {
      if(line.indexOf(check)!=-1)
        volname=line.substring(line.indexOf(check)+check.length());

//      System.out.println(line);
      line=reader.readLine();
    }
  }
  catch(Exception e1) {
    println("Failure: "+e1.toString());
  }
  return volname;
}

No Comments »

Danzer tiling

MIT IAP RhinoScript workshop - Danzer Variations

While looking for RhinoScript resources for the Digital Architecture workshop at AHO I found a recent posting of the final projects from a RhinoScript workshop at MIT IAP. It features some very nice-looking work, including the Danzer tile forms shown above. It also provides the source code for most of the experiments, well worth checking out.

The resource page for a previous MIT workshop is still up, it has more scripts and some useful links: Computational Design Solutions Part 1.

No Comments »

I am teaching a 3-day workshop in Digital Architecture at the Oslo School of Architecture & Design (AHO) this week, as part of a course by Søren Sørensen. The workshop will give an introduction to Processing, with a focus on synthesis of spatial form. If time permits we’ll also look briefly at Rhinoscript.

Be sure to look at the page I have prepared with links related to computational architecture. Code will be uploaded to:
http://workshop.evolutionzone.com/workshops/080211_aho.

Workshop contents
  • Basic Processing syntax
  • Simple animation
  • Control structures: If / else, loops, keyPressed(), mousePressed()
  • Transformations: translate(), scale(), rotate()
  • Complex drawing: beginShape(), endShape()
  • Data structures: Arrays, classes
  • Polygon mesh generation
  • Output: PDF, STL, DXF
Possible advanced topics

No Comments »

080205_rhinoscript.jpg

Rhinoscript sketch, extruding a revolution surface along random curves. Good cheesy fun.

I had a chance to see a bit more of the impressive tool Rhino 4 during the Generator.x 2.0 workshop, and so I thought I’d have a go at making a simple sketch in Rhinoscript. As it turns out, the fact that Rhinoscript is based on VBScript makes coding feel horrible at first. Seriously, who would want to use syntax like that? It might be easy for beginners to pick up, but it quickly gets painful once you’re dealing with complex API calls and 100+ lines of code.

Nevertheless, frustration soon gives way to amazement at the built-in Rhino library and its vast array of heavy-duty functions for creating and manipulating curves, meshes and NURBS surfaces. In comparison, mesh generation in Processing is enough to give anyone a headache, and I seriously doubt anyone would even attempt to implement NURBS. Even Boolean mesh operations is a staggering task, with no good Java libraries readily available.

While Rhinoscript is firmly a non-realtime tool, its power for pure geometry is amazing. I would definitely use Rhino as a creative tool for digital fabrication projects, where animation is not the goal. There are some excellent RhinoScript resources online, for starters look at RhinoScript 101 and David Rutten’s tutorial. I would also definitely recommend using the Monkey Script editor instead of the built-in editor, it’s more powerful and has a very useful documentation feature.

The script below gives a basic idea of the Rhino syntax, and while it is a basic sketch suffering from 3D clichées, it shows the power and versatility of Rhinoscript. I just wish it wasn’t Visual Basic.

Code: RandRail.rvb

Read the rest of this entry »

6 Comments »

Sample code to use mouse wheel events in Processing.

Read the rest of this entry »

1 Comment »

Here is a simple example showing how to use unlekkerLib to output and input 3D geometry in STL format.

// STLBoxes.pde - demonstrates how to use unlekkerLib to
// import / export STL geometry data.
//
// Marius Watz - http://workshop.evolutionzone.com/

import unlekker.data.*;

STL stl;

public void setup() {
  size(400,400, P3D);
  frameRate(25);
  sphereDetail(12);
}

public void draw() {
  translate(width/2,height/2);

  if(frameCount==10) outputSTL();
  else if(frameCount==11) readSTL();
  if(frameCount<12) return;

  background(0);
  noStroke();
  lights();
  rotateY(radians(frameCount));
  rotateX(radians(frameCount*0.25f));
  fill(0,200,255, 128);
  stl.draw();

}

public void readSTL() {
  stl=new STL(this,"Boxes.stl");
  stl.normalize(400); // scale object
  stl.center(); // center it around world origin
}

public void outputSTL() {
  float rad;

  stl=(STL)beginRaw("unlekker.data.STL","Boxes.stl");
  for(int i=0; i<200; i++) {
    pushMatrix();
    translate(random(-200,200),0,-random(400));
    rotateX(((float)(int)random(6))*radians(30));
    rotateY(((float)(int)random(6))*radians(30));

    rad=random(5,25);
    if(random(100)>5) box(rad,random(50,200),rad);
    else sphere(rad);
    popMatrix();
  }
  endRaw();
}

8 Comments »