[TD]prevent fail during document restore

This commit is contained in:
wandererfan
2023-12-23 08:56:09 -05:00
committed by WandererFan
parent 95fad03ee2
commit ca1aa9d916
2 changed files with 20 additions and 1 deletions

View File

@@ -795,9 +795,14 @@ TopoDS_Wire DrawComplexSection::makeSectionLineWire()
App::DocumentObject* toolObj = CuttingToolWireObject.getValue();
DrawViewPart* baseDvp = dynamic_cast<DrawViewPart*>(BaseView.getValue());
if (baseDvp) {
TopoDS_Shape toolShape = Part::Feature::getShape(toolObj);
if (toolShape.IsNull()) {
// CuttingToolWireObject is likely still restoring and has no shape yet
return {};
}
Base::Vector3d centroid = baseDvp->getCurrentCentroid();
TopoDS_Shape sTrans =
ShapeUtils::ShapeUtils::moveShape(Part::Feature::getShape(toolObj), centroid * -1.0);
ShapeUtils::ShapeUtils::moveShape(toolShape, centroid * -1.0);
TopoDS_Shape sScaled = ShapeUtils::scaleShape(sTrans, baseDvp->getScale());
//we don't mirror the scaled shape here as it will be mirrored by the projection