Creates a 3D image from an 8 bit (256 color) BMP image. In other words, it allows one to build a 3D project very easily from a bitmap image using grayscale (256 shades of gray). If one 32 bit BMP image is selected, the image is represented in points. The FCCreaLoft Macro Loft macro is used to automate the multi loft operation.
Macro version: 0.15 Last modified: 2025/01/04 FreeCAD version: 0.18 and more Download: ToolBar Icon Author: Mario52
This small macro allows one to build a 3D project very easily from a bitmap image with 256 shades of gray.
I hope that this macro will revolutionize the way we think when modeling with CAD and CNC converting to 3D objects with little to no intervention.
Everything becomes possible regardless of the complexity of the image!
The Macro Loft is used to automate the multi loft operation.
Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager. Link for optional manual installation: Macro
# This code is copied instead of the original macro code
# to guide the user to the online download page.
# Use it if the code of the macro is larger than 64 KB and cannot be included in the wiki
# or if the RAW code URL is somewhere else in the wiki.
from PySide import QtGui, QtCore
diag = QtGui.QMessageBox(QtGui.QMessageBox.Information,
"Information",
"This macro must be downloaded from this link\n"
"\n"
"https://gist.githubusercontent.com/mario52a/262317bc7d8555885b0e/raw/f18613c8bfd142e644ba79fc8dd34a5f72282f18/Macro%2520FCTexture.FCMacro" + "\n"
"\n"
"Quit this window to access the download page")
diag.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
diag.setWindowModality(QtCore.Qt.ApplicationModal)
diag.exec_()
import webbrowser
webbrowser.open("https://gist.githubusercontent.com/mario52a/262317bc7d8555885b0e/raw/f18613c8bfd142e644ba79fc8dd34a5f72282f18/Macro%2520FCTexture.FCMacro")
This macro requires an image in 256 shades of gray (0-255) therefore before executing the macro, convert your image into grayscale (black and white). When running the macro, the number of colors is detected automatically. Note: if the image is more than 256 colors another function is expected (WIP). Each color (gray level) is regarded as a deep, white (255) the level high and black (0) the lowest level (deep).
Configuration is done before the opening of the file, default values are the settings provided to get a project's dimensions:
width of the image in points in the coordinate X,
height of the image in points in the coordinate Y,
depth or thickness of the project leaked 10 mm (in raw mode, on 256 mm) in the coordinate Z.
The image file unfolds like a scanner x1 x2 x3 ... in 1 mm increments in FreeCAD similarly to the value y of 1 mm at a time. The value of z is given by the value of the color. These values are configurable in the macro.
Important note: depending on the size of the image, the project can become very large in size! For example, a simple image of (100px x 100px) width/height would be: 100 x 100 = 10000 points. Each of the 10,000 points corresponds to a coordinate, so that means 10000 X, 10000 Y, and 10000 Z coordinates in actuality.
Interface
Texture 002
Coordinates
Coordinate X 0,00 mm : The X coordinate position of the object (default: 0)
Coordinate Y 0,00 mm : The Y coordinate position of the object (default: 0)
Coordinate Z 0,00 mm : The Z coordinate position of the object (default: 0)
Stretching
Stretching X0,00 mm : narrowing or enlarging of the X (length) of the object (default: 0)
Stretching Y0,00 mm : narrowing or enlarging of the Y (height) of the object (default: 0)
Stretching Z0,00 mm : narrowing or enlarging of the Z (depth) of the object (default: 0)
Inversion
Axis X: inverts the X coordinates of the image.
Axis Y: inverts the Y coordinates of the image.
Axis Z: inverts the Z coordinates of the image.
8 bit Mode
The beginning of the operation value automatically adapts to the selected function: 0 if the setting is on black (Black) 255 or 20 if the setting is white (White).
Wire: build the line (vector) in the form of Wire.
Bspline: build the line (vector) in the form of Bspline.
Cloud: build the points vectors in a point cloud.
Point: creates a point at each pixel (vector) (Note: this procedure is CPU intensive)
Nuance: if the shade option is checked, the color of the point is represented as a picture.
32 bit Mode
Photo: photo mode is automatically activated when a 32-bit image is detected. (Note: this procedure is CPU intensive)
Plan: allows for importing a 32-bit image and ignore the background of the plan. By default the map background is black to ignore colors are adjustable with the Capping command. If White is checked, the bottom has ignore will be white. (Note: this procedure is CPU intensive)
File
.pcd: if checked, a file (originalName.bmp.pcd) is saved in the same directory of the file (pcd v0.7).
.asc: if checked, a file (originalName.bmp.asc) is saved in the same directory of the file. This file can be used as a point cloud (format: X Y Z).
Capping (10mm)
Slider: Enter the height of the form. The height is displayed on title frame.
0 height : Enter the height of the form. The height is displayed on title frame.
Raw mode 20: For adjusting the number of colors (depth). The default mode is 0-20 (which constitutes a filter and to obtain more details according to the complexity of the image) once the checked the mode is 0 to 255 (the entire range of colors).
: this option enables the ability to access the Contour spinbox
0/2 Contour : this spinbox gives the contour line. do not use (ex: 0 for the base).
Capping White: this function can be made on the choice of colours, white (default) or black. The degrees of capping rule 20 to 0 (or 255 to 0) if the checkbox is set on W (unchecked) or 0 to 20 (or 0 to 255) if the checkbox is set on B (checked).
20 Capping : this spinbox gives the degrees of capping.
Command
File and launch: opens the image file and launches the conversion.
Help:
Display the Wiki page in the FreeCAD browser
For change the parameter disponible: go to Tools → Edit parameter...
__The global step on spinBox:__
User parameter:BaseApp/Preferences/Macros/FCMmacros/FCTexture → SingleStep
Adjust the value desired (1.0 by default)
__For search if the macro is upgraded :__
User parameter:BaseApp/Preferences/Macros/FCMmacros/FCTexture → switchVesionMacroSearch
Adjust the switchVesionMacroSearch to true (false by default)