ADD_SUBDIRECTORY (src/PartSetPlugin)
ADD_SUBDIRECTORY (src/ConstructionPlugin)
ADD_SUBDIRECTORY (src/FeaturesPlugin)
+ADD_SUBDIRECTORY (src/PythonFeaturesPlugin)
ADD_SUBDIRECTORY (src/SketchPlugin)
ADD_SUBDIRECTORY (src/SketchSolver)
ADD_SUBDIRECTORY (src/ModuleBase)
#------ NewGEOM ------
export NEW_GEOM_ROOT_DIR=${ROOT_DIR}/install
export PATH=${NEW_GEOM_ROOT_DIR}/bin:${NEW_GEOM_ROOT_DIR}/plugins:${PATH}
-export PYTHONPATH=${NEW_GEOM_ROOT_DIR}/swig:${PYTHONPATH}
+export PYTHONPATH=${NEW_GEOM_ROOT_DIR}/swig:${NEW_GEOM_ROOT_DIR}/plugins:${PYTHONPATH}
export LD_LIBRARY_PATH=${NEW_GEOM_ROOT_DIR}/bin:${NEW_GEOM_ROOT_DIR}/swig:${NEW_GEOM_ROOT_DIR}/plugins:${LD_LIBRARY_PATH}
export NEW_GEOM_CONFIG_FILE=${NEW_GEOM_ROOT_DIR}/plugins
export NewGeomResources=${NEW_GEOM_ROOT_DIR}/resources
<plugin library="SketchPlugin" configuration="plugin-Sketch.xml"/>
<plugin library="ConstructionPlugin" configuration="plugin-Construction.xml"/>
<plugin library="FeaturesPlugin" configuration="plugin-Features.xml"/>
+ <plugin library="PythonFeaturesPlugin" configuration="plugin-PythonFeatures.xml"/>
<plugin library="ExchangePlugin" configuration="plugin-Exchange.xml"/>
<plugin library="SketchSolver"/>
<plugin library="GeomValidators"/>
FeaturesPlugin.h
FeaturesPlugin_Plugin.h
FeaturesPlugin_Extrusion.h
- FeaturesPlugin_Boolean.h
+ FeaturesPlugin_Boolean.h
)
SET(PROJECT_SOURCES
#include <TDF_RelocationTable.hxx>
#include <TDF_ClosureTool.hxx>
+// TEST
+#include <Python.h>
+
using namespace std;
static Model_Session* myImpl = new Model_Session();
FeaturePtr Model_Session::createFeature(string theFeatureID)
{
- if (this != myImpl)
+ if (this != myImpl) {
return myImpl->createFeature(theFeatureID);
+ }
LoadPluginsInfo();
if (myPlugins.find(theFeatureID) != myPlugins.end()) {
myCurrentPluginName = aPlugin.first;
if (myPluginObjs.find(myCurrentPluginName) == myPluginObjs.end()) {
// load plugin library if not yet done
- Config_ModuleReader::loadLibrary(myCurrentPluginName);
+ //TODO: Get info from Config about python libraries
+ if (myCurrentPluginName.compare(string("PythonFeaturesPlugin")) == 0) {
+ Py_Initialize();
+ PyObject* module = PyImport_ImportModule(myCurrentPluginName.c_str());
+ assert(module != NULL);
+ } else {
+ Config_ModuleReader::loadLibrary(myCurrentPluginName);
+ }
}
if (myPluginObjs.find(myCurrentPluginName) != myPluginObjs.end()) {
FeaturePtr aCreated = myPluginObjs[myCurrentPluginName]->createFeature(theFeatureID);
/* ModelAPI.i */
-%module ModelAPI
+%module(directors="1") ModelAPI
%{
#include "GeomAPI_Interface.h"
#include "GeomAPI_Shape.h"
#include "ModelAPI_Session.h"
#include "ModelAPI_Object.h"
#include "ModelAPI_Feature.h"
+ #include "ModelAPI_Plugin.h"
#include "ModelAPI_Data.h"
#include "ModelAPI_Attribute.h"
#include "ModelAPI_AttributeDocRef.h"
%shared_ptr(ModelAPI_Document)
%shared_ptr(ModelAPI_Session)
%shared_ptr(ModelAPI_Object)
+// %shared_ptr(ModelAPI_Plugin)
%shared_ptr(ModelAPI_Feature)
%shared_ptr(ModelAPI_Data)
%shared_ptr(ModelAPI_Attribute)
%shared_ptr(ModelAPI_ResultConstruction)
%shared_ptr(ModelAPI_ResultBody)
%shared_ptr(ModelAPI_ResultPart)
+%feature("director") ModelAPI_Plugin;
// all supported interfaces
%include "GeomAPI_Interface.h"
%include "ModelAPI_Document.h"
%include "ModelAPI_Session.h"
%include "ModelAPI_Object.h"
+%include "ModelAPI_Plugin.h"
%include "ModelAPI_Feature.h"
%include "ModelAPI_Data.h"
%include "ModelAPI_Attribute.h"
--- /dev/null
+INCLUDE(Common)
+
+SET(PYTHON_FILES
+ PythonFeaturesPlugin_Box.py
+ PythonFeaturesPlugin.py
+)
+
+SET(XML_RESSOURCES
+ plugin-PythonFeatures.xml
+ box_widget.xml
+)
+
+INSTALL(FILES ${PYTHON_FILES} ${XML_RESSOURCES} DESTINATION plugins)
--- /dev/null
+from ModelAPI import *
+import PythonFeaturesPlugin_Box
+
+class PythonFeaturesPlugin(ModelAPI_Plugin):
+ def __init__(self):
+ ModelAPI_Plugin.__init__(self)
+ pass
+
+ def createFeature(self, theFeatureID):
+ if theFeatureID == PythonFeaturesPlugin_Box.ID():
+ return PythonFeaturesPlugin_Box()
+ else:
+ raise StandardError("No such feature %s"%theFeatureID)
+
+plugin = PythonFeaturesPlugin()
+ModelAPI_Session_get().registerPlugin(plugin)
+
--- /dev/null
+from ModelAPI import *
+
+class PythonFeaturesPlugin_Box(ModelAPI_Feature):
+ "Feature to create a box by drawing a sketch and extruding it"
+ def __init__(self):
+ pass
+
+ def ID(self):
+ return "Box"
+
+ def WIDTH_ID(self):
+ return "box_width"
+
+ def LENGTH_ID(self):
+ return "box_length"
+
+ def HEIGHT_ID(self):
+ return "box_height"
+
+ def initAttributes(self):
+ self.data().addAttribute(self.WIDTH_ID(), ModelAPI_AttributeDouble.type())
+ self.data().addAttribute(self.LENGTH_ID(), ModelAPI_AttributeDouble.type())
+ self.data().addAttribute(self.HEIGHT_ID(), ModelAPI_AttributeDouble.type())
+
+ def execute(self):
+ aWidth = self.data().attribute(self.WIDTH_ID()).value()
+ aLength = self.data().attribute(self.LENGTH_ID()).value()
+ aHeight = self.data().attribute(self.HEIGHT_ID()).value()
+
+ aResult = document().createBody(data())
+ #aResult.store(UserPackage.makeBox(aLength, aWidth, aHeight)
+
+ #self.setResult(aResult)
+
+
+
+
+
--- /dev/null
+<source>
+ <doublevalue id="box_width" label="Width" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set width of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+ <doublevalue id="box_length" label="Length" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set length of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+ <doublevalue id="box_height" label="Height" min="0" step="1.0" default="10" icon=":icons/dimension_v.png" tooltip="Set height of the box">
+ <validator id="GeomValidators_Positive"/>
+ </doublevalue>
+</source>
--- /dev/null
+<plugin>
+ <workbench id="Features" document="Part">
+ <group id="Basic">
+ <feature id="Box" title="Box" tooltip="Create a box" icon="">
+ <source path="box_widget.xml"/>
+ </feature>
+ </group>
+ </workbench>
+</plugin>