CAD Forum - tips, tricks, discussion and utilities for AutoCAD, Inventor, Revit and other Autodesk products [www.cadforum.cz]
Cesky English Deutsch
Login/Register:
 Visitors: 483 

CAD tip CAD tip # 12609:

Question CAD 
 %  platform  category 
Q - question

Dynamo - how to convert a raster photo to 3D model in Revit?

A - answer With the following Dynamo script (.dyn) "Img2Model" you can create a 3D model from a specified raster image in Autodesk Revit. The individual pixels of the photo are converted to "3D pixels", where the size of each "pixel" is determined by the brightness of the respective image pixel. The functionality of this add-on tool is similar to our similar applications for AutoCAD (ImgConvert), Inventor (BoreImage) and Fusion 360 (Image2Model).

In addition to illustrating the possibilities of automated raster image processing in Dynamo, this script can also be used for practical purposes - e.g. for facade elements depicting the content of a photograph or logo, for a work of art, etc. It should be emphasized here that only raster images with low resolution (number of pixels) should be used, otherwise the script processing will be very lengthy.

Sources
To process the image, we will need the source image and an auxiliary family of a "3D pixel", the parametric family of the general model of the cube. As a source image, it is best to use a black and white (shades of gray) photo with good contrast, reduced to a size of only about 50 pixels. The script itself allows you to reduce the resolution of the selected photo, but it is better to "downsample" it directly in a graphics editor. An example of a photo with a resolution of 32x35 pixels is here (8x magnified intentionally for display):

As a "single pixel" parametric cube we can use the "Krychle" (Cube) family from the BIM block library, but any other parametric family preloaded in the project can be used - its name and its dimensional parameter has to be modified in the Dynamo script (default "Krychle:Krychle" and "Size").

Dynamo
We can now assemble a visual recipe for processing an image into a rectangular array of 3D "pixels". Using Manage > Visual Programming > Dynamo, start the Dynamo module in Revit and start specifying the individual steps (nodes) of the procedure.

The Dynamo script consists of 3 basic parts - loading the source photo, creating an auxiliary rectangular array of "3D pixels" and sizing these "pixels" according to the brightness of the corresponding pixel in the source photo. The input parameters will be the selection of the source raster file (all supported image formats), the downsampling ration for possible large images (e.g. for the original size of 1000px use approx. 20) and the overall scale of the resulting model (1 = unit size of "3D pixel").

Output
You can download the finished Img2Model.dyn script from the Download page. Use the Manual mode in Dynamo to edit and run the script as the script may take a few minutes to run. The result of the script is then a similar model:

You can preset this or any other Dynamo script (with correctly set input parameters) for a quick launch in Dynamo Player. Copy it to the folder C:\ProgramData\Autodesk\RVT 2021\Dynamo\samples\en-US\Revit\DynamoPlayer-4\ or add your script folder to the Dynamo Player. You can then run it directly from the Revit ribbon:

See also Img2Model on the blog NaZdi

RevitDynamo
100% *  CAD 
18.5.2020    440×  
Prices - CAD eShop:
applies to: Revit · Dynamo ·

See also:
Tip 12629:As sunflowers follow the Sun... Dynamo script for Revit
Tip 11634:Which CAD/BIM products are supported by the visual programming tool Dynamo?
Tip 11350:How to renumber Revit rooms in a given order?
Tip 11182:Can I use two versions of Dynamo on the same PC?
Tip 11181:Suddenly cannot run Dynamo in Advance Steel.


Back   All CAD Tips All CAD tips&tricks



Have we helped you? If you want to support the CAD Forum web service, consider buying one of our CAD applications, or our custom software development offerings, or donating via PayPal (see above). You may also add a link to your web - like this "fan" link: CAD Forum - tips, utilities, blocks for Autodesk products
CAD:    OS:    Categ: 
Text:  FAQ glossary   



Featuring:
Use Google Earth images in your AutoCAD projects with the Plex.Earth Tools More info


Please use these tips at your own risk.
CAD Studio is not responsible for possible problems that may occur as a result of using any of these tips.
TOPlist