API Yi Yi: bitmap to panel plugin



[EDIT: The startup proceedure for Revit 2011 API tools has changed a bit, read this post to get up to date]


Let me be the first to admit I have an unhealthy relationship with my software. But this is too cool to not gush about.


Harry the API Guru did a course on using the API in the revit 2010 massing environment at AU2009 just a few weeks ago: "Creating and Analyzing New Conceptual Massing Geometry With the Autodesk® Revit® API". Unfortunately, I was unable to attend, but I was given the opportunity to test drive some of the tools he made for the course before hand. Hands down the best one yet is Harry's SetParamFromImage.


Conceptually the tool is dead simple. You have a bitmap that is 12x12 pixels. You have a divided surface that is 12x12. The panels in your divided surface contain a parameter called Grayscale, and the API will write a value from 0" (white) to 12"(black) based on the pixel values of the image. Tah dah!



Of course, this is nothing new for many modeling softwares, which have been able to do this sort of thing with displacement to meshes with out-of-the-box functionality for over a decade. But it does get interesting when you tie this together with Revit's core competency of scheduling and parameter driven families. For instance. Here's a quick and dirty knock off of Gramazio and Kohler's winery, where they superimposed a image on a brick wall simply by precisely rotating bricks.






Now load, make your rotational parameter shared and you have precise information on the placement of each brick in your schedule.



You can extrapolate this method to all sorts of designs just deviating the angle of the brick on what is essentially a flat wall. The gradient and pattern fill tools in Photoshop get a whole new level of utility.
Another evening, armed with beer, the plugin, and something not so good on the Tevo, I came up with these 5 variations on a skyscraper facade just by manipulating a bitmap and reloading it. The panel has a mullion that has a radius directly linked to the 0-12" information given from the bitmap image.





We tinkered with the plugin a little since the AU class, you can download the most recent source code and the compiled dll here, along with a sample file to get you started. There are a bunch of other functions in this plugin, but the one I'm describing here is SetParamFromImage. You can see Harry's whole presentation at AU where he talks about making all the tools in this plugin.


To load it, I suggest using the revit add-in manager, which allows you to easily add and remove plugins that don't have installers: http://revittotd.com/07/607. If you just want to alter your .ini to load the plugin, add this to your .ini (see full instructions from this post)


[ExternalCommands]
ECCount=1
ECName1=SetParamFromImage
ECClassName1=AU2009.SetParamFromImage
ECAssembly1=[path to your dll]\AU2009.dll
ECDescription1=External Tool


The plugin will look for an image file next to your rfa file named "[your file name].rfa_grayscale.bmp" I really recommend starting small, like 12x12 bitmap/divided surface. It can take a really long time to start getting results with larger images.

Enjoy, make some good stuff.
[EDIT: The startup proceedure for Revit 2011 API tools has changed a bit, read this post to get up to date]

