fix basic additive box

This commit is contained in:
Stefan Tröger 2015-05-11 06:28:36 +02:00
parent 31e4fd8994
commit cf83242f5b
3 changed files with 15 additions and 8 deletions

View File

@ -27,11 +27,15 @@
#include "FeaturePrimitive.h"
#include <Base/Exception.h>
#include <App/Document.h>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Cut.hxx>
using namespace PartDesign;
namespace PartDesign {
@ -40,7 +44,7 @@ PROPERTY_SOURCE(PartDesign::FeaturePrimitive, PartDesign::FeatureAddSub)
FeaturePrimitive::FeaturePrimitive()
: primitiveType(Box)
{
ADD_PROPERTY_TYPE(References, (0,0), "Primitive", (App::PropertyType)(App::Prop_None), "References to build the location of the primitive");
ADD_PROPERTY(References, (0,0));//, "Primitive", (App::PropertyType)(App::Prop_None), "References to build the location of the primitive");
}
App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& primitiveShape)
@ -51,8 +55,12 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri
const TopoDS_Shape primitiveShape = mkTrf.Shape();
//if we have no base we just add the standart primitive shape
const TopoDS_Shape base = getBaseShape();
if(base.IsNull()) {
TopoDS_Shape base;
try{
base = getBaseShape();
}
catch(const Base::Exception&) {
if(getAddSubType() == FeatureAddSub::Additive)
Shape.setValue(primitiveShape);
else
@ -63,6 +71,7 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri
}
if(getAddSubType() == FeatureAddSub::Additive) {
BRepAlgoAPI_Fuse mkFuse(base, primitiveShape);
if (!mkFuse.IsDone())
return new App::DocumentObjectExecReturn("Adding the primitive failed");
@ -105,8 +114,6 @@ TopLoc_Location FeaturePrimitive::calculateLocation()
return TopLoc_Location();
}
PROPERTY_SOURCE(PartDesign::Box, PartDesign::FeaturePrimitive)
Box::Box()

View File

@ -46,7 +46,7 @@ public:
FeaturePrimitive();
virtual const char* getViewProviderName(void) const {
return "getViewProviderPrimitive";
return "PartDesignGui::ViewProviderPrimitive";
}
Type getPrimitiveType() {return primitiveType;};
@ -65,7 +65,7 @@ protected:
class PartDesignExport Box : public PartDesign::FeaturePrimitive {
PROPERTY_HEADER(Part::Box);
PROPERTY_HEADER(PartDesign::Box);
public:

View File

@ -66,7 +66,7 @@ void CmdPrimtiveCompAdditive::activated(int iMsg)
Gui::Command::openCommand("Make additive box");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\'PartDesign::AdditiveBox\',\'%s\')",
FeatName.c_str());
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addObject(App.activeDocument().%s)"
Gui::Command::doCommand(Doc,"App.activeDocument().%s.addFeature(App.activeDocument().%s)"
,pcActiveBody->getNameInDocument(), FeatName.c_str());
Gui::Command::doCommand(Gui::Command::Gui, "Gui.activeDocument().setEdit(\'%s\')", FeatName.c_str());
}