ADD_SUBDIRECTORY (src/ModelHighAPI)
ADD_SUBDIRECTORY (src/ConstructionAPI)
ADD_SUBDIRECTORY (src/ExchangeAPI)
+ADD_SUBDIRECTORY (src/SketchAPI)
IF(${HAVE_SALOME})
ADD_SUBDIRECTORY (src/SHAPERGUI)
theAttribute->setValue(theValue);
}
+void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
+ double theX, double theY)
+{
+ theAttribute->setValue(theX, theY);
+}
+
//--------------------------------------------------------------------------------------
void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
const std::shared_ptr<GeomDataAPI_Dir> & theAttribute)
void fillAttribute(const std::shared_ptr<GeomAPI_Pnt2d> & theValue,
const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute);
+MODELHIGHAPI_EXPORT
+void fillAttribute(const std::shared_ptr<GeomDataAPI_Point2D> & theAttribute,
+ double theX, double theY);
+
MODELHIGHAPI_EXPORT
void fillAttribute(const std::shared_ptr<GeomAPI_Dir> & theValue,
const std::shared_ptr<GeomDataAPI_Dir> & theAttribute);
import model
from TestSketcher import SketcherTestCase
-class SketcherAddLine(SketcherTestCase):
+class SketcherAddLine(SketcherTestCase):
def test_add_line(self):
line = self.sketch.addLine(0, 0, 0, 1)
model.do()
- self.assertEqual(line.getStartPoint().x(), line.getEndPoint().x())
- self.assertNotEqual(line.getStartPoint().y(), line.getEndPoint().y())
+ self.assertEqual(line.startPoint().x(), line.endPoint().x())
+ self.assertNotEqual(line.startPoint().y(), line.endPoint().y())
def test_modify_line(self):
line = self.sketch.addLine(0, 0, 0, 1)
model.do()
line.setStartPoint(0, 1)
line.setEndPoint(1, 1)
- self.assertEqual(line.getStartPoint().x(), 0)
- self.assertEqual(line.getStartPoint().y(), 1)
- self.assertEqual(line.getEndPoint().x(), 1)
- self.assertEqual(line.getEndPoint().y(), 1)
+ self.assertEqual(line.startPoint().x(), 0)
+ self.assertEqual(line.startPoint().y(), 1)
+ self.assertEqual(line.endPoint().x(), 1)
+ self.assertEqual(line.endPoint().y(), 1)
if __name__ == "__main__":
# Built-in features
-from sketcher.sketch import addSketch
+from sketcher import *
from connection import *
from construction import *
from exchange import *
n = GeomAPI.GeomAPI_Dir(1, 0, 0)
x = GeomAPI.GeomAPI_Dir(0, 1, 0)
- return geom.Ax3(o, n, x)
+ return GeomAPI.GeomAPI_Ax3(o, n, x)
def begin ():
+"""Package for Sketch plugin for the Parametric Geometry API of the Modeler.
+"""
+
+from SketchAPI import addSketch
\ No newline at end of file
--- /dev/null
+## Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+INCLUDE(Common)
+
+SET(PROJECT_HEADERS
+ SketchAPI.h
+ SketchAPI_Line.h
+ SketchAPI_Sketch.h
+ SketchAPI_SketchEntity.h
+)
+
+SET(PROJECT_SOURCES
+ SketchAPI_Line.cpp
+ SketchAPI_Sketch.cpp
+ SketchAPI_SketchEntity.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ ModelAPI
+ ModelHighAPI
+)
+
+INCLUDE_DIRECTORIES(
+ ${PROJECT_SOURCE_DIR}/src/Events
+ ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
+ ${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI
+)
+
+# Plugin headers dependency
+INCLUDE_DIRECTORIES(
+ # TODO(spo): modify ConstructionPlugin headers to remove dependency on GeomAPI headers
+ ${PROJECT_SOURCE_DIR}/src/Config
+ ${PROJECT_SOURCE_DIR}/src/GeomAPI
+ ${PROJECT_SOURCE_DIR}/src/SketchPlugin
+)
+
+#TODO(spo): is ${CAS_DEFINITIONS} necessary?
+ADD_DEFINITIONS(-DSKETCHAPI_EXPORTS ${CAS_DEFINITIONS})
+ADD_LIBRARY(SketchAPI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(SketchAPI ${PROJECT_LIBRARIES})
+
+# SWIG wrapper
+
+INCLUDE(PythonAPI)
+
+SET_SOURCE_FILES_PROPERTIES(SketchAPI.i PROPERTIES CPLUSPLUS ON)
+SET_SOURCE_FILES_PROPERTIES(SketchAPI.i PROPERTIES SWIG_DEFINITIONS "-shadow")
+
+#TODO(spo): is ModelAPI necessary or it could be received by INTERFACE_ (may require modern CMake)?
+SET(SWIG_LINK_LIBRARIES
+ SketchAPI
+ ModelHighAPI
+ ModelAPI
+ ${PYTHON_LIBRARIES}
+)
+
+SET(SWIG_MODULE_SketchAPI_EXTRA_DEPS ${SWIG_MODULE_SketchAPI_EXTRA_DEPS}
+ ${PROJECT_SOURCE_DIR}/src/ModelHighAPI/ModelHighAPI.i
+ doxyhelp.i
+ ${PROJECT_HEADERS}
+)
+
+SWIG_ADD_MODULE(SketchAPI python SketchAPI.i ${PROJECT_HEADERS})
+SWIG_LINK_LIBRARIES(SketchAPI ${SWIG_LINK_LIBRARIES})
+
+IF(WIN32)
+ SET_TARGET_PROPERTIES(_SketchAPI PROPERTIES DEBUG_OUTPUT_NAME _SketchAPI_d)
+ENDIF(WIN32)
+
+INSTALL(TARGETS _SketchAPI DESTINATION ${SHAPER_INSTALL_SWIG})
+INSTALL(TARGETS SketchAPI DESTINATION ${SHAPER_INSTALL_BIN})
+INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/SketchAPI.py DESTINATION ${SHAPER_INSTALL_SWIG})
+
+# Tests
+
+INCLUDE(UnitTest)
+
+ADD_UNIT_TESTS(
+ TestSketch.py
+)
+
+# ADD_SUBDIRECTORY (Test)
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#ifndef SKETCHAPI_H
+#define SKETCHAPI_H
+
+#if defined SKETCHAPI_EXPORTS
+#if defined WIN32
+#define SKETCHAPI_EXPORT __declspec( dllexport )
+#else
+#define SKETCHAPI_EXPORT
+#endif
+#else
+#if defined WIN32
+#define SKETCHAPI_EXPORT __declspec( dllimport )
+#else
+#define SKETCHAPI_EXPORT
+#endif
+#endif
+
+#endif
--- /dev/null
+/* SketchAPI.i */
+
+%module SketchAPI
+
+%{
+ #include "SketchAPI_swig.h"
+%}
+
+%include "doxyhelp.i"
+
+// import other modules
+%import "ModelHighAPI.i"
+
+// to avoid error on this
+#define SKETCHAPI_EXPORT
+
+// standard definitions
+%include "typemaps.i"
+%include "std_list.i"
+%include "std_shared_ptr.i"
+
+// shared pointers
+%shared_ptr(SketchAPI_Line)
+%shared_ptr(SketchAPI_Sketch)
+%shared_ptr(SketchAPI_SketchEntity)
+
+// all supported interfaces
+%include "SketchAPI_Line.h"
+%include "SketchAPI_Sketch.h"
+%include "SketchAPI_SketchEntity.h"
--- /dev/null
+// Name : SketchAPI_Line.cpp
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_Line.h"
+//--------------------------------------------------------------------------------------
+#include <GeomAPI_Pnt2d.h>
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Selection.h>
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+SketchAPI_Line::SketchAPI_Line(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_Line::SketchAPI_Line(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ double theX1, double theY1, double theX2, double theY2)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setByCoordinates(theX1, theY1, theX2, theY2);
+ }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setByPoints(theStartPoint, theEndPoint);
+ }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theExternal )
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setByExternal(theExternal);
+ }
+}
+
+SketchAPI_Line::SketchAPI_Line(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::string & theExternalName )
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setByExternalName(theExternalName);
+ }
+}
+
+SketchAPI_Line::~SketchAPI_Line()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Line::setByCoordinates(
+ double theX1, double theY1, double theX2, double theY2)
+{
+ fillAttribute(startPoint(), theX1, theY1);
+ fillAttribute(endPoint(), theX2, theY2);
+
+ execute();
+}
+
+void SketchAPI_Line::setByPoints(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+ fillAttribute(theStartPoint, startPoint());
+ fillAttribute(theEndPoint, endPoint());
+
+ execute();
+}
+
+void SketchAPI_Line::setByExternal(const ModelHighAPI_Selection & theExternal)
+{
+ fillAttribute(theExternal, external());
+
+ execute();
+}
+
+void SketchAPI_Line::setByExternalName(const std::string & theExternalName)
+{
+ fillAttribute(ModelHighAPI_Selection("EDGE", theExternalName), external());
+
+ execute();
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Line::setStartPoint(double theX, double theY)
+{
+ fillAttribute(startPoint(), theX, theY);
+
+ execute();
+}
+void SketchAPI_Line::setStartPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
+{
+ fillAttribute(thePoint, startPoint());
+
+ execute();
+}
+void SketchAPI_Line::setEndPoint(double theX, double theY)
+{
+ fillAttribute(endPoint(), theX, theY);
+
+ execute();
+}
+void SketchAPI_Line::setEndPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
+{
+ fillAttribute(thePoint, endPoint());
+
+ execute();
+}
+
+//--------------------------------------------------------------------------------------
+
--- /dev/null
+// Name : SketchAPI_Line.h
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_LINE_H_
+#define SRC_SKETCHAPI_SKETCHAPI_LINE_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <GeomDataAPI_Point2D.h>
+
+#include <SketchPlugin_Line.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelHighAPI_Selection;
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_Line
+ * \ingroup CPPHighAPI
+ * \brief Interface for Line feature
+ */
+class SketchAPI_Line : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ double theX1, double theY1, double theX2, double theY2);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theExternal);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Line(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::string & theExternalName);
+ /// Destructor
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_Line();
+
+ INTERFACE_3(SketchPlugin_Line::ID(),
+ startPoint, SketchPlugin_Line::START_ID(), GeomDataAPI_Point2D, /** Start point */,
+ endPoint, SketchPlugin_Line::END_ID(), GeomDataAPI_Point2D, /** End point */,
+ external, SketchPlugin_Line::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */
+ )
+
+ /// Set by coordinates
+ SKETCHAPI_EXPORT
+ void setByCoordinates(double theX1, double theY1, double theX2, double theY2);
+
+ /// Set by points
+ SKETCHAPI_EXPORT
+ void setByPoints(const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+
+ /// Set by external
+ SKETCHAPI_EXPORT
+ void setByExternal(const ModelHighAPI_Selection & theExternal);
+
+ /// Set by external name
+ SKETCHAPI_EXPORT
+ void setByExternalName(const std::string & theExternalName);
+
+ /// Set start point
+ SKETCHAPI_EXPORT
+ void setStartPoint(double theX, double theY);
+
+ /// Set start point
+ SKETCHAPI_EXPORT
+ void setStartPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
+
+ /// Set end point
+ SKETCHAPI_EXPORT
+ void setEndPoint(double theX, double theY);
+
+ /// Set end point
+ SKETCHAPI_EXPORT
+ void setEndPoint(const std::shared_ptr<GeomAPI_Pnt2d> & thePoint);
+};
+
+//! Pointer on Line object
+typedef std::shared_ptr<SketchAPI_Line> LinePtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_LINE_H_ */
--- /dev/null
+// Name : SketchAPI_Sketch.cpp
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_Sketch.h"
+//--------------------------------------------------------------------------------------
+#include <ModelAPI_CompositeFeature.h>
+#include <ModelHighAPI_Tools.h>
+#include "SketchAPI_Line.h"
+//--------------------------------------------------------------------------------------
+SketchAPI_Sketch::SketchAPI_Sketch(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_Sketch::SketchAPI_Sketch(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setPlane(thePlane);
+ }
+}
+
+SketchAPI_Sketch::SketchAPI_Sketch(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theExternal)
+: ModelHighAPI_Interface(theFeature)
+{
+ if (initialize()) {
+ setExternal(theExternal);
+ }
+}
+
+SketchAPI_Sketch::~SketchAPI_Sketch()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_CompositeFeature> SketchAPI_Sketch::compositeFeature() const
+{
+ return std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(feature());
+}
+
+//--------------------------------------------------------------------------------------
+void SketchAPI_Sketch::setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+{
+ fillAttribute(thePlane->origin(), myorigin);
+ fillAttribute(thePlane->dirX(), mydirX);
+ fillAttribute(thePlane->normal(), mynormal);
+
+ execute();
+}
+
+void SketchAPI_Sketch::setExternal(const ModelHighAPI_Selection & theExternal)
+{
+ fillAttribute(theExternal, myexternal);
+
+ execute();
+}
+
+//--------------------------------------------------------------------------------------
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const std::shared_ptr<GeomAPI_Ax3> & thePlane)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
+ return SketchPtr(new SketchAPI_Sketch(aFeature, thePlane));
+}
+
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection & theExternal)
+{
+ // TODO(spo): check that thePart is not empty
+ std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(SketchAPI_Sketch::ID());
+ return SketchPtr(new SketchAPI_Sketch(aFeature, theExternal));
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(double theX1, double theY1, double theX2, double theY2)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+ return LinePtr(new SketchAPI_Line(aFeature, theX1, theY1, theX2, theY2));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+ return LinePtr(new SketchAPI_Line(aFeature, theStartPoint, theEndPoint));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const ModelHighAPI_Selection & theExternal)
+{
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+ return LinePtr(new SketchAPI_Line(aFeature, theExternal));
+}
+std::shared_ptr<SketchAPI_Line> SketchAPI_Sketch::addLine(const std::string & theExternalName)
+{
+ // TODO(spo): Add constraint SketchConstraintRigid like in PythonAPI. Is it necessary?
+ std::shared_ptr<ModelAPI_Feature> aFeature = compositeFeature()->addFeature(SketchPlugin_Line::ID());
+ return LinePtr(new SketchAPI_Line(aFeature, theExternalName));
+}
+//--------------------------------------------------------------------------------------
--- /dev/null
+// Name : SketchAPI_Sketch.h
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_SketchEntity.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+class ModelAPI_CompositeFeature;
+class ModelHighAPI_Selection;
+class SketchAPI_Line;
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_Sketch
+ * \ingroup CPPHighAPI
+ * \brief Interface for Sketch feature
+ */
+class SketchAPI_Sketch : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+ /// Constructor with values
+ SKETCHAPI_EXPORT
+ SketchAPI_Sketch(const std::shared_ptr<ModelAPI_Feature> & theFeature,
+ const ModelHighAPI_Selection & theExternal);
+ /// Destructor
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_Sketch();
+
+ INTERFACE_7(SketchPlugin_Sketch::ID(),
+ origin, SketchPlugin_Sketch::ORIGIN_ID(), GeomDataAPI_Point, /** Origin point */,
+ dirX, SketchPlugin_Sketch::DIRX_ID(), GeomDataAPI_Dir, /** Direction of X */,
+ normal, SketchPlugin_Sketch::NORM_ID(), GeomDataAPI_Dir, /** Normal */,
+ features, SketchPlugin_Sketch::FEATURES_ID(), ModelAPI_AttributeRefList, /** Features */,
+ external, SketchPlugin_SketchEntity::EXTERNAL_ID(), ModelAPI_AttributeSelection, /** External */,
+ solverError, SketchPlugin_Sketch::SOLVER_ERROR(), ModelAPI_AttributeString, /** Solver error */,
+ solverDOF, SketchPlugin_Sketch::SOLVER_DOF(), ModelAPI_AttributeString, /** Solver DOF */
+ )
+
+ /// Set plane
+ SKETCHAPI_EXPORT
+ void setPlane(const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+
+ /// Set external
+ SKETCHAPI_EXPORT
+ void setExternal(const ModelHighAPI_Selection & theExternal);
+
+ /// Add line
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Line> addLine(
+ double theX1, double theY1, double theX2, double theY2);
+ /// Add line
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Line> addLine(
+ const std::shared_ptr<GeomAPI_Pnt2d> & theStartPoint,
+ const std::shared_ptr<GeomAPI_Pnt2d> & theEndPoint);
+ /// Add line
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Line> addLine(const ModelHighAPI_Selection & theExternal);
+ /// Add line
+ SKETCHAPI_EXPORT
+ std::shared_ptr<SketchAPI_Line> addLine(const std::string & theExternalName);
+
+protected:
+ std::shared_ptr<ModelAPI_CompositeFeature> compositeFeature() const;
+
+};
+
+//! Pointer on Sketch object
+typedef std::shared_ptr<SketchAPI_Sketch> SketchPtr;
+
+/**\ingroup CPPHighAPI
+ * \brief Create Sketch feature
+ */
+SKETCHAPI_EXPORT
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const std::shared_ptr<GeomAPI_Ax3> & thePlane);
+
+/**\ingroup CPPHighAPI
+ * \brief Create Sketch feature
+ */
+SKETCHAPI_EXPORT
+SketchPtr addSketch(const std::shared_ptr<ModelAPI_Document> & thePart,
+ const ModelHighAPI_Selection & theExternal);
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCH_H_ */
--- /dev/null
+// Name : SketchAPI_SketchEntity.cpp
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI_SketchEntity.h"
+//--------------------------------------------------------------------------------------
+#include <ModelHighAPI_Tools.h>
+//--------------------------------------------------------------------------------------
+SketchAPI_SketchEntity::SketchAPI_SketchEntity(
+ const std::shared_ptr<ModelAPI_Feature> & theFeature)
+: ModelHighAPI_Interface(theFeature)
+{
+ initialize();
+}
+
+SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
+{
+
+}
+
+//--------------------------------------------------------------------------------------
+bool SketchAPI_SketchEntity::initialize()
+{
+ SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
+
+ return true;
+}
+
+//--------------------------------------------------------------------------------------
+std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
+{
+ return myAuxiliary;
+}
+
+void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
+{
+ fillAttribute(theAuxiliary, myAuxiliary);
+
+ execute();
+}
+
+//--------------------------------------------------------------------------------------
--- /dev/null
+// Name : SketchAPI_SketchEntity.h
+// Purpose:
+//
+// History:
+// 07/06/16 - Sergey POKHODENKO - Creation of the file
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_
+
+//--------------------------------------------------------------------------------------
+#include "SketchAPI.h"
+
+#include <SketchPlugin_SketchEntity.h>
+
+#include <ModelHighAPI_Interface.h>
+#include <ModelHighAPI_Macro.h>
+//--------------------------------------------------------------------------------------
+/**\class SketchAPI_SketchEntity
+ * \ingroup CPPHighAPI
+ * \brief Base class for Sketch feature interfaces
+ */
+class SketchAPI_SketchEntity : public ModelHighAPI_Interface
+{
+public:
+ /// Constructor without values
+ SKETCHAPI_EXPORT
+ explicit SketchAPI_SketchEntity(const std::shared_ptr<ModelAPI_Feature> & theFeature);
+ /// Destructor
+ SKETCHAPI_EXPORT
+ virtual ~SketchAPI_SketchEntity();
+
+ /// Auxiliary
+ SKETCHAPI_EXPORT
+ std::shared_ptr<ModelAPI_AttributeBoolean> auxiliary() const;
+
+ /// Set auxiliary
+ SKETCHAPI_EXPORT
+ void setAuxiliary(bool theAuxiliary);
+
+protected:
+ std::shared_ptr<ModelAPI_AttributeBoolean> myAuxiliary;
+
+ bool initialize();
+};
+
+//! Pointer on SketchEntity object
+typedef std::shared_ptr<SketchAPI_SketchEntity> SketchEntityPtr;
+
+//--------------------------------------------------------------------------------------
+//--------------------------------------------------------------------------------------
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SKETCHENTITY_H_ */
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: SketchAPI_swig.h
+// Created: 07/06/16
+// Author: Sergey POKHODENKO
+
+#ifndef SRC_SKETCHAPI_SKETCHAPI_SWIG_H_
+#define SRC_SKETCHAPI_SKETCHAPI_SWIG_H_
+
+ #include <ModelHighAPI_swig.h>
+
+ #include "SketchAPI.h"
+ #include "SketchAPI_Line.h"
+ #include "SketchAPI_Sketch.h"
+ #include "SketchAPI_SketchEntity.h"
+
+#endif /* SRC_SKETCHAPI_SKETCHAPI_SWIG_H_ */
--- /dev/null
+import unittest
+
+import ModelAPI
+import ExchangeAPI
+
+class PointTestCase(unittest.TestCase):
+
+ def setUp(self):
+ self.session = ModelAPI.ModelAPI_Session.get()
+ self.doc = self.session.moduleDocument()
+
+ def tearDown(self):
+ self.session.closeAll()
+
+ def test_addImport(self):
+ self.session.startOperation()
+ self.feature = ExchangeAPI.addImport(self.doc, "file_path")
+ self.session.finishOperation()
+
+ def test_addExport(self):
+ self.session.startOperation()
+ self.feature = ExchangeAPI.exportToFile(self.doc, "file_path", "file_format", [])
+ self.session.finishOperation()
+
+if __name__ == "__main__":
+ unittest.main()