I have one question is it possible to change the color of a face easier as the code I showed ?
Code: Select all
import FreeCAD
import PySide
from PySide import QtCore, QtGui
Gui.Selection.addSelection('Test_Meassuring','Box001','Face4')
a = FreeCADGui.Selection.getSelectionEx()
aa = FreeCADGui.Selection.getSelection()
SubElement = FreeCADGui.Selection.getSelectionEx()
element_ = SubElement[0].SubElementNames[0]
print(element_)
#FreeCAD.ActiveDocument.getObject(aa[0].Name).ViewObject.DiffuseColor=[(1.0,1.0,0.0)] >> Works but only for the whole object
cols = colors = []
cols = FreeCAD.ActiveDocument.getObject(aa[0].Name).ViewObject.DiffuseColor
for i in aa[0].Shape.Faces:
colors += [(cols[0])]
for i in range(len(aa)):
fce = int(a[0].SubElementNames[i][4:])-1
colors[fce] = (1.00,1.00,0.00)
aa[i].ViewObject.DiffuseColor = colors # >> Colors the selected face as it shows
Code: Select all
aa = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.getObject(aa[0].Name).ViewObject.DiffuseColor=[(1.0,1.0,0.0)] #>> Works but only for the whole object
Thanks and Greetings
Nanayaw
Code: Select all
OS: KDE Flatpak runtime (XFCE/xfce)
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: (HEAD detached at 0.20.1)
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.9.9, Qt 5.15.5, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.2
Locale: German/Germany (de_DE)
Installed mods:
* BIM 2021.12.0
* Curves 0.6.1
* lattice2 1.0.0
* CurvedShapes 1.0.4
* FEM_FrontISTR 0.1.0
* Assembly3 0.11.4
* workfeature
* Manipulator 1.4.9
* Defeaturing 1.2.0