Scene optimizer for 3ds Max

Scene optimizer is a simple and easy to use maxscript plugin that utilizes the ProOptimizer feature of 3ds Max to reduce the geometrical complexity of selected items based on their distance from a specified camera (or any other object for that matter). Scene optimizer can be used in a number of scenarios, but it’s particularly useful in optimizing trees and other scene elements in an architectural visualization project.

Download Scene optimizer:

Click here to download Scene optimizer


How to use:


At times its rather difficult to determine the distance of objects in 3ds Max, for that you can use our Distance finder script:

Click here to download Distance finder

Installing and using maxscript macros is extremely simple and straight forward (just as easy as dragging and dropping the maxscript into 3ds max). I hope that this blog post will be of some help to you, enjoy the rest of your day 😉 .

Scale Calculator for architectural drawings

Hello and welcome to this blog post. As an architect it’s always been a challenge to quickly and easily determine the scale of a CAD drawing or to change it to a new one. thus I have programmed a little application called Scale Calculator which addresses that very problem. It’s not extremely polished but I’ve decided to share it with you guys here, hoping that it will help you in your day to day life working with technical drawings of various scales.

Edit: Scale calculator is now a web application, start running it right in your browser. click here.

Click here to download the application.

How to use the application:

Scale Calculator is extremely easy and self explanatory to use, all you really need to do is to download the installer from the link above and go through the simple installation process. once that’s done, a new icon should appear on your desktop with the name Scale Calculator. Once you open that up, you’re greeted with a super simple user interface. The application has two major functionalities:

  • Scale Finder: this functionality asks for a dimension from the drawing and it’s real-world value to find the scale of the drawing (units are irrelevant as long as the same unit is used for both inputs, e.g. in a 1:100 drawing, a 1m wide door measures exactly 1cm. So the user needs to input something like this: drawing dimension = 0.01 and real dimension = 1).
  • Scale Converter: this functionality asks the user to input the current and the desired scale in n:n format (1:100 or 1:25) and it calculates the factor by which the drawing should be enlarged or reduced (simply multiply the drawing by the given factor inside of AutoCad or a similar drafting application).

It’s true that most of the time we tend to use a small number of scales in our day to day lives and it’s very easy to convert them on the fly, but every now and then we might come across an irregular scale factor, this is when this tool might come in handy. Anyways I hope this post delivers some value to you and have an amazing day!

Organic elevation design from image file using dynamo and Revit

In the previous blog post, we touched upon an interesting idea by creating a parametric facade generator that had the ability to analyse an Image file and then convert it’s pixel data into a usable form. which would later be used to determine the overall look of an architectural facade. in that project we used a non-destructive approach. this means that once the code is written, the user can run the program indefinitely, as many times as they wish with a number of different image files to achieve different results. this is useful when slow and gradual fine tuning of the original design is desirable. if you haven’t read that blog post yet, I highly recommend checking it out by clicking here.

But today, we’re going to be working on a whole different project. in this blog post, I’ll walk you through the process of creating an automated Dynamo Graph that would generate a parametric facade element from a given image file. in other words the designer would “model” this parametric three dimensional form in a two dimensional photo editing environment such as Adobe Photoshop or a similar application, and then use this workflow to transform the flat image into 3d. and finally import the geometry right into Revit for visualization and further documentation. The process consists of four separate steps, and since we’re going to generate our geometry from an image file, naturally the first step is to select, analyze and prepare our bitmap related information. then we can use our newly acquired pixel data to generate an array of points that will later be used to create the final form. so with all that out of the way, lets get coding already!

Although the same results can be achieved with traditional modeling techniques, but the main advantage of using Dynamo is the fact that, once the code is written, generating different results is super fast and extremely efficient.

Step 1: data extraction

This stage includes defining a fixed number of samples that we’re going to extract from our bitmap, it ensures that the code can run smoothly on high definition image files since it eliminates the need to loop and iterate through each and every pixel. here we also implement a mechanism that allows our code to programmatically detect the aspect ratio of the image file and assign a suitable number of samples in both X and Y directions.

High definition image available here
  1. Select image file path.
  2. Read from file and display a preview (optional).
  3. Acquire image width and height using Image.Dimensions.
  4. Input node for the max amount of samples. (100 in this case).
  5. boolean code block (W >= H) reports whether the image is portrait or landscape.
  6. Python script: assign smaller number of samples to the shorter side of the image file.
  1. If” code block: assign max samples to the longer side of the image file.
  2. Image.Pixel: extract the pixels based on the given number of samples.
  3. we want pixel columns as opposed to rows therefore we transpose the list.
  4. using Color.Brightness to get the brightness value of each pixel.

here is the python script used in the graph above (we could’ve just used another If node and just alternate the “true” and “false” input slots).

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

check = IN[0]
#simple if statement 
if check == True:
    OUT = IN[1]
else: OUT = IN[2]

Step 2: generating array of points

