harmonize show() function of Part, Mesh, Fem, Path and Points modules
This commit is contained in:
@@ -103,7 +103,7 @@ public:
|
||||
);
|
||||
#endif
|
||||
add_varargs_method("show",&Module::show,
|
||||
"show(shape) -- Add the shape to the active document or create one if no document exists."
|
||||
"show(shape,[string]) -- Add the mesh to the active document or create one if no document exists."
|
||||
);
|
||||
initialize("This module is the Fem module."); // register with Python
|
||||
}
|
||||
@@ -299,7 +299,8 @@ private:
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(FemMeshPy::Type), &pcObj))
|
||||
char *name = "Mesh";
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(FemMeshPy::Type), &pcObj, &name))
|
||||
throw Py::Exception();
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
@@ -307,9 +308,9 @@ private:
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
|
||||
FemMeshPy* pShape = static_cast<FemMeshPy*>(pcObj);
|
||||
Fem::FemMeshObject *pcFeature = (Fem::FemMeshObject *)pcDoc->addObject("Fem::FemMeshObject", "Mesh");
|
||||
Fem::FemMeshObject *pcFeature = static_cast<Fem::FemMeshObject*>
|
||||
(pcDoc->addObject("Fem::FemMeshObject", name));
|
||||
// copy the data
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->FemMesh.setValue(*(pShape->getFemMeshPtr()));
|
||||
pcDoc->recompute();
|
||||
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
"compressed.\n"
|
||||
);
|
||||
add_varargs_method("show",&Module::show,
|
||||
"Put a mesh object in the active document or creates one if needed"
|
||||
"show(shape,[string]) -- Add the mesh to the active document or create one if no document exists."
|
||||
);
|
||||
add_varargs_method("createBox",&Module::createBox,
|
||||
"Create a solid mesh box"
|
||||
@@ -359,14 +359,15 @@ private:
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(MeshPy::Type), &pcObj))
|
||||
char *name = "Mesh";
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(MeshPy::Type), &pcObj, &name))
|
||||
throw Py::Exception();
|
||||
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
MeshPy* pMesh = static_cast<MeshPy*>(pcObj);
|
||||
Mesh::Feature *pcFeature = (Mesh::Feature *)pcDoc->addObject("Mesh::Feature", "Mesh");
|
||||
Mesh::Feature *pcFeature = static_cast<Mesh::Feature*>(pcDoc->addObject("Mesh::Feature", name));
|
||||
Mesh::MeshObject* mo = pMesh->getMeshObjectPtr();
|
||||
if (!mo) {
|
||||
throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid mesh");
|
||||
|
||||
@@ -616,9 +616,8 @@ private:
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
TopoShapePy* pShape = static_cast<TopoShapePy*>(pcObj);
|
||||
Part::Feature *pcFeature = (Part::Feature *)pcDoc->addObject("Part::Feature", name);
|
||||
Part::Feature *pcFeature = static_cast<Part::Feature*>(pcDoc->addObject("Part::Feature", name));
|
||||
// copy the data
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->Shape.setValue(pShape->getTopoShapePtr()->getShape());
|
||||
pcDoc->recompute();
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ public:
|
||||
"read(filename,[document]): Imports a GCode file into the given document"
|
||||
);
|
||||
add_varargs_method("show",&Module::show,
|
||||
"show(path): Add the path to the active document or create one if no document exists"
|
||||
"show(path,[string]): Add the path to the active document or create one if no document exists"
|
||||
);
|
||||
add_varargs_method("fromShape",&Module::fromShape,
|
||||
"fromShape(Shape): Returns a Path object from a Part Shape"
|
||||
@@ -217,15 +217,16 @@ private:
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PathPy::Type), &pcObj))
|
||||
char *name = "Path";
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(PathPy::Type), &pcObj, &name))
|
||||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
App::Document *pcDoc = App::GetApplication().getActiveDocument();
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
PathPy* pPath = static_cast<PathPy*>(pcObj);
|
||||
Path::Feature *pcFeature = (Path::Feature *)pcDoc->addObject("Path::Feature", "Path");
|
||||
Path::Feature *pcFeature = static_cast<Path::Feature*>(pcDoc->addObject("Path::Feature", name));
|
||||
Path::Toolpath* pa = pPath->getToolpathPtr();
|
||||
if (!pa) {
|
||||
throw Py::Exception(PyExc_ReferenceError, "object doesn't reference a valid path");
|
||||
|
||||
@@ -64,7 +64,8 @@ public:
|
||||
);
|
||||
add_varargs_method("export",&Module::exporter
|
||||
);
|
||||
add_varargs_method("show",&Module::show
|
||||
add_varargs_method("show",&Module::show,
|
||||
"show(points,[string]) -- Add the points to the active document or create one if no document exists."
|
||||
);
|
||||
initialize("This module is the Points module."); // register with Python
|
||||
}
|
||||
@@ -381,7 +382,8 @@ private:
|
||||
Py::Object show(const Py::Tuple& args)
|
||||
{
|
||||
PyObject *pcObj;
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!", &(PointsPy::Type), &pcObj))
|
||||
char *name = "Points";
|
||||
if (!PyArg_ParseTuple(args.ptr(), "O!|s", &(PointsPy::Type), &pcObj, &name))
|
||||
throw Py::Exception();
|
||||
|
||||
try {
|
||||
@@ -389,11 +391,9 @@ private:
|
||||
if (!pcDoc)
|
||||
pcDoc = App::GetApplication().newDocument();
|
||||
PointsPy* pPoints = static_cast<PointsPy*>(pcObj);
|
||||
Points::Feature *pcFeature = (Points::Feature *)pcDoc->addObject("Points::Feature", "Points");
|
||||
Points::Feature *pcFeature = static_cast<Points::Feature*>(pcDoc->addObject("Points::Feature", name));
|
||||
// copy the data
|
||||
//TopoShape* shape = new MeshObject(*pShape->getTopoShapeObjectPtr());
|
||||
pcFeature->Points.setValue(*(pPoints->getPointKernelPtr()));
|
||||
//pcDoc->recompute();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
throw Py::RuntimeError(e.what());
|
||||
|
||||
Reference in New Issue
Block a user