diff --git a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp index 22efa4eca6..9f75430d33 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGuiPy.cpp @@ -79,11 +79,25 @@ static PyObject * setActiveAssembly(PyObject *self, PyObject *args) Py_Return; } +/* module functions */ +static PyObject * getActiveAssembly(PyObject *self, PyObject *args) +{ + if(ActiveAsmObject){ + + return ActiveAsmObject->getPyObject(); + } + + + Py_Return; +} + /* registration table */ struct PyMethodDef AssemblyGui_Import_methods[] = { {"setActiveAssembly" ,setActiveAssembly ,METH_VARARGS, "setActiveAssembly(AssemblyObject) -- Set the Assembly object in work."}, + {"getActiveAssembly" ,getActiveAssembly ,METH_VARARGS, + "getActiveAssembly() -- Returns the Assembly object in work."}, {NULL, NULL} /* end of table marker */ }; diff --git a/src/Mod/Assembly/Gui/Command.cpp b/src/Mod/Assembly/Gui/Command.cpp index c1ac9f199a..bfb3d65db6 100644 --- a/src/Mod/Assembly/Gui/Command.cpp +++ b/src/Mod/Assembly/Gui/Command.cpp @@ -175,19 +175,46 @@ void CmdAssemblyAddExistingComponent::activated(int iMsg) return; } - openCommand("Insert TestPart"); - std::string PartName = getUniqueObjectName("Part"); - doCommand(Doc,"App.activeDocument().addObject('Assembly::ItemPart','%s')",PartName.c_str()); - if(dest){ - std::string fatherName = dest->getNameInDocument(); - doCommand(Doc,"App.activeDocument().%s.Items = App.activeDocument().%s.Items + [App.activeDocument().%s] ",fatherName.c_str(),fatherName.c_str(),PartName.c_str()); - } - Command::addModule(App,"PartDesign"); - Command::addModule(Gui,"PartDesignGui"); - std::string BodyName = getUniqueObjectName("Body"); - doCommand(Doc,"App.activeDocument().addObject('PartDesign::Body','%s')",BodyName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Model = App.activeDocument().%s ",PartName.c_str(),BodyName.c_str(),BodyName.c_str()); - + // asking for file name (only step at the moment) + QStringList filter; + filter << QString::fromAscii("STEP (*.stp *.step)"); + filter << QString::fromAscii("STEP with colors (*.stp *.step)"); + filter << QString::fromAscii("IGES (*.igs *.iges)"); + filter << QString::fromAscii("IGES with colors (*.igs *.iges)"); + filter << QString::fromAscii("BREP (*.brp *.brep)"); + + QString select; + QString fn = Gui::FileDialog::getOpenFileName(Gui::getMainWindow(), QString(), QString(), filter.join(QLatin1String(";;")), &select); + if (!fn.isEmpty()) { + + + openCommand("Import ExtPart"); + addModule(Doc,"Part"); + addModule(Doc,"PartDesign"); + addModule(Gui,"PartDesignGui"); + + std::string fName( (const char*)fn.toUtf8()); + + doCommand(Gui, + +"father = AssemblyGui.getActiveAssembly()\n" +"\n" +"for i in Part.read('%s').Solids:\n" +" po = App.activeDocument().addObject('Assembly::ItemPart','STP-Part_1')\n" +" father.Items = father.Items + [po]\n" +" bo = App.activeDocument().addObject('PartDesign::Body','STP-Body_1')\n" +" po.Model = bo\n" +" so = App.activeDocument().addObject('PartDesign::Solid','STP-Solid_1')\n" +" bo.Model = so\n" +" bo.Tip = so\n" +" so.Shape = i\n" +"\n" +"del so,bo,father,po\n" + + ,fName.c_str()); + + this->updateActive(); + } } void CreateAssemblyCommands(void) diff --git a/src/Mod/PartDesign/App/AppPartDesign.cpp b/src/Mod/PartDesign/App/AppPartDesign.cpp index 18f96394c4..dbd6b0dbdf 100644 --- a/src/Mod/PartDesign/App/AppPartDesign.cpp +++ b/src/Mod/PartDesign/App/AppPartDesign.cpp @@ -30,6 +30,7 @@ #include #include "FeaturePad.h" +#include "FeatureSolid.h" #include "FeaturePocket.h" #include "FeatureFillet.h" #include "FeatureSketchBased.h" @@ -75,6 +76,7 @@ PyMODINIT_FUNC init_PartDesign() // This function is responsible for adding inherited slots from a type's base class. PartDesign::Feature ::init(); + PartDesign::Solid ::init(); PartDesign::DressUp ::init(); PartDesign::SketchBased ::init(); PartDesign::Subtractive ::init(); diff --git a/src/Mod/PartDesign/App/CMakeLists.txt b/src/Mod/PartDesign/App/CMakeLists.txt index 51500d14c4..fce91a4760 100644 --- a/src/Mod/PartDesign/App/CMakeLists.txt +++ b/src/Mod/PartDesign/App/CMakeLists.txt @@ -31,6 +31,8 @@ set(PartDesign_LIBS SET(Features_SRCS Feature.cpp Feature.h + FeatureSolid.cpp + FeatureSolid.h Body.cpp Body.h ) diff --git a/src/Mod/PartDesign/App/FeatureSolid.cpp b/src/Mod/PartDesign/App/FeatureSolid.cpp new file mode 100644 index 0000000000..9f745e7ddb --- /dev/null +++ b/src/Mod/PartDesign/App/FeatureSolid.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ +#endif + + +#include "FeatureSolid.h" + + + +namespace PartDesign { + + +PROPERTY_SOURCE(PartDesign::Solid,PartDesign::Feature) + +Solid::Solid() +{ +} + + + +} diff --git a/src/Mod/PartDesign/App/FeatureSolid.h b/src/Mod/PartDesign/App/FeatureSolid.h new file mode 100644 index 0000000000..fd441c54fd --- /dev/null +++ b/src/Mod/PartDesign/App/FeatureSolid.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (c) 2011 Juergen Riegel * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#ifndef PARTDESIGN_FeatureSolid_H +#define PARTDESIGN_FeatureSolid_H + +#include +#include "Feature.h" + +class gp_Pnt; + + +/// Base class of all additive features in PartDesign +namespace PartDesign +{ + + /** PartDesign feature + * Base class of all PartDesign features. + * This kind of features only produce solids or fail. + */ +class PartDesignExport Solid : public Feature +{ + PROPERTY_HEADER(PartDesign::FeatureSolid); + +public: + Solid(); + +protected: + +}; + +} //namespace PartDesign + + +#endif // PARTDESIGN_Feature_H