In this step we’ll generate an array of geometrical dynamo points using Point.ByCoordinates node, but to do that we’ll need X,Y and Z coordinates of each point (we’ll acquire those from the pixel data we generated in the previous step with the help of a few Python nodes). lastly we’ll use an additional piece of Python code to add two more points to each sub-list of points. one in the beginning and one in the end of each column to close the loop (note that these additional points are always located of the XY plane, in other words they always have a Z coordinate of zero).

  1. Three Python code snippets, one for generating each coordinate for it’s respective point.
  2. mapping the z values to a user defined range ( this will allow the user to control the height of the geometry).
  3. using Point.ByCoordinate to generate the list of points.
  4. additional Python Code to add the remaining points needed to for a closed loop.

Here is all the Python code that was used:

#Pythone code X
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

zdepth = IN[0]
filteredX = [[] for i in range(len(zdepth))]
columnNumber = 0


for column in zdepth:
	for z in column:		
		filteredX[columnNumber].append(columnNumber)
	columnNumber += 1

OUT = filteredX
#Python code Y
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

zdepth = IN[0]
filteredY = [[] for i in range(len(zdepth))]
columnNumber = 0


for column in zdepth:
	zIndex = 0
	for z in column:		
		filteredY[columnNumber].append(zIndex)
		zIndex += 1
	columnNumber += 1

OUT = filteredY
#Python code Z
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

zdepth = IN[0]
filteredZ = [[] for i in range(len(zdepth))]
columnNumber = 0


for column in zdepth:	
	for z in column:				
		filteredZ[columnNumber].append(z)	
	columnNumber += 1

OUT = filteredZ
# Python code Additional Points
# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

lists = IN[0]

for pts in lists:
	if pts[0].Z != 0:
		pointS = Point.ByCoordinates(pts[0].X,pts[0].Y,0)
		pts.insert(0,pointS)
	if pts[-1].Z != 0:
		pointE = Point.ByCoordinates(pts[-1].X,pts[-1].Y,0)
		pts.insert(len(pts),pointE)
OUT = lists

Step 3: generating solid geometry

Now that we have the much needed list of points, the rest is just a matter of generating the relevant kinds of geometry, this is a rather painless process thanks to the amazing geometry generation tools offered by Dynamo.

  1. Generating curves that run trough each of our point sub-lists.
  2. joining the curves into PolyCurves.
  3. closing the curve loop using PolyCurve.CloseWithLine.
  4. Generating surfaces from the curve loops.
  5. turning the surfaces into solid Geometry using Surface.Thicken.

Step 4: exporting to Revit

Now all that’s left is to export the geometry back to Revit. there are many approaches to do so, in a real world project you might wanna import the geometry in the form of a family, but in this demonstration I’ll use a simple ImportInstance.ByGeometries node for the sake of simplicity.

  1. Removing potential problematic instances using Manage.RemoveNulls, this is a protective measure against importing errors down the line.
  2. Importing the geometry into Revit using ImportInstance.ByGeometries.

And… we’re done! bellow are some examples designed using this very graph that we just wrote together, this was a rather long blog post but I personally had a ton of fun creating it. thank you so much for your time and I really hope that this tutorial was of some value to you. take care and keep creating!

Parametric facade design from Image file using Revit and dynamo

In this blog post we’re going to use some fundamental Revit and Dynamo skills as well as a builtin Dynamo image processing library to create a workflow that converts an ordinary image into an amazing architectural facade in a matter of minuets (or even seconds depending on your hardware). we’re going to be using curtain walls and custom parametric curtain panels to model this. thus naturally creating the curtain panel family is the first step. after that we’ll learn how to use an image processing library inside of dynamo in order to extract all kinds of useful data from the image file. and last but not least, we’ll use that extracted pixel information to parametrically alter the facade in cool and interesting ways. so without further ado lets get started!

So the first step is to create the parametric curtain panel, the design and geometry for this element are rather simple since we will be placing thousands of these and we really don’t want to push our hardware too far (geometrical detail in the individual family instances is not that important anyways since each instance of this family represents a single pixel which together they create the final impression collectively).

So we’ll start by creating a new family, we will use the template “Metric Curtain Wall Panel”. now we’re good to go… open the exterior view and start by changing the distance between the reference lines (we want to have a 500mm x 500mm panel). once that is done create an extrusion. while in sketch mode, create a rectangular shape and constrain it to the existing reference lines as shown in the image bellow. then draw another rectangle within the first rectangle. we need to constrain this one using an instance parameter. add dimensions to the second rectangle as shown in the second image below, and associate those dimensions with an instance parameter. lets call this parameter “width” for now. once those steps are done, click create form. it’s a good idea to keep the extrusion end at around 100mm.

Constraining the first rectangle to the reference lines…
Constraining the inner rectangle with an instance parameter (width)…

You could also try and create another 20mm extrusion and constrain it to the inner rectangle to represent the glass but we’ll keep things simple for this demonstration. create a new architectural project and import the new family into it and we’re good to go. now that the custom panel family is complete we can move on to the next step and work on our curtain panel. for this demonstration we’ll be using a 50m x 50m curtain wall with 0.5m x 0.5m panels, effectively giving us 10,000 panels (pardon the unrealistic dimensions, this is for educational purposes only). after selecting our custom panel family as our curtain wall panels, we can move on to dynamo.


