Assembly import script & PartDesign Solid object
This commit is contained in:
parent
fca3b9dffb
commit
fc7db6369c
|
@ -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 */
|
||||
};
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <Base/Interpreter.h>
|
||||
|
||||
#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();
|
||||
|
|
|
@ -31,6 +31,8 @@ set(PartDesign_LIBS
|
|||
SET(Features_SRCS
|
||||
Feature.cpp
|
||||
Feature.h
|
||||
FeatureSolid.cpp
|
||||
FeatureSolid.h
|
||||
Body.cpp
|
||||
Body.h
|
||||
)
|
||||
|
|
44
src/Mod/PartDesign/App/FeatureSolid.cpp
Normal file
44
src/Mod/PartDesign/App/FeatureSolid.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
55
src/Mod/PartDesign/App/FeatureSolid.h
Normal file
55
src/Mod/PartDesign/App/FeatureSolid.h
Normal file
|
@ -0,0 +1,55 @@
|
|||
/***************************************************************************
|
||||
* Copyright (c) 2011 Juergen Riegel <FreeCAD@juergen-riegel.net> *
|
||||
* *
|
||||
* 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 <App/PropertyStandard.h>
|
||||
#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
|
Loading…
Reference in New Issue
Block a user