Ein Beispiel mit Farben:
Code: Select all
import FreeCAD as App
import Part
doc = App.newDocument('BoxTest')
box = []
b = doc.addObject('Part::Box','Box')
box.append(b)
doc.recompute()
box[0].ViewObject.DiffuseColor = [(0.9,1.,0.), (0.8,1.,0.), (0.7,1.,0.), (0.6,1.,0.), (0.5,1.,0.), (0.4,1.,0.)]
b = doc.addObject('Part::Box','Box')
box.append(b)
doc.recompute()
box[1].Placement = App.Placement(App.Vector(5,5,5),App.Rotation(App.Vector(0,0,1),0))
box[1].ViewObject.DiffuseColor = [(0.9,0.,1.), (0.8,0.,1.), (0.7,0.,1.), (0.6,0.,1.), (0.5,0.,1.), (0.4,0.,1.)]
box[0].ViewObject.Visibility = False
box[1].ViewObject.Visibility = False
fusion = doc.addObject('Part::Fuse','Fusion')
fusion.Base = box[0]
fusion.Tool = box[1]
doc.recompute()
for id1, face1 in enumerate(fusion.Shape.Faces):
for b in box:
for id2, face2 in enumerate(b.Shape.Faces):
if face1.BoundBox.Center == face2.BoundBox.Center:
print str(fusion.ViewObject.DiffuseColor[id1]) + ' <=> ' + str(b.ViewObject.DiffuseColor[id2])