An image processing library will allow us to manipulate image files and extract valuable data from them. luckily for us, Dynamo happens to be very flexible in this regard, since it allows us to easily import .Net framework libraries and tools, we can even write custom nodes for Dynamo that use external C# libraries using Zero touch (more on this topic soon). but for the purposes of this tutorial we can use a builtin Dynamo node to extract the pixel data as shown in the graph bellow.

Extracting data from selected Image file (note that the image is 100 x 100 pixels) Click Here for high resolution.
  1. Get the file path to the image file
  2. Get file from file path
  3. Read image from file
  4. Get pixel data from image
  1. Get brightness of each pixel
  2. Map the values to our panel’s “width” min and max (0.02 and 0.24 in this case).
  3. Reverse the list

The graph above should be simple enough, I trust that you can easily follow through with it. now that we have extracted pixel brightness values and stored them in a 2 dimensional list (100 lists each containing 100 pixels), we’re ready to move on to the final stage of assigning those values to the relevant panels. selecting all the panels is easy enough but we need some simple list manipulation to get the lists of panels correspond to our data from the image. the following graph does just that.

Selecting and sorting all the panels in this project (Click Here for high resolution)
  1. Selecting the panel family type
  2. Getting all instances of the family type (10,000)
  3. Get the bounding box
  4. Get it’s centroid
  1. Python code: getting the Z coordinate
  2. Using “GetItemAtIndex” and “Chop” nodes in conjunction with the Z and X coordinates to sort the panels.

The python code block simply loops through the list of points to get their Z coordinates. of course just like the X coordinate, Z coordinate could also be obtained easily using a builtin dynamo node, but I thought that this was a good opportunity to demonstrate the freedom that the python code block offers us. so using it is completely optional, here’s the code:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

#creating variables to store the lists of points
pts = IN[0]
z = []

#looping through the list of points and getting their Z component
for pt in pts:
    z.append(pt.Z)

#outputing a list of Z components 
OUT = z

Now all that is left is to assign the values to the panels using a “SetParameterByName” node:


Hit run in dynamo and…. voilà! the facade is complete! I really hope that this tutorial was somewhat useful and that you have enjoyed reading this blog post. keep creating and don’t forget to give something back to the universe!

Done!

The image has been accurately transferred onto our facade!

Introduction

Hello and welcome to CodedBIM! my name is Nasim Naji, I’m an architect from Iraqi Kurdistan and I’ve been working in the field of computational design for a while now. I have created countless custom workflows and solutions to aid me in my day to day challenges as an architect throughout my college years and beyond. I’m also a self taught C# and python programmer who thinks programming can help absolutely anyone and everyone to be more productive. and in some cases, even help them achieve results which are otherwise extremely time consuming, risky or outright impossible. even though I’ve occasionally used the knowledge in some rather cute personal projects outside of my field and profession, but the fact of the matter is, I mainly use software development and computer programming to aid me in my architectural career.

I have always felt that, the main strength of BIM, and it’s biggest advantage over traditional CAD solutions lies in the way it stores, handles and manipulates information in a raw and realistic way, and with the high level of complexity that BIM solutions such as Revit offer, I naturally had a desire to be able to freely and efficiently manipulate the model in meaningful ways. I first realized this fact when I started using an outstanding Autodesk product called Dynamo.


Dynamo’s node based user friendly interface can be used by architects and everyone else with minimum coding background….

Dynamo is a visual programming and non-destructive computational geometry modeling software which is available both as a standalone and an addin for Autodesk Revit and some other Autodesk products. with the innovative and user friendly node-based user interface of dynamo, I was introduced to the amazing world of visual programming and I can daringly say that I could never go back to using Revit without Dynamo. it has helped me tremendously over the years, both in school activities that were meant to be mostly artistic, as well as strictly realistic and accurate real world projects…

As amazing as dynamo is, and as much as I think that it helps smoothen out the learning curve of programming for AEC and it makes it easier to get into topics such as computational design, generative design, parametric architecture etc… but there is only so much that a visual programming tool can do. after using Dynamo for a while it quickly became obvious to me that learning a traditional software programming language can be extremely useful. for those of you who don’t know, Dynamo allows the user to write python code within it, so that’s where I started. one of the greatest advantages of writing python within Dynamo was the fact that now I had access to the Revit API and I could talk to Revit directly (if you don’t know what that is, Revit API is a set of Revit tools and functionalities that the developers have exposed for us to program). after learning python which is a relatively simple, but an extremely powerful language nevertheless, I slowly worked my way up from there, and I started experimenting with another more strongly typed language called C#, which quickly became my favorite language for writing Revit plugins and custom Dynamo nodes.


Now that you, the dear reader, know a little more about me and my past experiences, this brings us to CodedBIM and it’s purpose. CodedBIM is my first blog ever, and the main motivational force behind it’s creation is to serve as a platform, on which I can share my experiences in this field with the world, and hopefully potentially help others along the way. I really hope that you’ll enjoy your stay on my weblog and that we’ll be able to bring about an amazing community of professionals who are willing to excel in their work through exploring different alternatives and interdisciplinary collaboration.

Thank you very much for your time…

Nasim Naji Salim