Which Macro on which FreeCAD ?
The macro from my post viewtopic.php?f=18&t=12355#p99560 works for me on
OS: Windows 7
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6157 (Git)
Build type: Release
Branch: master
Hash: b6faaefaf8adc81bd2f41aebe7516ccd3cbb50a0
Python version: 2.7.8
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Colorbar macro test
Moderator: bernd
Forum rules
and Helpful information for the FEM forum
and Helpful information for the FEM forum
Re: Colorbar macro test
- Attachments
-
- screen.png (248.9 KiB) Viewed 2231 times
Re: Colorbar macro test
On ubuntu I have problems too:
OS: Ubuntu 15.04
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6188 (Git)
Build type: None
Branch: master
Hash: bf19e80de17454b170cde98df5e4995a7a4991f6
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Code: Select all
Traceback (most recent call last):
File "/home/bhb/.FreeCAD/Mod/Macros/FEM_ColorBAR.FCMacro", line 50, in <module>
ColorMapWidget.setWidget(ColorMap()) # load the Ui script
File "/home/bhb/.FreeCAD/Mod/Macros/FEM_ColorBAR.FCMacro", line 21, in __init__
layout.addWidget(self.canvas)
<type 'exceptions.TypeError'>: 'PySide.QtGui.QBoxLayout.addWidget' called with wrong argument types:
PySide.QtGui.QBoxLayout.addWidget(FigureCanvasQTAgg)
Supported signatures:
PySide.QtGui.QBoxLayout.addWidget(PySide.QtGui.QWidget, int = 0, PySide.QtCore.Qt.Alignment = 0)
Word size of OS: 32-bit
Word size of FreeCAD: 32-bit
Version: 0.16.6188 (Git)
Build type: None
Branch: master
Hash: bf19e80de17454b170cde98df5e4995a7a4991f6
Python version: 2.7.9
Qt version: 4.8.6
Coin version: 4.0.0a
OCC version: 6.8.0.oce-0.17
Re: Colorbar macro test
My version
OS: Ubuntu 14.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6163 (Git)
Build type: None
Branch: master
Hash: 273131c08857464fe7a140331afc864b7ae752f8
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
OS: Ubuntu 14.04.3 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.16.6163 (Git)
Build type: None
Branch: master
Hash: 273131c08857464fe7a140331afc864b7ae752f8
Python version: 2.7.6
Qt version: 4.8.6
Coin version: 4.0.0a
Re: Colorbar macro test
Mhh, the addWidget function needs a QWidget but gets a FigureCanvasQTAgg which is returned from matplotlib.pyplot.figure() It seams on Windows this get converted somehow but on Linux we need to take care of this. I have never been working with matplotlib Anyone an idea how to solve this?bernd wrote:Code: Select all
Traceback (most recent call last): File "/home/bhb/.FreeCAD/Mod/Macros/FEM_ColorBAR.FCMacro", line 50, in <module> ColorMapWidget.setWidget(ColorMap()) # load the Ui script File "/home/bhb/.FreeCAD/Mod/Macros/FEM_ColorBAR.FCMacro", line 21, in __init__ layout.addWidget(self.canvas) <type 'exceptions.TypeError'>: 'PySide.QtGui.QBoxLayout.addWidget' called with wrong argument types: PySide.QtGui.QBoxLayout.addWidget(FigureCanvasQTAgg) Supported signatures: PySide.QtGui.QBoxLayout.addWidget(PySide.QtGui.QWidget, int = 0, PySide.QtCore.Qt.Alignment = 0)
Re: Colorbar macro test
I got this working in ubuntu 14.04
It needed :
import os
os.environ['QT_API'] = 'pyside'
It needed :
import os
os.environ['QT_API'] = 'pyside'
Code: Select all
import sys
import FreeCAD
import FreeCADGui
import os
os.environ['QT_API'] = 'pyside'
from PySide import QtGui, QtCore
from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
class ColorMap(QtGui.QWidget):
def __init__(self, parent=None):
super(ColorMap, self).__init__(parent)
##
self.figure = plt.figure()
self.canvas = FigureCanvas(self.figure)
self.draw_colormap()
# set the layout
layout = QtGui.QVBoxLayout()
layout.addWidget(self.canvas)
self.setLayout(layout)
def draw_colormap(self):
sel = FreeCADGui.Selection.getSelection() # Selection
if not sel:
QtGui.QMessageBox.critical(None, "ColorMap macro", "An object has to be selected to run")
return
sel1=sel[0]
# Stess Values in MPa
datos=sel1.StressValues
val_max=max(datos)
val_min=min(datos)
# axes
ax = self.figure.add_axes([0.05, 0.10, 0.5, 0.8])
cmap = mpl.cm.jet
norm = mpl.colors.Normalize(vmin=val_min, vmax=val_max)
ticks_cm = np.linspace(val_min, val_max, 10, endpoint=True)
cb1 = mpl.colorbar.ColorbarBase(ax, cmap=cmap,
norm=norm,
ticks=ticks_cm,
orientation='vertical')
label_cm = 'Von Misses Stress [MPa]'
cb1.set_label(label=label_cm,weight='bold')
cb1.ax.tick_params(labelsize=16)
self.canvas.draw()
mw = FreeCADGui.getMainWindow() # access the main window
ColorMapWidget = QtGui.QDockWidget() # create a new dockwidget
ColorMapWidget.setWidget(ColorMap()) # load the Ui script
mw.addDockWidget(QtCore.Qt.RightDockWidgetArea,ColorMapWidget) # add the widget to the main window
Last edited by makkemal on Wed Jan 20, 2016 5:24 pm, edited 1 time in total.
Re: Colorbar macro test
Wow cool works for me to on Debian Jessie and FreeCAD 0.16.6237
BTW:
There is a type in the first line on the first character. It is but should be
You may could edit your post in this regard for others to get it work immediately.
BTW:
There is a type in the first line on the first character. It is
Code: Select all
mport sys
Code: Select all
import sys
Re: Colorbar macro test
Sorry copy paste finger trouble. Post updated