Macro Texture

From FreeCAD Documentation
Jump to navigation Jump to search
Other languages:
Deutsch • ‎English • ‎français • ‎italiano • ‎čeština

FCTexture.png Macro Texture

Description
Creates an image 3D from a BMP image 8 bits (256 colours).
This small macro allows you to build a project 3D very easily from a bitmap image 256 levels of gray.
If one image BMP 32 bits is selected the image is represented in points (Time !!!).
The macro FCCreaLoft Macro Loft for automate the multi loft.

Macro version: 0.13
Last modified: 2020-04-17
FreeCAD version: 0.18 and more
Download: ToolBar Icon, Macro Loft FCCreaLoft
Author
Mario52
Download
ToolBar Icon, Macro Loft FCCreaLoft
Links
Macro Version
0.13
Date last modified
2020-04-17
FreeCAD Version(s)
0.18 and more
Default shortcut
None
See also
FCCreaLoft Macro Loft


Description

This small macro allows you to build a project 3D very easily from a bitmap image 256 levels of gray.

I hope that this macro will revolutionize the way of thinking the CAD and CNC any image when what can be converted to object 3D without any intervention.

Everything becomes possible regardless of the complexity of the image !

The macro FCCreaLoft Macro Loft for automate the multi loft

Temporary code for external macro link. Do not use this code. This code is used exclusively by Addon Manager.


# 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/dc31d568180b5aa20887e20b5dc622fc860e1d33/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/dc31d568180b5aa20887e20b5dc622fc860e1d33/Macro%2520FCTexture.FCMacro")
<class="rawcodeurl"><a href="https://gist.githubusercontent.com/mario52a/262317bc7d8555885b0e/raw/dc31d568180b5aa20887e20b5dc622fc860e1d33/Macro%2520FCTexture.FCMacro">raw code</a>


Texture 004 Honda.png

Texture 004 Honda


Usage

This macro need an image in 256 gray levels (0-255) therefore before using the macro, convert your image into grayscale (black and white) Lowe. The number of colors is detected automatically, if the image is more than 256 colors another function is expected (to come). 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.

Attention: depending on the size of the image, the project can become very big! for the record an image of 100 px wide and 100 px in height gives 100 x 100 = 10000 points 'and as each point corresponds to a coordinate, so 10000 coordinates XYZ there.

The interface

Texture 002


Coordinate

  • Coordinate X Std CoordinateSystem.svg 0,00 mm SpinBox.svg : coordinate X of position of the object, default: 0.
  • Coordinate Y Std CoordinateSystem.svg 0,00 mm SpinBox.svg : coordinate Y of position of the object, default: 0.
  • Coordinate Z Std CoordinateSystem.svg 0,00 mm SpinBox.svg : coordinate Z of position of the object, default: 0.

Stetching

  • Stetching X 0,00 mm SpinBox.svg : narrowing or enlargement of the length of the object, default: 0.
  • Stetching Y 0,00 mm SpinBox.svg : narrowing or enlargement of the height of the object, default: 0.
  • Stetching Z 0,00 mm SpinBox.svg : narrowing or enlargement of the depth of the object, default: 0.

Inversion

  • CheckBoxFalse.svg Axis X : reverse coordinates X image.
  • CheckBoxFalse.svg Axis Y : reverse coordinates Y image.
  • CheckBoxFalse.svg Axis Z : reverse coordinates Z image.

Mode 8 Bits

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).

  • RadioButtonTrue.svg Draft Wire.svg Wire : build your line (vector) in the form of Wire.
  • RadioButtonFalse.svg Draft BSpline.svg Bspline : build your line (vector) in the form of Bspline.
  • RadioButtonFalse.svg Workbench Points.svg Cloud : build the points vectors in the points cloud.
  • RadioButtonFalse.svg Draft Point.svg Point : creates a point at each pixel (vector). (the procedure can be long)
  • CheckBoxFalse.svg Nuance : If the shade option is checked the color of the point is represented as a picture.

Mode 32 Bits

  • RadioButtonTrue.svg Photo : the photo mode is automatically activated when a 32-bit image is detected. (the procedure can be long)
  • RadioButtonFalse.svg Plan : the plan allows you to import 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. (the procedure can be long)

File

  • CheckBoxFalse.svg .pcd : if is checked one file originalName.bmp.pcd is saved in the same directory of the file (pcd v0.7).
  • CheckBoxFalse.svg .asc : if is checked one file originalName.bmp.asc is saved in the same directory of the file. This file can be used as a cloud point (format: X Y Z).

Capping (10mm)

  • Slider : give the height of the form the height is displayed on title frame.
  • 0 height SpinBox.svg : give the height of the form the height is displayed on title frame.
  • Raw mode CheckBoxFalse.svg 20 : to adjust 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).
  • CheckBoxFalse.svg : this checkBox switch enabled the spinbox Contour.
  • 0/2 Contour SpinBox.svg : this spinbox give the contour line do not use (ex: 0 for the base).
  • Capping CheckBoxFalse.svg White : the capping 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 SpinBox.svg : this spinbox give the degrees of capping.

Command

  • File and launch : opens the image file and launches the conversion.
  • Help : display the wiki page in the FreeCAD webBrowser
  • Quit : exits the function.

Script

The icons .png FCTexture.png and .svgFCTexture.svg


Macro_Texture.FCMacro

Download the macro to Gist Macro FCTexture.FCMacro

Example

The images were inclined to enhance the 3D effect.









Links

The discussion on the forum to give your impressions or contact me.

The macro FCCreaLoft Macro Loft for automate the multi loft

apply hair cell texture

How to handle pdf import properly and feasibly?

Revision

  • ver 0.13 : 17/04/2020 Layout and PySide2 Qt5
  • ver 0.12 : 04/08/2019 add spinbox button for height
  • ver 0.11 :03/07/2019 adapt to Python 3
  • ver 0.10 : 28/12/2016 add save point in .pcd, .asc display a points cloud, height form, contour
  • ver 0.9 : 12/12/2016 adding save file .asc for cloud point
  • ver 0.8 : 16/03/2016 adding progressBar
  • ver 0.7 : 03/09/2014 Delete "translate" forgotten and bug fix discovered by the passage of PyQt to Pyside !
  • ver 0.6 : 26/08/2014 Delete all "_translate"
  • ver 0.5 : 25/08/2014 Delete "_translate (" MainWindow "," Stretching X ", None)" that prevented the display of tooltip with PySide (Windows Vista)
  • ver 0.4 : 08/08/2014 PyQt4 PySide
  • ver 0.3 : 28/03/2014 :comment out the line "# self.checkBox_5.setAccessibleName(_fromUtf8(""))"

that causes an error with the version FreeCAD : Version: 0.14.3343 (Git), Python version: 2.7.6, Qt version: 4.8.5