Materials: Child ignoring parent material
Inherit the material from the parent object when creating a new object, such as during a boolean operation, or when extruding a sketch. fixes #15503
This commit is contained in:
committed by
Yorik van Havre
parent
5435b3e4db
commit
0804d80ebf
@@ -128,6 +128,26 @@ PyObject *Feature::getPyObject()
|
||||
return Py::new_reference_to(PythonObject);
|
||||
}
|
||||
|
||||
void Feature::copyMaterial(Feature* feature)
|
||||
{
|
||||
auto mat = Materials::MaterialManager::defaultMaterial();
|
||||
if (feature) {
|
||||
if (ShapeMaterial.getValue().getUUID() != feature->ShapeMaterial.getValue().getUUID()) {
|
||||
if (ShapeMaterial.getValue().getUUID() == mat->getUUID()) {
|
||||
ShapeMaterial.setValue(feature->ShapeMaterial.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Feature::copyMaterial(App::DocumentObject* link)
|
||||
{
|
||||
auto feature = dynamic_cast<Part::Feature*>(link);
|
||||
if (feature) {
|
||||
copyMaterial(feature);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Override getElementName to support the Export type. Other calls are passed to the original
|
||||
* method
|
||||
@@ -1709,6 +1729,16 @@ short FilletBase::mustExecute() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
App::DocumentObjectExecReturn* FilletBase::execute()
|
||||
{
|
||||
App::DocumentObject* link = this->Base.getValue();
|
||||
if (!link) {
|
||||
return new App::DocumentObjectExecReturn("No object linked");
|
||||
}
|
||||
copyMaterial(link);
|
||||
return Part::Feature::execute();
|
||||
}
|
||||
|
||||
void FilletBase::onChanged(const App::Property *prop) {
|
||||
if(getDocument() && !getDocument()->testStatus(App::Document::Restoring)) {
|
||||
if(prop == &Edges || prop == &Base) {
|
||||
|
||||
Reference in New Issue
Block a user