Part: reversed -- fix so it works with App::Links and App::Parts

This commit is contained in:
mwganson
2022-04-15 12:37:01 -05:00
committed by Uwe
parent 05f024678c
commit 7f7e33edc3
2 changed files with 15 additions and 11 deletions

View File

@@ -119,13 +119,13 @@ App::DocumentObjectExecReturn *RuledSurface::execute(void)
// get the first input shape
TopoDS_Shape S1;
ret = getShape(Curve1, S1);
if (ret)
if (ret)
return ret;
// get the second input shape
TopoDS_Shape S2;
ret = getShape(Curve2, S2);
if (ret)
if (ret)
return ret;
// check for expected type
@@ -711,16 +711,21 @@ Reverse::Reverse()
App::DocumentObjectExecReturn* Reverse::execute(void)
{
Part::Feature* source = Source.getValue<Part::Feature*>();
if (!source)
App::DocumentObject* source = Source.getValue<App::DocumentObject*>();
Part::TopoShape topoShape = Part::Feature::getShape(source);
if (topoShape.isNull())
return new App::DocumentObjectExecReturn("No part object linked.");
try {
TopoDS_Shape myShape = source->Shape.getValue();
if (!myShape.IsNull())
TopoDS_Shape myShape = topoShape.getShape();
if (!myShape.IsNull()){
this->Shape.setValue(myShape.Reversed());
this->Placement.setValue(source->Placement.getValue());
return App::DocumentObject::StdReturn;
Base::Placement p;
p.fromMatrix(topoShape.getTransform());
this->Placement.setValue(p);
return App::DocumentObject::StdReturn;
}
return new App::DocumentObjectExecReturn("Shape is null.");
}
catch (Standard_Failure & e) {
return new App::DocumentObjectExecReturn(e.GetMessageString());

View File

@@ -1264,7 +1264,7 @@ void CmdPartReverseShape::activated(int iMsg)
{
Q_UNUSED(iMsg);
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType
(Part::Feature::getClassTypeId());
(App::DocumentObject::getClassTypeId());
openCommand(QT_TRANSLATE_NOOP("Command", "Reverse"));
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
const TopoDS_Shape& shape = Part::Feature::getShape(*it);
@@ -1302,8 +1302,7 @@ void CmdPartReverseShape::activated(int iMsg)
bool CmdPartReverseShape::isActive(void)
{
return Gui::Selection().countObjectsOfType
(Part::Feature::getClassTypeId(), nullptr, Gui::ResolveMode::FollowLink) > 0;
return PartGui::getShapesFromSelection().size() > 0;
}
//===========================================================================