Latest development.
First, I have ported PartDesign to adopt the element mapping, but haven't thoroughly tested it yet. Can someone please provide me some big PartDesign models for testing?
Second, I have improved the naming scheme for tracing back modeling history. As a demonstration, I extended Part view provider face coloring to use the element map for mapping child shape colors. It is now supported for all Part::Feature derived objects. By default, only face color mapping is enabled, otherwise you'll see a lot of white edges mapped from extrusion through a sketch, which I guess people won't like. To enable/disable color mapping, use Part view providers new property, MapFaceColor, MapLineColor, MapPointColor.
The screencast also shows how to override individual element colors. The element references are stable, thanks to the new topo naming. Unlike fillet, if an element reference is gone, it will auto deduce related elements for coloring. To color any element in Python,
Code: Select all
# obtain the existing overridden colors as a dict(name:color)
colors = App.ActiveDocument.Cut.ViewObject.ElementColors
colors['Face6'] = (1.0, 0.0, 0.0) # add some more element color
App.ActiveDocument.Cut.ViewObject.ElementColors = colors
To show the element evolving history
Code: Select all
from pprint import pprint
pprint(App.ActiveDocument.Cut.getElementHistory('Face2'))
[('Fusion', '#31;:M#30;RFI;:T2:3', []),
('Cylinder', 'Face3', ['Face3;:M2;FUS;:T2:5'])]
It returns a list of tuple(sourceObjName, sourceElementName, [intermediateName...]). The intermediateName are intermediate modeling steps. The above result means
Code: Select all
# Cut.Face2 comes from a Fusion element, the 'RFI' op code indicates the last modeling step is refine.
'Fusion', '#31;:M#30;RFI;:T2:3'
# The above refined element, comes from Cylinder.Face3, with an intermediate modeling step, and its
# op code 'FUS' means it is a fusion operation.
('Cylinder', 'Face3', ['Face3;:M2;FUS;:T2:5'])
The Cut.Face2 (the bottom face of the cut object) obviously comes from more than one source face. The history trace right now only decodes the first source shape (in tag+name sorting order), and therefore will give you a linear history. It is also possible to return the full history tree by decoding the ;:M#30 marker above. #30 means it's stored in hasher table entry 0x30. It will tell you the rest of the source shape element names.