Comments

  1. Brings to mind this example:

    http://usa.autodesk.com/adsk/servlet/item?siteID=123112&id=12138853

    SOM's Cathedral of Christ the Light church that is built in the San Francisco bay area and is featured in the Autodesk Gallery in SF. Now if this plug-in would only have existed back during SOM's design process....

    ReplyDelete
  2. As Zach said, this functionality has been available for over a decade in many modeling software. So, there's nothing really amazing about it.

    Even though Revit is many years behind the competitors, I'm very glad to see that the software is really maturing and slowly catching up. In a few years we might even be able to unfold a facade in Revit.

    ReplyDelete
  3. Well . . . chocolate and peanut butter existed for centuries before Reese's (and don't even get me started on the pre-existence of Captains and Tennilles). What's important are the combinations of ideas. What happened in the previous incarnations of this sort of tool was an image map was combined with meshes or other modeling elements. The difference now is that the image is being combined with a relational database with a 3d graphical front end. This means a world of difference for construction and documentation, that is, creating a conduit between on screen ideas and built reality. This too is not necessarily new, Grasshopper has some awesome examples of using gestural external references to create easily quantified data sets, and I’m sure there are all sorts of ways to do this in GC.

    I believe this also could have been done before with regular curtain systems and the API, it's just that no one bothered to do it, or at least make the tool publicly accessible. Same with unfolding a façade. There’s plenty of information out there on general methodology to unfold geometry and the API can probably access all of the necessary features. It would be great to have this in out-of-the-box functionality, but it isn’t. You know any .net coders who want to give it a whack? My guess is that it is an economic hurdle and not a technological one. If there is enough money in unfolding, someone will do it. The beautiful thing about enthusiasm and wonder and curiosity is that it often makes an end run on economics and makes things happen because someone just wants it badly enough. Usually doesn’t pay the bills though.

    BTW, my shallow understanding of the Revit API is that there are very different hurdles when working with an object oriented database instead of simple geometry. Jeremy Tammik has a lovely description of the difference between working in simple 3d space and a fully interconnected parametric environment: http://thebuildingcoder.typepad.com/blog/2009/05/transform-an-element.html

    ReplyDelete
  4. Historically, Revit has been a tool for regular day to day orthogonal buildings. So the current Revit users will demand different tools than others who designs structures like the bird cage in Beijing. Demands for tools like an algortimic editor, a tool to unfold facades or a tool to randomly place panels in a curtain system aren't present within the current Revit community, but are higly demanded outside of the Revit spectrum. To win a competition nowadays you can't do without using grasshopper. Or world wide venues like the olympics are all done with parametric alogorithmic software like Generative components.

    Revit has made great progress on the API and lets just hope that someone catches on to this and creates these great plugins.

    ReplyDelete
  5. Thanks Zach, this post relay fascinated me, since I've been training Revit for more then a year and never could impress one concept modeler until your post showed, unfolding valuable info! But how can a regular architect write such complex scripting? And is there any available step by step tutorials revealing the mystery!?

    ReplyDelete
  6. I’m glad that this was interesting to you and I hope you can pass some of it on to your trainees.
    I’m told that this particular coding is not so complicated, but I don’t know how to code. I have tried a couple times to learn, but I realized that it would take me a long time to become as good as a very poor programmer. There are a couple things that I can do well, and I would rather trade on them and have friends and colleges that I can work with who have coding experience. I haven’t yet found a step by step entry to the process that is satisfying, just as you will probably not find a step by step tutorial called “how to design architecture” that is particularly convincing. That isn’t to say you shouldn’t try, I just have a pretty short attention span. I have learned just enough to be able to access stuff that isn’t polished and ready for a mass market, which is helpful when you are getting friends to write code in exchange for beer or pretty pictures. This kind of stuff can be learned by reading the documentation that comes with the Revit SDK and downloading a free development environment like Visual Studio Express.

    ReplyDelete
  7. This is a good step-by-step tutorial in how to get started with the Revit API. It does not sepcifically address this image-to-parameter example but it is a good place to start if you would like to learn about Revit API coding.

    http://download.autodesk.com/media/adn/DevTV_Introduction_to_Revit_Programming/

    ReplyDelete
  8. A file called "AssemblyInfo.cs" is missing(http://buildz.info/downloads/AU2009plugins.zip) and the plugin is failing because of this. Is there any way I can get this missing file?

    ReplyDelete
  9. Hello ... Kron
    Luiz Carlos said ... Make use of API's makes design ideas that we have before we started our project Q. Here 's an incredibly great step forward for all designers. The API's makes a difference in the final product.
    lcchvacr

    ReplyDelete
  10. Hello,

    I am trying to use this add-on on Revit 2011 and I can't seem to be able to load it... I assume I have the wrong dll for 2011. Any idea of how I can implement the same tool explained here on Revit 2011?

    Thanks so much in adavance!

    ReplyDelete
  11. Yes, the api setup and dlls have changed a bit for 2011. Read this post to get up and running:
    http://buildz.blogspot.com/2010/08/making-revit-forms-from-image-files-in.html

    ReplyDelete
  12. Thanks Zach, I will check it out!

    ReplyDelete
  13. Zach, thanks for a great description! this is awesome material. I have it working on my revit and I couldn't be more stoked.
    one question though about how it works - does the grayscale variable always have a length range of values from 0-12" or is it 0-x where x is the size of the bitmap length/width? in your example it is a 12x12 pixel bitmap.
    does grayscale come in as a length variable with a unit attached or is it a unitless number?

    ReplyDelete
  14. Great question Laura. I think I had it in my mind that it was writing a 0' to 1' range but it is actually writing a unitless 0 to 1 number now that I take a closer look. Whatever the parameter type you set to Grayscale, it will operate as though you manually entered a value from 0 to 1 and convert to whatever units you like. Black=1, White=0.

    ReplyDelete
  15. Hi!
    Is it possible to use this plugin, with nonlatin characters and spaces in my Windows username?
    Revit starts with an error message telling me the file does not exists :(
    Thank you,
    b

    ReplyDelete
  16. bzsi,
    are you using the installer? If so, what path did you install it to?

    ReplyDelete
  17. I used the installer, and after unsuccessful process I tried to fix it manually.

    I got this error

    ReplyDelete
  18. @bzsi, looks like you are trying to use the plugin in Vasari with the the application written to a the app data folder. Due to some restrictions in Vasari, the program can't "see" certain folders, namely most subfolder of App Data and Program Files. When you install, write to a different directory, should work fine then

    ReplyDelete
  19. When I try this, it seems that my grayscale image is rotated 90 when applied to the mass...What's going on?

    ReplyDelete
  20. Would this work in Revit 2012?

    ReplyDelete
  21. The white part of my grayscale image causes the panels in that area to disappear (can't make type when value is set to 0). how do i get around that? Thanks.

    ReplyDelete
  22. StealthNYC, there are a couple options. Easiest is to set your bitmap to not quite hit a 0 value (make it a little more greay). Otherwise you can adjust your family to work with a value of 0 input (say, add a little by default, make another paramater equal to Grayscale+.01) or add a conditional that catches 0, if(Grayscale=0,0.1,Grayscale)

    ReplyDelete
  23. This is just GREAT!
    Well done Zach!
    The only thing that comes to my mind is how to build it in real life...? (without a robotic arm that places each brick in its place)

    ReplyDelete
  24. Robotic arm is definitely the recommended approach, although similar subtle manipulations of surfaces were achieved in projects like the Grimshaw steel museum's louvering system in Montery with a detailed spreadsheet and many many patient wrenches.

    ReplyDelete
  25. has anyone tried this in 2013? I am not getting the "External Tools" tab under Add-ins like in previous verisons. Have I lost my edge?
    HHHEEELLLLPPPP!

    ReplyDelete
  26. This comment has been removed by the author.

    ReplyDelete
  27. Will this work in Revit 2014?

    ReplyDelete
  28. I don't think anyone has ported this application to 2014. I have been doing this kind of work now with Dynamo. If you download Dynamo, take a look at sample 20 Panel Manipulations for an example of how to get data from images to panels.

    ReplyDelete

Post a Comment