Macro Texture: Difference between revisions
Renatorivo (talk | contribs) m (Renatorivo moved page Macro FCTexture to Macro Texture without leaving a redirect: style) |
No edit summary |
||
(45 intermediate revisions by 6 users not shown) | |||
Line 1: | Line 1: | ||
<languages/> |
|||
<translate> |
<translate> |
||
<!--T:1--> |
<!--T:1--> |
||
{{Macro |
|||
{{Macro|Icon=FCTexture|Name=Macro FCTexture|Description=Creates an image 3D from a BMP image.|Author=Mario52}} |
|||
|Name=Macro Texture |
|||
|Icon=FCTexture.png |
|||
|Description=Creates a 3D image from an 8 bit (256 color) BMP image.<br/>In other words, it allows one to build a 3D project very easily from a bitmap image using grayscale (256 shades of gray).<br/>If one 32 bit BMP image is selected, the image is represented in points.<br/>The '''FCCreaLoft Macro Loft''' macro is used to automate the multi loft operation. |
|||
|Author=Mario52 |
|||
|Version=0.14c |
|||
|Date=2021/01/16 |
|||
|FCVersion=0.18 and more |
|||
|Download=[https://www.freecadweb.org/wiki/images/9/90/FCTexture.png ToolBar Icon] |
|||
|SeeAlso=[[File:FCCreaLoft.png|32px|FCCreaLoft]] [[Macro_Loft|Macro Loft]] |
|||
}} |
|||
==Description== <!--T: |
==Description== <!--T:43--> |
||
This small macro allows you to build a project 3D very easily from a bitmap image 256 levels of gray. |
|||
<!--T:2--> |
|||
This small macro allows one to build a 3D project very easily from a bitmap image with 256 shades of gray. |
|||
<!--T:3--> |
<!--T:3--> |
||
I hope that this macro will revolutionize the way |
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. |
||
<!--T:4--> |
<!--T:4--> |
||
Everything becomes possible regardless of the complexity of the image |
Everything becomes possible regardless of the complexity of the image! |
||
<!--T:26--> |
<!--T:26--> |
||
The |
The [[File:FCCreaLoft.png|32px|FCCreaLoft]] [[Macro_Loft|Macro Loft]] is used to automate the multi loft operation. |
||
</translate> |
|||
{{Codeextralink|https://gist.githubusercontent.com/mario52a/262317bc7d8555885b0e/raw/3ec2ab127d8ad01a6b657aa5df9a6127ff07c7c0/Macro%2520FCTexture.FCMacro}} |
|||
<translate> |
|||
</translate> |
|||
[[File:Texture 004 Honda.png|480px]] |
|||
<translate> |
|||
<!--T:5--> |
<!--T:5--> |
||
{{Caption|Texture 004 Honda}} |
|||
{{clear}} |
|||
==Usage== <!--T:44--> |
|||
<!--T:6--> |
|||
This macro |
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). |
||
<!--T:7--> |
<!--T:7--> |
||
Line 32: | Line 54: | ||
<!--T:9--> |
<!--T:9--> |
||
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=== <!--T:10--> |
||
<!--T:11--> |
<!--T:11--> |
||
[[File:Texture_002.png| |
[[File:Texture_002.png|300px|none|Texture 002]] |
||
====Coordinates==== <!--T:45--> |
|||
<!--T:12--> |
<!--T:12--> |
||
* |
* {{Button|Coordinate X [[Image:Std_CoordinateSystem.svg|24px]]}} {{SpinBox|0,00 mm}}: The '''X''' coordinate position of the object (default: 0) |
||
* |
* {{Button|Coordinate Y [[Image:Std_CoordinateSystem.svg|24px]]}} {{SpinBox|0,00 mm}}: The '''Y''' coordinate position of the object (default: 0) |
||
* |
* {{Button|Coordinate Z [[Image:Std_CoordinateSystem.svg|24px]]}} {{SpinBox|0,00 mm}}: The '''Z''' coordinate position of the object (default: 0) |
||
* |
|||
* '''Stetching X:''' narrowing or enlargement of the length of the object, default: 0. |
|||
* '''Stetching Y:''' narrowing or enlargement of the height of the object, default: 0. |
|||
* '''Stetching Z:''' narrowing or enlargement of the depth of the object, default: 0. |
|||
* |
|||
* '''Raw mode:''' to adjust the number of colors (depth). The default mode is 0-19 (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). |
|||
* '''Capping:''' the capping function can be made on the choice of colours, white (default) or black. The degrees of capping rule 19 to 0 (or 255 to 0) if the checkbox is set on '''W''' (unchecked) or 0 to 19 (or 0 to 255) if the checkbox is set on '''B''' (checked). |
|||
<!--T: |
====Stretching==== <!--T:46--> |
||
The beginning of the operation value automatically adapts to the selected function: 0 if the setting is on black ('''Black''') 255 or 19 if the setting is white ('''White''') |
|||
* |
|||
* '''Wire:''' build your line (vector) in the form of Wire. |
|||
* '''Bspline:''' build your line (vector) in the form of Bspline. |
|||
* '''Point:''' creates a point at each pixel (vector). (the procedure can be long) |
|||
* '''Nuance:''' If the shade option is checked the color of the point is represented as a picture |
|||
* |
|||
* '''Inversion X:''' reverse coordinates '''X''' image. |
|||
* '''Inversion Y:''' reverse coordinates '''Y''' image. |
|||
* '''Inversion Z:''' reverse coordinates '''Z''' image. |
|||
* |
|||
* '''Photo:''' the photo mode is automatically activated when a '''32-bit image''' is detected. (the procedure can be long) |
|||
* '''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 and lauch:''' opens the image file and launches the conversion. |
|||
* '''Quit:''' exits the function. |
|||
<!--T:31--> |
|||
* {{Button|Stretching X}} {{SpinBox|0,00 mm}}: narrowing or enlarging of the '''X''' (length) of the object (default: 0) |
|||
* {{Button|Stretching Y}} {{SpinBox|0,00 mm}}: narrowing or enlarging of the '''Y''' (height) of the object (default: 0) |
|||
* {{Button|Stretching Z}} {{SpinBox|0,00 mm}}: narrowing or enlarging of the '''Z''' (depth) of the object (default: 0) |
|||
<!--T: |
====Inversion==== <!--T:47--> |
||
The icons .png [[Image:FCTexture.png|64px]] and .svg[[Image:FCTexture.svg|64px]] |
|||
<!--T:32--> |
|||
</translate> |
|||
* {{CheckBox|Axis X}}: inverts the '''X''' coordinates of the image. |
|||
'''Macro_FCTexture.FCMacro''' |
|||
* {{CheckBox|Axis Y}}: inverts the '''Y''' coordinates of the image. |
|||
* {{CheckBox|Axis Z}}: inverts the '''Z''' coordinates of the image. |
|||
====8 bit Mode==== <!--T:48--> |
|||
{{Code|code= |
|||
<!--T:33--> |
|||
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'''). |
|||
from __future__ import unicode_literals |
|||
""" |
|||
*************************************************************************** |
|||
* Copyright (c) 2014 <mario52> * |
|||
* * |
|||
* This file is a supplement to the FreeCAD CAx development system. * |
|||
* * |
|||
* This program is free software; you can redistribute it and/or modify * |
|||
* it under the terms of the GNU General Public License (GPL) * |
|||
* as published by the Free Software Foundation; either version 3 of * |
|||
* the License, or (at your option) any later version. * |
|||
* for detail see the LICENCE text file. * |
|||
* * |
|||
* This software is distributed in the hope that it will be useful, * |
|||
* but WITHOUT ANY WARRANTY; without even the implied warranty of * |
|||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
|||
* GNU Library General Public License for more details. * |
|||
* * |
|||
* You should have received a copy of the GNU General Public License * |
|||
* License along with this macro; if not, write to the Free Software * |
|||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * |
|||
* USA * |
|||
*************************************************************************** |
|||
* WARNING! All changes in this file will be lost and * |
|||
* may cause malfunction of the program * |
|||
*************************************************************************** |
|||
""" |
|||
# pour faire une texture de votre image, l'image doit être en 256 niveaux de gris (N/B) |
|||
# une image de 16 millons de couleurs fait l'objet d'une autre procédure d'affichage |
|||
# http://forum.freecadweb.org/viewtopic.php?f=24&t=5893&sid=c5f8d32c22e1d1a883741b70b1fea2dc |
|||
# ver 0.7 03/09/2014 PyQt4 and PySide 0.8 16/03/2016 |
|||
<!--T:34--> |
|||
__title__ = "FCTexture" |
|||
* {{RadioButton|TRUE|[[Image:Draft_Wire.svg|24px]] Wire}}: build the line (vector) in the form of Wire. |
|||
__author__ = "Mario52" |
|||
* {{RadioButton|[[Image:Draft_BSpline.svg|24px]] Bspline}}: build the line (vector) in the form of Bspline. |
|||
__url__ = "http://www.freecadweb.org/index-fr.html" |
|||
* {{RadioButton|[[Image:Workbench_Points.svg|24px]] Cloud}}: build the points vectors in a point cloud. |
|||
__version__ = "0.8" |
|||
* {{RadioButton|[[Image:Draft_Point.svg|24px]] Point}}: creates a point at each pixel (vector) (Note: this procedure is CPU intensive) |
|||
__date__ = "16/03/2016" |
|||
* {{CheckBox|Nuance}}: if the shade option is checked, the color of the point is represented as a picture. |
|||
try: |
|||
import PyQt4 |
|||
from PyQt4 import QtGui ,QtCore |
|||
from PyQt4.QtGui import * |
|||
from PyQt4.QtCore import * |
|||
except Exception: |
|||
import PySide |
|||
from PySide import QtGui ,QtCore |
|||
from PySide.QtGui import * |
|||
from PySide.QtCore import * |
|||
import Draft, Part, FreeCAD, math, PartGui, FreeCADGui, FreeCAD |
|||
from math import sqrt, pi, sin, cos, asin |
|||
from FreeCAD import Base |
|||
import os, time, sys |
|||
import os.path |
|||
def errorDialog(msg): |
|||
diag = QtGui.QMessageBox(QtGui.QMessageBox.Critical,u"Error Message",msg ) |
|||
diag.setWindowModality(QtCore.Qt.ApplicationModal) |
|||
diag.exec_() |
|||
def decobit(b0 = 0, b1 = 0, b2 = 0, b3 = 0): |
|||
b0 = int(ord(b0)) |
|||
b1 = int(ord(b1)) |
|||
if b2 == 0: |
|||
return b0 + (b1*256) |
|||
else: |
|||
b2 = int(ord(b2)) |
|||
b3 = int(ord(b3)) |
|||
return b0 + (b1*256) + (b2*65536) + (b3*16777216) |
|||
global position_X ; position_X = 0.0 |
|||
global position_Y ; position_Y = 0.0 |
|||
global position_Z ; position_Z = 0.0 |
|||
global etirement_X ; etirement_X = 1.0 |
|||
global etirement_Y ; etirement_Y = 1.0 |
|||
global etirement_Z ; etirement_Z = 1.0 |
|||
global modeBrut ; modeBrut = 0 |
|||
global modeColor ; modeColor = 0 |
|||
global ecreter ; ecreter = 19 |
|||
global avecLigne ; avecLigne = 1 |
|||
global typeligne ; typeligne = 0 |
|||
global nuance ; nuance = 0 |
|||
global inversion_X ; inversion_X = 0 |
|||
global inversion_Y ; inversion_Y = 0 |
|||
global inversion_Z ; inversion_Z = 0 |
|||
global plan ; plan = 0 |
|||
global fond ; fond = 0 |
|||
global bits_pixel ; bits_pixel = 0 |
|||
global tailleDonnees; tailleDonnees = 0 |
|||
#global path ; path = FreeCAD.ConfigGet("AppHomePath") |
|||
global path ; path = FreeCAD.ConfigGet("UserAppData") |
|||
try: |
|||
_fromUtf8 = QtCore.QString.fromUtf8 |
|||
except AttributeError: |
|||
def _fromUtf8(s): |
|||
return s |
|||
try: |
|||
_encoding = QtGui.QApplication.UnicodeUTF8 |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig, _encoding) |
|||
except AttributeError: |
|||
def _translate(context, text, disambig): |
|||
return QtGui.QApplication.translate(context, text, disambig) |
|||
class Ui_MainWindow(object): |
|||
def __init__(self, MainWindow): |
|||
self.window = MainWindow |
|||
global path |
|||
global position_X |
|||
global position_Y |
|||
global position_Z |
|||
global etirement_X |
|||
global etirement_Y |
|||
global etirement_Z |
|||
global modeBrut |
|||
global modeColor |
|||
global ecreter |
|||
global typeligne |
|||
global nuance |
|||
global avecLigne |
|||
global inversion_X |
|||
global inversion_Y |
|||
global inversion_Z |
|||
global plan |
|||
global fond |
|||
global bits_pixel |
|||
global tailleDonnees |
|||
MainWindow.setObjectName(_fromUtf8("MainWindow")) |
|||
MainWindow.resize(263, 536) |
|||
self.centralWidget = QtGui.QWidget(MainWindow) |
|||
self.centralWidget.setObjectName(_fromUtf8("centralWidget")) |
|||
self.frame = QtGui.QFrame(self.centralWidget) |
|||
self.frame.setGeometry(QtCore.QRect(10, 11, 241, 101)) |
|||
self.frame.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame.setObjectName(_fromUtf8("frame")) |
|||
self.doubleSpinBox_01 = QtGui.QDoubleSpinBox(self.frame) |
|||
self.doubleSpinBox_01.setGeometry(QtCore.QRect(120, 10, 111, 22)) |
|||
self.doubleSpinBox_01.setDecimals(7) |
|||
self.doubleSpinBox_01.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_01.setMaximum(9999999.99) |
|||
self.doubleSpinBox_01.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_01.setObjectName(_fromUtf8("doubleSpinBox_01")) |
|||
self.doubleSpinBox_01.setToolTip(u"Coordinate placement Axis X.") |
|||
self.doubleSpinBox_01.valueChanged.connect(self.on_doubleSpinBox_01_valueChanged) #position_X connection doubleSpinBox_01 |
|||
self.doubleSpinBox_02 = QtGui.QDoubleSpinBox(self.frame) |
|||
self.doubleSpinBox_02.setGeometry(QtCore.QRect(120, 40, 111, 22)) |
|||
self.doubleSpinBox_02.setDecimals(7) |
|||
self.doubleSpinBox_02.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_02.setMaximum(9999999.99) |
|||
self.doubleSpinBox_02.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_02.setObjectName(_fromUtf8("doubleSpinBox_02")) |
|||
self.doubleSpinBox_02.setToolTip(u"Coordinate placement Axis Y.") |
|||
self.doubleSpinBox_02.valueChanged.connect(self.on_doubleSpinBox_02_valueChanged) #position_Y connection doubleSpinBox_02 |
|||
self.doubleSpinBox_03 = QtGui.QDoubleSpinBox(self.frame) |
|||
self.doubleSpinBox_03.setGeometry(QtCore.QRect(120, 70, 111, 22)) |
|||
self.doubleSpinBox_03.setDecimals(7) |
|||
self.doubleSpinBox_03.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_03.setMaximum(9999999.99) |
|||
self.doubleSpinBox_03.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_03.setObjectName(_fromUtf8("doubleSpinBox_03")) |
|||
self.doubleSpinBox_03.setToolTip(u"Coordinate placement Axis Z.") |
|||
self.doubleSpinBox_03.valueChanged.connect(self.on_doubleSpinBox_03_valueChanged) #position_Z connection doubleSpinBox_03 |
|||
self.label = QtGui.QLabel(self.frame) |
|||
self.label.setGeometry(QtCore.QRect(10, 10, 81, 16)) |
|||
self.label.setObjectName(_fromUtf8("label")) |
|||
self.label_2 = QtGui.QLabel(self.frame) |
|||
self.label_2.setGeometry(QtCore.QRect(12, 40, 81, 20)) |
|||
self.label_2.setObjectName(_fromUtf8("label_2")) |
|||
self.label_3 = QtGui.QLabel(self.frame) |
|||
self.label_3.setGeometry(QtCore.QRect(12, 70, 81, 20)) |
|||
self.label_3.setObjectName(_fromUtf8("label_3")) |
|||
self.frame_2 = QtGui.QFrame(self.centralWidget) |
|||
self.frame_2.setGeometry(QtCore.QRect(10, 120, 241, 101)) |
|||
self.frame_2.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame_2.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame_2.setObjectName(_fromUtf8("frame_2")) |
|||
self.doubleSpinBox_1 = QtGui.QDoubleSpinBox(self.frame_2) |
|||
self.doubleSpinBox_1.setGeometry(QtCore.QRect(120, 10, 111, 22)) |
|||
self.doubleSpinBox_1.setDecimals(7) |
|||
self.doubleSpinBox_1.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_1.setMaximum(9999999.99) |
|||
self.doubleSpinBox_1.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_1.setObjectName(_fromUtf8("doubleSpinBox_1")) |
|||
self.doubleSpinBox_1.setToolTip(u"Stretching Axis X.") |
|||
self.doubleSpinBox_1.valueChanged.connect(self.on_doubleSpinBox_1_valueChanged) #etirement_X connection doubleSpinBox_1 |
|||
self.doubleSpinBox_2 = QtGui.QDoubleSpinBox(self.frame_2) |
|||
self.doubleSpinBox_2.setGeometry(QtCore.QRect(120, 40, 111, 22)) |
|||
self.doubleSpinBox_2.setDecimals(7) |
|||
self.doubleSpinBox_2.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_2.setMaximum(9999999.99) |
|||
self.doubleSpinBox_2.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_2.setObjectName(_fromUtf8("doubleSpinBox_2")) |
|||
self.doubleSpinBox_2.setToolTip(u"Stretching Axis Y.") |
|||
self.doubleSpinBox_2.valueChanged.connect(self.on_doubleSpinBox_2_valueChanged) #etirement_Y connection doubleSpinBox_2 |
|||
self.doubleSpinBox_3 = QtGui.QDoubleSpinBox(self.frame_2) |
|||
self.doubleSpinBox_3.setGeometry(QtCore.QRect(120, 70, 111, 22)) |
|||
self.doubleSpinBox_3.setDecimals(7) |
|||
self.doubleSpinBox_3.setMinimum(-9999999.0) |
|||
self.doubleSpinBox_3.setMaximum(9999999.99) |
|||
self.doubleSpinBox_3.setSingleStep(0.0000001) |
|||
self.doubleSpinBox_3.setObjectName(_fromUtf8("doubleSpinBox_3")) |
|||
self.doubleSpinBox_3.setToolTip(u"Stretching Axis Z.") |
|||
self.doubleSpinBox_3.valueChanged.connect(self.on_doubleSpinBox_3_valueChanged) #etirement_Z connection doubleSpinBox_3 |
|||
self.label_4 = QtGui.QLabel(self.frame_2) |
|||
self.label_4.setGeometry(QtCore.QRect(10, 10, 101, 16)) |
|||
self.label_4.setObjectName(_fromUtf8("label_4")) |
|||
self.label_5 = QtGui.QLabel(self.frame_2) |
|||
self.label_5.setGeometry(QtCore.QRect(10, 40, 101, 16)) |
|||
self.label_5.setObjectName(_fromUtf8("label_5")) |
|||
self.label_6 = QtGui.QLabel(self.frame_2) |
|||
self.label_6.setGeometry(QtCore.QRect(10, 70, 81, 16)) |
|||
self.label_6.setObjectName(_fromUtf8("label_6")) |
|||
self.frame_3 = QtGui.QFrame(self.centralWidget) |
|||
self.frame_3.setGeometry(QtCore.QRect(10, 230, 241, 61)) |
|||
self.frame_3.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame_3.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame_3.setObjectName(_fromUtf8("frame_3")) |
|||
self.label_7 = QtGui.QLabel(self.frame_3) |
|||
self.label_7.setGeometry(QtCore.QRect(10, 30, 101, 16)) |
|||
self.label_7.setObjectName(_fromUtf8("label_7")) |
|||
self.checkBox_5 = QtGui.QCheckBox(self.frame_3) |
|||
self.checkBox_5.setGeometry(QtCore.QRect(120, 10, 81, 20)) |
|||
sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) |
|||
sizePolicy.setHorizontalStretch(0) |
|||
sizePolicy.setVerticalStretch(0) |
|||
sizePolicy.setHeightForWidth(self.checkBox_5.sizePolicy().hasHeightForWidth()) |
|||
self.checkBox_5.setSizePolicy(sizePolicy) |
|||
self.checkBox_5.setBaseSize(QtCore.QSize(0, 0)) |
|||
self.checkBox_5.setLayoutDirection(QtCore.Qt.LeftToRight) |
|||
self.checkBox_5.setAutoFillBackground(False) |
|||
self.checkBox_5.setObjectName(_fromUtf8("checkBox_5")) |
|||
self.checkBox_5.setToolTip(u"Raw mode 256 colors or 19 colors") |
|||
self.checkBox_5.clicked.connect(self.on_checkBox_5_clicked) #connection checkBox_5 mode brut |
|||
self.checkBox_6 = QtGui.QCheckBox(self.frame_3) |
|||
self.checkBox_6.setGeometry(QtCore.QRect(120, 30, 61, 20)) |
|||
self.checkBox_6.setObjectName(_fromUtf8("checkBox_6")) |
|||
self.checkBox_6.setToolTip(u"Capping color White or Black") |
|||
self.checkBox_6.clicked.connect(self.on_checkBox_6_clicked) #connection checkBox_6 mode W or B |
|||
self.label_8 = QtGui.QLabel(self.frame_3) |
|||
self.label_8.setGeometry(QtCore.QRect(10, 10, 71, 16)) |
|||
self.label_8.setObjectName(_fromUtf8("label_8")) |
|||
self.spinBox = QtGui.QSpinBox(self.frame_3) |
|||
self.spinBox.setGeometry(QtCore.QRect(180, 30, 51, 22)) |
|||
self.spinBox.setMinimum(0) |
|||
self.spinBox.setMaximum(19) |
|||
self.spinBox.setValue(19) |
|||
# self.spinBox.setProperty("value", 19) |
|||
self.spinBox.setObjectName(_fromUtf8("spinBox")) |
|||
self.spinBox.setToolTip(u"Capping [0 to 19 (black) 19 to 0 (white) normal mode] or [0 to 255 (black) 255 to 0 (white) Raw mode]") |
|||
self.spinBox.valueChanged.connect(self.on_spinBox_valueChanged) # ecreter connection spinBox |
|||
self.frame_4 = QtGui.QFrame(self.centralWidget) |
|||
self.frame_4.setGeometry(QtCore.QRect(10, 300, 241, 61)) |
|||
self.frame_4.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame_4.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame_4.setObjectName(_fromUtf8("frame_4")) |
|||
self.radioButton_3 = QtGui.QRadioButton(self.frame_4) |
|||
self.radioButton_3.setGeometry(QtCore.QRect(10, 10, 95, 20)) |
|||
self.radioButton_3.setChecked(True) |
|||
self.radioButton_3.setObjectName(_fromUtf8("radioButton_3")) |
|||
self.radioButton_3.setToolTip(u"Make a Wire") |
|||
self.radioButton_3.clicked.connect(self.on_radioButton_3_clicked) #connection radioButton_3 type makeWire |
|||
self.radioButton_4 = QtGui.QRadioButton(self.frame_4) |
|||
self.radioButton_4.setGeometry(QtCore.QRect(140, 10, 95, 20)) |
|||
self.radioButton_4.setObjectName(_fromUtf8("radioButton_4")) |
|||
self.radioButton_4.setToolTip(u"Make a BSpline") |
|||
self.radioButton_4.clicked.connect(self.on_radioButton_4_clicked) #connection radioButton_4 type BSpline |
|||
self.checkBox_4 = QtGui.QCheckBox(self.frame_4) |
|||
self.checkBox_4.setGeometry(QtCore.QRect(140, 30, 81, 20)) |
|||
self.checkBox_4.setObjectName(_fromUtf8("checkBox_4")) |
|||
self.checkBox_4.setEnabled(False) |
|||
self.checkBox_4.setToolTip(u"To display items in mode photo with shade of gray 19 or 256 shades of gray if Raw mode is set 255") |
|||
self.checkBox_4.clicked.connect(self.on_checkBox_4_clicked) #connection checkBox_4 nuance |
|||
self.radioButton_2 = QtGui.QRadioButton(self.frame_4) |
|||
self.radioButton_2.setGeometry(QtCore.QRect(10, 30, 95, 20)) |
|||
self.radioButton_2.setObjectName(_fromUtf8("radioButton_2")) |
|||
self.radioButton_2.setToolTip(u"Make a Point (the procedure can be long)") |
|||
self.radioButton_2.clicked.connect(self.on_radioButton_2_clicked) #connection radioButton_2 mode point |
|||
self.frame_6 = QtGui.QFrame(self.centralWidget) |
|||
self.frame_6.setGeometry(QtCore.QRect(10, 370, 111, 81)) |
|||
self.frame_6.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame_6.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame_6.setObjectName(_fromUtf8("frame_6")) |
|||
self.checkBox_1 = QtGui.QCheckBox(self.frame_6) |
|||
self.checkBox_1.setGeometry(QtCore.QRect(10, 10, 111, 20)) |
|||
self.checkBox_1.setObjectName(_fromUtf8("checkBox_1")) |
|||
self.checkBox_1.setToolTip(u"Inversion coordinate X") |
|||
self.checkBox_1.clicked.connect(self.on_checkBox_1_clicked) #connection checkBox_1 X |
|||
self.checkBox_2 = QtGui.QCheckBox(self.frame_6) |
|||
self.checkBox_2.setGeometry(QtCore.QRect(10, 30, 111, 20)) |
|||
self.checkBox_2.setObjectName(_fromUtf8("checkBox_2")) |
|||
self.checkBox_2.setToolTip(u"Inversion coordinate Y") |
|||
self.checkBox_2.clicked.connect(self.on_checkBox_2_clicked) #connection checkBox_2 Y |
|||
self.checkBox_3 = QtGui.QCheckBox(self.frame_6) |
|||
self.checkBox_3.setGeometry(QtCore.QRect(10, 50, 101, 20)) |
|||
self.checkBox_3.setObjectName(_fromUtf8("checkBox_3")) |
|||
self.checkBox_3.setToolTip(u"Inversion coordinate Z") |
|||
self.checkBox_3.clicked.connect(self.on_checkBox_3_clicked) #connection checkBox_3 Z |
|||
# section progressBar 1 |
|||
self.PBA_progressBar = QtGui.QProgressBar(self.centralWidget) # |
|||
self.PBA_progressBar.setGeometry(QtCore.QRect(10, 480, 241, 12)) |
|||
self.PBA_progressBar.setValue(0) |
|||
self.PBA_progressBar.setVisible(True) |
|||
self.PBA_progressBar.setOrientation(QtCore.Qt.Horizontal) |
|||
self.PBA_progressBar.setAlignment(QtCore.Qt.AlignCenter) |
|||
self.PBA_progressBar.setObjectName(_fromUtf8("PBA_progressBar")) |
|||
# self.PBA_progressBar.setToolTip(_translate("MainWindow", " ", None)) |
|||
====32 bit Mode==== <!--T:49--> |
|||
self.pushButton = QtGui.QPushButton(self.centralWidget) |
|||
self.pushButton.setGeometry(QtCore.QRect(10, 500, 113, 28)) |
|||
self.pushButton.setObjectName(_fromUtf8("pushButton")) |
|||
self.pushButton.setToolTip(u"Load the file and launch the process") |
|||
self.pushButton.clicked.connect(self.on_pushButton_En_clicked) # load file |
|||
self.pushButton_2 = QtGui.QPushButton(self.centralWidget) |
|||
self.pushButton_2.setGeometry(QtCore.QRect(140, 500, 113, 28)) |
|||
self.pushButton_2.setObjectName(_fromUtf8("pushButton_2")) |
|||
self.pushButton_2.setToolTip(u"Quit FCTexture") |
|||
self.pushButton_2.clicked.connect(self.on_pushButton_Quit_clicked) # quit |
|||
self.label_9 = QtGui.QLabel(self.centralWidget) |
|||
self.label_9.setGeometry(QtCore.QRect(10, 460, 241, 16)) |
|||
self.label_9.setObjectName(_fromUtf8("label_9")) |
|||
self.frame_7 = QtGui.QFrame(self.centralWidget) |
|||
self.frame_7.setGeometry(QtCore.QRect(140, 370, 111, 80)) |
|||
self.frame_7.setFrameShape(QtGui.QFrame.Box) |
|||
self.frame_7.setFrameShadow(QtGui.QFrame.Raised) |
|||
self.frame_7.setObjectName(_fromUtf8("frame_7")) |
|||
self.radioButton_5 = QtGui.QRadioButton(self.frame_7) |
|||
self.radioButton_5.setGeometry(QtCore.QRect(10, 10, 95, 20)) |
|||
self.radioButton_5.setChecked(True) |
|||
self.radioButton_5.setObjectName(_fromUtf8("radioButton_5")) |
|||
self.radioButton_5.setToolTip(u"The photo mode is automatically activated when a 32-bit image is detected. (the procedure can be long)") |
|||
self.radioButton_5.clicked.connect(self.on_radioButton_5_clicked) #connection radioButton_5 Photo |
|||
self.radioButton_6 = QtGui.QRadioButton(self.frame_7) |
|||
self.radioButton_6.setGeometry(QtCore.QRect(10, 30, 95, 20)) |
|||
self.radioButton_6.setObjectName(_fromUtf8("radioButton_6")) |
|||
self.radioButton_6.setToolTip(u"The plan mode is possible when a 32-bit image and ignore the background of the plan. (the procedure can be long)") |
|||
self.radioButton_6.clicked.connect(self.on_radioButton_6_clicked) #connection radioButton_6 Plan |
|||
MainWindow.setCentralWidget(self.centralWidget) |
|||
self.retranslateUi(MainWindow) |
|||
QtCore.QMetaObject.connectSlotsByName(MainWindow) |
|||
def retranslateUi(self, MainWindow): |
|||
MainWindow.setWindowTitle("FCTexture") |
|||
try: |
|||
MainWindow.setWindowFlags(PyQt4.QtCore.Qt.WindowStaysOnTopHint) # PyQt4 cette fonction met la fenêtre en avant |
|||
except Exception: |
|||
MainWindow.setWindowFlags(PySide.QtCore.Qt.WindowStaysOnTopHint) # PySide cette fonction met la fenêtre en avant |
|||
self.label.setText("Coordinate X") |
|||
self.label_2.setText("Coordinate Y") |
|||
self.label_3.setText("Coordinate Z") |
|||
self.label_6.setText("Stretching Z") |
|||
self.label_4.setText("Stretching X") |
|||
self.label_5.setText("Stretching Y") |
|||
self.label_7.setText("Capping") |
|||
self.radioButton_2.setText("Point") |
|||
self.radioButton_4.setText("BSpline") |
|||
self.radioButton_3.setText("Wire") |
|||
self.checkBox_1.setText("Inversion X") |
|||
self.checkBox_2.setText("Inversion Y") |
|||
self.checkBox_3.setText("Inversion Z") |
|||
self.radioButton_5.setText("Photo") |
|||
self.radioButton_6.setText("Plan") |
|||
self.checkBox_4.setText("Nuance") |
|||
self.checkBox_5.setText("19") |
|||
self.checkBox_6.setText("White") |
|||
self.label_8.setText("Raw mode") |
|||
self.pushButton.setText("File and launch") |
|||
self.pushButton_2.setText("Quit") |
|||
self.label_9.setText("File :") |
|||
self.label_9.setToolTip(u"Gives informations about the file (Bits_pixel, Size data, Length, Height)") |
|||
def on_doubleSpinBox_01_valueChanged(self,value): # connection doubleSpinBox_01 Coordinate X |
|||
global position_X |
|||
position_X = value |
|||
def on_doubleSpinBox_02_valueChanged(self,value): # connection doubleSpinBox_02 Coordinate Y |
|||
global position_Y |
|||
position_Y = value |
|||
def on_doubleSpinBox_03_valueChanged(self,value): # connection doubleSpinBox_03 Coordinate Z |
|||
global position_Z |
|||
position_Z = value |
|||
def on_doubleSpinBox_1_valueChanged(self,value): # connection doubleSpinBox_1 Stretching X |
|||
global etirement_X |
|||
etirement_X = value |
|||
def on_doubleSpinBox_2_valueChanged(self,value): # connection doubleSpinBox_2 Stretching Y |
|||
global etirement_Y |
|||
etirement_Y = value |
|||
def on_doubleSpinBox_3_valueChanged(self,value): # connection doubleSpinBox_3 Stretching Z |
|||
global etirement_Z |
|||
etirement_Z = value |
|||
def on_checkBox_5_clicked(self): # if checked mode brut |
|||
global modeBrut |
|||
global ecreter |
|||
if self.checkBox_5.isChecked(): |
|||
modeBrut = 1 # if checked mode brut = 255 colors |
|||
self.spinBox.setMaximum(255) |
|||
self.checkBox_5.setText("255") |
|||
if self.checkBox_6.isChecked(): # if Black |
|||
self.spinBox.setValue(0) |
|||
ecreter = 0 |
|||
else: |
|||
self.spinBox.setValue(255) |
|||
ecreter = 255 |
|||
else: |
|||
modeBrut = 0 # if nochecked White mode brut = 19 colors |
|||
self.spinBox.setMaximum(19) |
|||
self.checkBox_5.setText("19") |
|||
if self.checkBox_6.isChecked(): # if Black |
|||
self.spinBox.setValue(0) |
|||
ecreter = 0 |
|||
else: |
|||
self.spinBox.setValue(19) # if White |
|||
ecreter = 19 |
|||
<!--T:35--> |
|||
def on_checkBox_6_clicked(self): # if checked ecreter Black else White |
|||
* {{RadioButton|TRUE|Photo}}: photo mode is automatically activated when a '''32-bit image''' is detected. (Note: this procedure is CPU intensive) |
|||
global modeColor |
|||
* {{RadioButton|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) |
|||
global ecreter |
|||
if self.checkBox_6.isChecked(): |
|||
modeColor = 1 # if checked mode Black |
|||
self.checkBox_6.setText("Black") |
|||
self.spinBox.setValue(0) |
|||
self.spinBox.setObjectName(_fromUtf8("spinBox")) |
|||
else: |
|||
modeColor = 0 # if nochecked mode White |
|||
self.checkBox_6.setText("White") |
|||
if self.checkBox_5.isChecked(): |
|||
self.spinBox.setValue(255) |
|||
else: |
|||
self.spinBox.setValue(19) |
|||
def on_spinBox_valueChanged(self,value): # ecreter |
|||
global ecreter |
|||
ecreter = value |
|||
def on_radioButton_3_clicked(self): # if checked then 0=makeWire N/B |
|||
global typeligne |
|||
global avecLigne |
|||
typeligne = 0 |
|||
avecLigne = 1 |
|||
self.checkBox_4.setChecked(False) |
|||
self.checkBox_4.setEnabled(False) |
|||
def on_radioButton_4_clicked(self): # if no checked then 1=BSpline N/B |
|||
global typeligne |
|||
global avecLigne |
|||
typeligne = 1 |
|||
avecLigne = 1 |
|||
self.checkBox_4.setChecked(False) |
|||
self.checkBox_4.setEnabled(False) |
|||
def on_radioButton_2_clicked(self): # if checked then mode point N/B |
|||
global avecLigne |
|||
avecLigne = 0 |
|||
self.checkBox_4.setEnabled(True) |
|||
def on_checkBox_1_clicked(self): # if checked inverse X |
|||
global inversion_X |
|||
if self.checkBox_1.isChecked(): |
|||
inversion_X = 1 |
|||
else: |
|||
inversion_X = 0 |
|||
def on_checkBox_2_clicked(self): # if checked inverse X |
|||
global inversion_Y |
|||
if self.checkBox_2.isChecked(): |
|||
inversion_Y = 1 |
|||
else: |
|||
inversion_Y = 0 |
|||
def on_checkBox_3_clicked(self): # if checked inverse X |
|||
global inversion_Z |
|||
if self.checkBox_3.isChecked(): |
|||
inversion_Z = 1 |
|||
else: |
|||
inversion_Z = 0 |
|||
def on_radioButton_5_clicked(self): # if checked then Photo colors |
|||
global plan |
|||
plan = 0 |
|||
def on_radioButton_6_clicked(self): # if checked then Plan colors |
|||
global plan |
|||
global modeBrut |
|||
global ecreter |
|||
plan = 1 |
|||
modeBrut = 1 # if checked mode brut = 255 colors |
|||
ecreter = 255 |
|||
self.spinBox.setObjectName(_fromUtf8("spinBox")) |
|||
self.spinBox.setMaximum(255) |
|||
self.spinBox.setValue(255) |
|||
self.checkBox_6.setText("White") |
|||
self.checkBox_5.setText("255") |
|||
self.checkBox_5.setChecked(True) |
|||
FreeCAD.Console.PrintMessage("checkBox_5 ecreter : "+str(ecreter)+"\n") # ici |
|||
====File==== <!--T:50--> |
|||
def on_checkBox_4_clicked(self): # if checked fond Black else White |
|||
global nuance |
|||
if self.checkBox_4.isChecked(): |
|||
nuance = 1 # if checked Nuance ok |
|||
else: |
|||
nuance = 0 # if nochecked Nuance Ko |
|||
def on_pushButton_Quit_clicked(self): |
|||
FreeCAD.Console.PrintMessage("Terminé"+"\n") |
|||
self.window.hide() |
|||
def on_pushButton_En_clicked(self): |
|||
global position_X |
|||
global position_Y |
|||
global position_Z |
|||
global etirement_X |
|||
global etirement_Y |
|||
global etirement_Z |
|||
global modeBrut |
|||
global modeColor |
|||
global ecreter |
|||
global typeligne |
|||
global avecLigne |
|||
global inversion_X |
|||
global inversion_Y |
|||
global inversion_Z |
|||
global plan |
|||
global fond |
|||
global bits_pixel |
|||
global tailleDonnees |
|||
# Configuration FCTexture |
|||
# FreeCAD.Console.PrintMessage("position_X : "+str(position_X)+"\n") |
|||
# FreeCAD.Console.PrintMessage("position_Y : "+str(position_Y)+"\n") |
|||
# FreeCAD.Console.PrintMessage("position_Z : "+str(position_Z)+"\n") |
|||
# FreeCAD.Console.PrintMessage("etirement_X : "+str(etirement_X)+"\n") |
|||
# FreeCAD.Console.PrintMessage("etirement_Y : "+str(etirement_Y)+"\n") |
|||
# FreeCAD.Console.PrintMessage("etirement_Z : "+str(etirement_Z)+"\n") |
|||
# FreeCAD.Console.PrintMessage("ecreter : "+str(ecreter)+"\n") |
|||
# FreeCAD.Console.PrintMessage("wire : "+str(avecLigne)+"\n") |
|||
# FreeCAD.Console.PrintMessage("typeligne : "+str(typeligne)+"\n") |
|||
# FreeCAD.Console.PrintMessage("point : "+str(avecLigne)+"\n") |
|||
# FreeCAD.Console.PrintMessage("inversion_X : "+str(inversion_X)+"\n") |
|||
# FreeCAD.Console.PrintMessage("inversion_Y : "+str(inversion_Y)+"\n") |
|||
# FreeCAD.Console.PrintMessage("inversion_Z : "+str(inversion_Z)+"\n") |
|||
# FreeCAD.Console.PrintMessage("plan : "+str(plan)+"\n") |
|||
# FreeCAD.Console.PrintMessage("fond : "+str(fond)+"\n") |
|||
doc = FreeCAD.ActiveDocument |
|||
if doc == None: |
|||
doc = FreeCAD.newDocument() |
|||
<!--T:36--> |
|||
self.pushButton.setStyleSheet("background-color: QPalette.Base") # origin system |
|||
* {{CheckBox|.pcd}}: if checked, a file (originalName.bmp.pcd) is saved in the same directory of the file (pcd v0.7). |
|||
self.label_9.setText("File :") |
|||
* {{CheckBox|.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). |
|||
OpenName = "" |
|||
try: |
|||
OpenName = QFileDialog.getOpenFileName(None,QString.fromLocal8Bit("Read an image file"),path,"*.Bmp") # PyQt4 |
|||
except Exception: |
|||
OpenName, Filter = PySide.QtGui.QFileDialog.getOpenFileName(None, "Read an image file", path, "*.Bmp")#PySide |
|||
try: |
|||
if OpenName != "": |
|||
depart = time.clock() |
|||
FreeCAD.Console.PrintMessage("Read the file "+OpenName+"\n") |
|||
f = open(OpenName, "rb") |
|||
length = os.path.getsize(OpenName) |
|||
# decode header file |
|||
bytes = f.read(2)# Signature du fichier. BM=Bitmap windows, BA= Bitmap |
|||
# FreeCAD.Console.PrintMessage(str(bytes[0]) + str(bytes[1])+"\n") |
|||
bytes = f.read(4)# Taille totale du fichier en octets |
|||
bytes = f.read(4)# Champ réservé |
|||
bytes = f.read(4)# Adresse de la zone de définition de l’image |
|||
adresse = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(adresse)+" adresse "+"\n") |
|||
bytes = f.read(4)# Taille en octets de l'en-tête BITMAPINFOHEADER |
|||
entete = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(entete)+" entete "+"\n") |
|||
bytes = f.read(4)# Largeur de l’image en pixels |
|||
Largeur = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(Largeur)+" Largeur "+"\n") |
|||
bytes = f.read(4)# Hauteur de l’image en pixels |
|||
hauteur = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(hauteur)+" hauteur "+"\n") |
|||
bytes = f.read(2)# Nombre de plans |
|||
plans = decobit(bytes[0],bytes[1]) |
|||
# FreeCAD.Console.PrintMessage(str(plans)+" plans "+"\n") |
|||
bytes = f.read(2)# Nombre de bits par pixel |
|||
bits_pixel = decobit(bytes[0],bytes[1]) |
|||
FreeCAD.Console.PrintMessage(str(bits_pixel)+" bits_pixel "+"\n") |
|||
bytes = f.read(4)# Type de compression : 0=pas de compression,1=compressé à 8 bits par pixel, 2=4bits par pixel. |
|||
bytes = f.read(4)# Taille en octets des données de l’image |
|||
tailleDonnees = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(tailleDonnees)+" tailleDonnees "+"\n") |
|||
bytes = f.read(4)# Résolution horizontale en pixels par mètre |
|||
bytes = f.read(4)# Résolution verticale en pixels par mètre |
|||
bytes = f.read(4)# Nombre de couleurs dans l’image : 0=maximum possible. Si une palette est utilisée, ce nombre indique le nombre de couleurs de la palette |
|||
couleurs = decobit(bytes[0],bytes[1],bytes[2],bytes[3]) |
|||
# FreeCAD.Console.PrintMessage(str(couleurs)+" couleurs "+"\n") |
|||
bytes = f.read(4)# Nombre de couleurs importantes. 0= toutes importantes |
|||
self.label_9.setText("File: "+str(bits_pixel)+":bits " +str(tailleDonnees)+":data ("+str(Largeur)+" x "+str(hauteur)+")") |
|||
Gui.updateGui() # rafraichi l'ecran |
|||
f.seek(adresse, 0) # seek(position, 0=defaut 1=à la position courante 2=à partir de la fin du fichier) |
|||
coor_X = 0.0 |
|||
coor_Y = 0.0 |
|||
coor_Z = 0.0 |
|||
###########256 couleurs début##################################### |
|||
if couleurs == 256: |
|||
completion = Largeur % 4 |
|||
ii = 0 |
|||
pnts = [] |
|||
points = [] |
|||
del pnts[:] |
|||
del points[:] |
|||
self.PBA_progressBar.setMaximum(tailleDonnees) |
|||
====Capping (10mm)==== <!--T:51--> |
|||
for Y in range(tailleDonnees): |
|||
self.PBA_progressBar.setValue(Y) |
|||
<!--T:37--> |
|||
ii += 1 |
|||
* Slider: Enter the height of the form. The height is displayed on title frame. |
|||
try: |
|||
* {{SpinBox|0 height}}: Enter the height of the form. The height is displayed on title frame. |
|||
bytes = ord(f.read(1)) |
|||
* Raw mode {{CheckBox|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). |
|||
pnts.append(str(bytes)) |
|||
* {{CheckBox}}: this option enables the ability to access the Contour spinbox |
|||
except: |
|||
* {{SpinBox|0/2 Contour}}: this spinbox gives the contour line. do not use (ex: 0 for the base). |
|||
None |
|||
* Capping {{CheckBox|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). |
|||
try: |
|||
* {{SpinBox|20 Capping}}: this spinbox gives the degrees of capping. |
|||
if ((ii % Largeur) == 0) and (completion > 0): |
|||
if completion == 3: |
|||
bytes = (f.read(1)) |
|||
Y += 1 |
|||
elif completion == 2: |
|||
bytes = (f.read(2)) |
|||
Y += 2 |
|||
elif completion == 1: |
|||
bytes = (f.read(3)) |
|||
Y += 3 |
|||
ii = 0 |
|||
except: |
|||
None |
|||
f.close() |
|||
ii = 0 |
|||
====Command==== <!--T:52--> |
|||
self.PBA_progressBar.setMaximum(hauteur) |
|||
for Y in range(hauteur): |
|||
self.PBA_progressBar.setValue(Y) |
|||
for X in range(Largeur): |
|||
<!--T:13--> |
|||
if X > Largeur: |
|||
* {{Button|File and launch}}: opens the image file and launches the conversion. |
|||
del points[:] |
|||
* {{Button|Help}}: |
|||
else: |
|||
**Display the Wiki page in the FreeCAD browser |
|||
if modeBrut == 0: |
|||
**For change the parameter disponible: go to '''Tools → Edit parameter...''' |
|||
if float(pnts[ii]) > 225: # 19 Filter |
|||
**__The global step on spinBox:__ |
|||
pnts[ii] = "10" |
|||
**User parameter:'''BaseApp/Preferences/Macros/FCMmacros/FCTexture → SingleStep''' |
|||
elif float(pnts[ii]) > 212: # 18 |
|||
**Adjust the value desired (1.0 by default) |
|||
pnts[ii] = "9.5" |
|||
**__For search if the macro is upgraded :__ |
|||
elif float(pnts[ii]) > 200: # 17 |
|||
**User parameter:'''BaseApp/Preferences/Macros/FCMmacros/FCTexture → switchVesionMacroSearch''' |
|||
pnts[ii] = "9" |
|||
**Adjust the switchVesionMacroSearch to {{TRUE}} ({{FALSE}} by default) |
|||
elif float(pnts[ii]) > 187: # 16 |
|||
pnts[ii] = "8.5" |
|||
elif float(pnts[ii]) > 175: # 15 |
|||
pnts[ii] = "8" |
|||
elif float(pnts[ii]) > 162: # 14 |
|||
pnts[ii] = "7.5" |
|||
elif float(pnts[ii]) > 150: # 13 |
|||
pnts[ii] = "7" |
|||
elif float(pnts[ii]) > 137: # 12 |
|||
pnts[ii] = "6.5" |
|||
elif float(pnts[ii]) > 125: # 11 |
|||
pnts[ii] = "6" |
|||
elif float(pnts[ii]) > 112: # 10 |
|||
pnts[ii] = "5.5" |
|||
elif float(pnts[ii]) > 100: # 9 |
|||
pnts[ii] = "5" |
|||
elif float(pnts[ii]) > 87: # 8 |
|||
pnts[ii] = "4.5" |
|||
elif float(pnts[ii]) > 75: # 7 |
|||
pnts[ii] = "4" |
|||
elif float(pnts[ii]) > 62: # 6 |
|||
pnts[ii] = "3.5" |
|||
elif float(pnts[ii]) > 50: # 5 |
|||
pnts[ii] = "3" |
|||
elif float(pnts[ii]) > 37: # 4 |
|||
pnts[ii] = "2.5" |
|||
elif float(pnts[ii]) > 25: # 3 |
|||
pnts[ii] = "2" |
|||
elif float(pnts[ii]) > 12: # 2 |
|||
pnts[ii] = "1.5" |
|||
elif float(pnts[ii]) > 1: # 1 |
|||
pnts[ii] = "1" |
|||
else : |
|||
pnts[ii] = "0" # 0 |
|||
if modeBrut == 0: # ecreter 19 colors |
|||
if modeColor == 0: |
|||
if float(pnts[ii]) > ((ecreter + 1) / 2): # ecreter White |
|||
pnts[ii] = str((ecreter + 1) / 2) |
|||
else: |
|||
if float(pnts[ii]) < ((ecreter + 1) / 2): # ecreter Black |
|||
pnts[ii] = str((ecreter + 1) / 2) |
|||
else: # ecreter 255 colors |
|||
if modeColor == 0: |
|||
if float(pnts[ii]) > ecreter: # ecreter White |
|||
pnts[ii] = str(ecreter) |
|||
else: |
|||
if float(pnts[ii]) < ecreter: # ecreter Black |
|||
pnts[ii] = str(ecreter) |
|||
coor_X = (X * etirement_X) + position_X |
|||
coor_Y = (Y * etirement_Y) + position_Y |
|||
coor_Z = (float(pnts[ii]) * etirement_Z) + position_Z |
|||
if inversion_X > 0: |
|||
coor_X = (-coor_X) |
|||
if inversion_Y > 0: |
|||
coor_Y = (-coor_Y) |
|||
if inversion_Z > 0: |
|||
coor_Z = (-coor_Z) |
|||
try: |
|||
if avecLigne == 1: # 0=point 1=Ligne |
|||
points += [FreeCAD.Vector(coor_X,coor_Y,coor_Z)] |
|||
else: |
|||
if nuance == 1: # 1 = nuance |
|||
a = Draft.makePoint(coor_X,coor_Y,coor_Z) |
|||
FreeCADGui.activeDocument().getObject(a.Label).PointColor = (coor_Z*0.00392157,coor_Z*0.00392157,coor_Z*0.00392157) |
|||
else: |
|||
Draft.makePoint(coor_X,coor_Y,coor_Z) |
|||
except: |
|||
FreeCAD.Console.PrintError("Not ActiveDocument detected "+"\n") #errorDialog("Not ActiveDocument detected") |
|||
break |
|||
ii += 1 |
|||
try: |
|||
if avecLigne == 1: |
|||
if typeligne == 0: # 0=makeWire |
|||
Draft.makeWire(points,closed=False,face=False,support=None) |
|||
else: |
|||
Draft.makeBSpline(points,closed=False) # 0=makeBSpline |
|||
except: |
|||
FreeCAD.Console.PrintError("Not ActiveDocument detected "+"\n") #errorDialog("Not ActiveDocument detected") |
|||
break |
|||
del points[:] |
|||
##256 couleurs fin##################################### |
|||
# |
|||
###########16 millions couleurs debut########################### |
|||
elif bits_pixel == 32: #if couleurs == 0: # 16 millions couleurs pour 32 bits mode 1 bit |
|||
if adresse == 138: # mode 2 bits |
|||
bytes = (f.read(1)) |
|||
completion = Largeur % 4 |
|||
ii = 0 |
|||
ic = 0 |
|||
r_color = 0.0 |
|||
v_color = 0.0 |
|||
b_color = 0.0 |
|||
pnts = [] |
|||
points = [] |
|||
del pnts[:] |
|||
del points[:] |
|||
self.PBA_progressBar.setMaximum(tailleDonnees) |
|||
for Y in range(tailleDonnees): |
|||
self.PBA_progressBar.setValue(Y) |
|||
<!--T:38--> |
|||
ii = 0 |
|||
* {{Button|Quit}}: exits the function. |
|||
for ic in range(3): |
|||
ii += 1 |
|||
try: |
|||
bytes = ord(f.read(1)) |
|||
pnts.append(str(bytes)) |
|||
except: |
|||
None |
|||
f.read(1) |
|||
ii += 1 |
|||
try: |
|||
if ((ii % Largeur) == 0) and (completion > 0): |
|||
if completion == 3: |
|||
bytes = ord(f.read(1)) |
|||
Y += 1 |
|||
elif completion == 2: |
|||
bytes = ord(f.read(2)) |
|||
Y += 2 |
|||
elif completion == 1: |
|||
bytes = ord(f.read(3)) |
|||
Y += 3 |
|||
except: |
|||
None |
|||
f.close() |
|||
ii = 0 |
|||
self.PBA_progressBar.setMaximum(hauteur) |
|||
for Y in range(hauteur): |
|||
self.PBA_progressBar.setValue(Y) |
|||
==Script== <!--T:14--> |
|||
for X in range(Largeur): |
|||
<!--T:25--> |
|||
The icons .png [[Image:FCTexture.png|64px]] and .svg[[Image:FCTexture.svg|64px]] |
|||
<!--T:28--> |
|||
'''Macro_Texture.FCMacro''' |
|||
<!--T:29--> |
|||
Download the macro to Gist [https://gist.github.com/mario52a/262317bc7d8555885b0e Macro FCTexture.FCMacro] |
|||
if X > Largeur: |
|||
del points[:] |
|||
else: |
|||
coor_X = (X * etirement_X) + position_X |
|||
coor_Y = (Y * etirement_Y) + position_Y |
|||
coor_Z = ( etirement_Z) + position_Z |
|||
if inversion_X > 0: |
|||
coor_X = (-coor_X) |
|||
if inversion_Y > 0: |
|||
coor_Y = (-coor_Y) |
|||
if inversion_Z > 0: |
|||
coor_Z = (-coor_Z) |
|||
b_color = float(pnts[ii])*0.00392157 |
|||
ii += 1 |
|||
v_color = float(pnts[ii])*0.00392157 |
|||
ii += 1 |
|||
r_color = float(pnts[ii])*0.00392157 |
|||
ii += 1 |
|||
try: |
|||
if plan == 0: # 0=Photo |
|||
a = Draft.makePoint(coor_X,coor_Y,coor_Z) # ok pour 32 bits mode |
|||
FreeCADGui.activeDocument().getObject(a.Label).PointColor = (r_color,v_color,b_color) |
|||
else: # 1=Plan |
|||
if modeColor == 0: # white background |
|||
if (r_color < (ecreter*0.00392157)) and (r_color < (ecreter*0.00392157)) and (r_color < (ecreter*0.00392157)): # ecreter White |
|||
a = Draft.makePoint(coor_X,coor_Y,coor_Z) |
|||
FreeCADGui.activeDocument().getObject(a.Label).PointColor = (r_color,v_color,b_color) |
|||
else: # black background |
|||
if (r_color > (ecreter*0.00392157)) and (r_color > (ecreter*0.00392157)) and (r_color > (ecreter*0.00392157)): # ecreter Black |
|||
a = Draft.makePoint(coor_X,coor_Y,coor_Z) |
|||
FreeCADGui.activeDocument().getObject(a.Label).PointColor = (r_color,v_color,b_color) |
|||
except: |
|||
FreeCAD.Console.PrintError("Not ActiveDocument detected "+"\n") |
|||
break |
|||
del points[:] |
|||
###########16 millions couleurs fin##################################### |
|||
else: |
|||
FreeCAD.Console.PrintError("Bits_pixel "+str(bits_pixel)+" unrecognized format"+"\n") |
|||
arrivee = time.clock() |
|||
self.pushButton.setStyleSheet("background-color: green") # This function gives a color button |
|||
FreeCAD.Console.PrintMessage("Time : "+str("%.2f" % ((arrivee - depart)/60))+" min"+"\n") |
|||
FreeCAD.Console.PrintMessage("_End FCTexture_____________"+"\n") |
|||
except: |
|||
self.pushButton.setStyleSheet("background-color: red") # This function gives a color button |
|||
FreeCAD.Console.PrintMessage("Error in reading the file "+OpenName+"\n") |
|||
errorDialog(u"Error in reading the file "+OpenName) |
|||
self.PBA_progressBar.setValue(0) |
|||
MainWindow = QtGui.QMainWindow() |
|||
ui = Ui_MainWindow(MainWindow) |
|||
MainWindow.show() |
|||
}} |
|||
<translate> |
|||
==Example== <!--T:15--> |
==Example== <!--T:15--> |
||
Line 992: | Line 155: | ||
</center> |
</center> |
||
<!--T:30--> |
|||
<center> |
|||
<gallery widths="600" heights="300"> |
|||
File:Macro_FCTexture_008b.png|Here with option contour<br /> |
|||
</gallery> |
|||
</center> |
|||
<!--T:23--> |
<!--T:23--> |
||
<center> |
<center> |
||
<gallery widths=" |
<gallery widths="300" heights="200"> |
||
File:Texture Nano Photo.png|Here an example of a bmp image converted to points and restoring picture the width of the image is 6.5 nm<br />[http://forum.freecadweb.org/viewtopic.php?f=24&t=5893#p47075 thanks for the permission of Yorik] |
File:Texture Nano Photo.png|Here an example of a bmp image converted to points and restoring picture the width of the image is 6.5 nm<br />[http://forum.freecadweb.org/viewtopic.php?f=24&t=5893#p47075 thanks for the permission of Yorik] |
||
Image:Texture NanoDesign.png|Here an example of a bmp image converted to object 3D of 6.7 nm width.<br /> [http://forum.freecadweb.org/viewtopic.php?f=24&t=5893#p47075 thanks for the permission of Yorik] |
Image:Texture NanoDesign.png|Here an example of a bmp image converted to object 3D of 6.7 nm width.<br /> [http://forum.freecadweb.org/viewtopic.php?f=24&t=5893#p47075 thanks for the permission of Yorik] |
||
Line 1,002: | Line 171: | ||
<br /> |
<br /> |
||
<center> |
<center> |
||
<gallery widths=" |
<gallery widths="300" heights="200"> |
||
Image:Texture 001 Logo.png|The logo of FreeCAD. |
Image:Texture 001 Logo.png|The logo of FreeCAD. |
||
Image:Texture 002 Fe FC.png|A portion of the screen FreeCAD. The [http://forum.freecadweb.org/viewtopic.php?f=3&t=4708&start=10#p46353 file]. |
Image:Texture 002 Fe FC.png|A portion of the screen FreeCAD. The [http://forum.freecadweb.org/viewtopic.php?f=3&t=4708&start=10#p46353 file]. |
||
Line 1,009: | Line 178: | ||
<br /> |
<br /> |
||
<center> |
<center> |
||
<gallery widths=" |
<gallery widths="300" heights="200"> |
||
Image:Texture_003_napperon.png|A portion of a tablecloth. |
Image:Texture_003_napperon.png|A portion of a tablecloth. |
||
Image:Texture_005_larme.png|A diamond plate. |
Image:Texture_005_larme.png|A diamond plate. |
||
Line 1,035: | Line 204: | ||
<center> |
<center> |
||
<gallery widths="600" heights="600"> |
<gallery widths="600" heights="600"> |
||
File:FCTexture_Example.gif|Procedure for create solid:<br /> '''1:''' Create loft with the [[File:Part_RuledSurface.svg|24px]] tools or with the [[ |
File:FCTexture_Example.gif|Procedure for create solid:<br /> '''1:''' Create loft with the [[File:Part_RuledSurface.svg|24px]] tools or with the [[File:FCCreaLoft.png|32px|FCCreaLoft]] [[Macro_Loft|Macro Loft]]<br /> '''2:''' Select all and extrude with the tools [[File:Part_Extrude.svg|24px]] <br /> '''3A:''' For Linux Download [https://github.com/psicofil/Macros_FreeCAD GMSHMesh] (author psicofil) [[Macro_GMSH|Macro_GMSH Wiki page]] <br /> '''3B:''' For Windows Download [http://forum.freecadweb.org/download/file.php?id=15220 GmshMesh2.zip] unzip the file and install it in your Mod directory (author ulrich1a) <br /> '''4:''' Create your Mesh file and use it |
||
</gallery> |
</gallery> |
||
</center> |
</center> |
||
Line 1,046: | Line 215: | ||
<br /> |
<br /> |
||
==Links== <!--T: |
==Links== <!--T:53--> |
||
<!--T:17--> |
|||
The discussion on [http://forum.freecadweb.org/viewtopic.php?f=24&t=5893 the forum] to give your impressions or contact me. |
The discussion on [http://forum.freecadweb.org/viewtopic.php?f=24&t=5893 the forum] to give your impressions or contact me. |
||
<!--T:27--> |
<!--T:27--> |
||
The macro [[ |
The macro [[File:FCCreaLoft.png|32px|FCCreaLoft]] [[Macro_Loft|Macro Loft]] for automate the multi loft. |
||
<!--T:19--> |
<!--T:19--> |
||
Line 1,059: | Line 230: | ||
==Revision== <!--T:18--> |
==Revision== <!--T:18--> |
||
<!--T:42--> |
|||
*Ver 0.14c : 15-01-2021 include '''Gui.SendMsgToActiveView("ViewFit")''' |
|||
<!--T:20--> |
<!--T:20--> |
||
*Ver 0.14b : 15-01-2021 Create Tab Coordinate and Tab Stretching for diminish the height of the macro and accepted in 15" screen |
|||
<!--T:41--> |
|||
*ver 0.14 : 06/01/2021 change the search path procedure and adding preference option: search the new macro upgraded |
|||
{{Code|code= |
|||
####new2 |
|||
pathFile = os.path.dirname(SaveName) + "/" #= C:/Provisoire400/ |
|||
formatFichier = os.path.splitext(SaveName)[1] #= .png |
|||
SaveName = os.path.splitext(SaveName)[0] #= /home/kubuntu/.FreeCAD/Macro/Texture_007_H #= C:/Provisoire400/image3D |
|||
SaveNameformatFichier = SaveName + formatFichier #= C:/Provisoire400/image3D.png |
|||
####new2 |
|||
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/FCTexture").SetString("Path",pathFile) |
|||
####new |
|||
}} |
|||
*ver 0.13b: 30/12/2020 add try for '''time.clock()''' and '''time.process_time()''' for Python 3xyz... |
|||
*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.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.7 : 03/09/2014 Delete "'''translate'''" forgotten and bug fix discovered by the passage of PyQt to Pyside ! |
||
Line 1,072: | Line 266: | ||
*ver 0.3 : 28/03/2014 :comment out the line "'''# self.checkBox_5.setAccessibleName(_fromUtf8(""))'''" |
*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 |
that causes an error with the version FreeCAD : Version: 0.14.3343 (Git), Python version: 2.7.6, Qt version: 4.8.5 |
||
</translate> |
</translate> |
||
{{clear}} |
|||
<languages/> |
Latest revision as of 02:49, 15 May 2023
Description |
---|
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.14c Last modified: 2021/01/16 FreeCAD version: 0.18 and more Download: ToolBar Icon Author: Mario52 |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
0.14c |
Date last modified |
2021/01/16 |
FreeCAD Version(s) |
0.18 and more |
Default shortcut |
None |
See also |
Macro Loft |
Description
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/3ec2ab127d8ad01a6b657aa5df9a6127ff07c7c0/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/3ec2ab127d8ad01a6b657aa5df9a6127ff07c7c0/Macro%2520FCTexture.FCMacro")
Texture 004 Honda
Usage
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
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 X 0,00 mm : narrowing or enlarging of the X (length) of the object (default: 0)
- Stretching Y 0,00 mm : narrowing or enlarging of the Y (height) of the object (default: 0)
- Stretching Z 0,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)
- Quit: exits the function.
Script
Macro_Texture.FCMacro
Download the macro to Gist Macro FCTexture.FCMacro
Example
The images were inclined to enhance the 3D effect.
-
Honda
-
Here with option contour
-
Here an example of a bmp image converted to points and restoring picture the width of the image is 6.5 nm
thanks for the permission of Yorik -
Here an example of a bmp image converted to object 3D of 6.7 nm width.
thanks for the permission of Yorik
-
The logo of FreeCAD.
-
A portion of the screen FreeCAD. The file.
-
A portion of a tablecloth.
-
A diamond plate.
-
Mode Plan: the image on the left the white background has been ignored in the right image the colour black has been ignored (an example on the forum)
-
Topography from a drawing or each level is represented with a degrees of different color.
-
Image converted in ASCII caracter.
-
Procedure for create solid:
1: Create loft with the tools or with the Macro Loft
2: Select all and extrude with the tools
3A: For Linux Download GMSHMesh (author psicofil) Macro_GMSH Wiki page
3B: For Windows Download GmshMesh2.zip unzip the file and install it in your Mod directory (author ulrich1a)
4: Create your Mesh file and use it
-
Convert solid in mesh with GmshMesh.
Links
The discussion on the forum to give your impressions or contact me.
The macro Macro Loft for automate the multi loft.
How to handle pdf import properly and feasibly?
Revision
- Ver 0.14c : 15-01-2021 include Gui.SendMsgToActiveView("ViewFit")
- Ver 0.14b : 15-01-2021 Create Tab Coordinate and Tab Stretching for diminish the height of the macro and accepted in 15" screen
- ver 0.14 : 06/01/2021 change the search path procedure and adding preference option: search the new macro upgraded
####new2
pathFile = os.path.dirname(SaveName) + "/" #= C:/Provisoire400/
formatFichier = os.path.splitext(SaveName)[1] #= .png
SaveName = os.path.splitext(SaveName)[0] #= /home/kubuntu/.FreeCAD/Macro/Texture_007_H #= C:/Provisoire400/image3D
SaveNameformatFichier = SaveName + formatFichier #= C:/Provisoire400/image3D.png
####new2
FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Macros/FCMmacros/FCTexture").SetString("Path",pathFile)
####new
- ver 0.13b: 30/12/2020 add try for time.clock() and time.process_time() for Python 3xyz...
- 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