]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Add partset plugin without tests.
authorspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 11:43:03 +0000 (14:43 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Tue, 27 Oct 2015 11:43:11 +0000 (14:43 +0300)
src/PythonAPI/model/__init__.py
src/PythonAPI/model/part.py [deleted file]
src/PythonAPI/model/partset/__init__.py [new file with mode: 0644]
src/PythonAPI/model/partset/part.py [new file with mode: 0644]

index 1e158cca8f6c12034a7b7c5c483efc81c4e34731..a73f32e795d6bb21ff5abb35ce9c0ad051368f9a 100644 (file)
@@ -8,12 +8,12 @@ from roots     import *
 
 # Built-in features
 
-from part      import Part            as addPart
 from sketcher.sketch  import addSketch
 from construction import *
 from exchange import *
 from features import *
 from parameter import *
+from partset import *
 
 # Custom exceptions
 
diff --git a/src/PythonAPI/model/part.py b/src/PythonAPI/model/part.py
deleted file mode 100644 (file)
index d69265d..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-"""Part Feature Interface
-Author: Daniel Brunier-Coulin
-Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-"""
-
-import model     # Required by the temporary implementation of result member function
-
-
-class Part():
-
-  def __init__ (self, partset):
-    """Adds a new Part to the given Partset and activates the Part."""
-    self._feature = partset.addFeature("Part")
-    self._feature.execute()
-
-  def document (self):
-    """Returns the Part document created by this feature."""
-    #TODO: Get the document referenced by this feature
-    return model.activeDocument()
\ No newline at end of file
diff --git a/src/PythonAPI/model/partset/__init__.py b/src/PythonAPI/model/partset/__init__.py
new file mode 100644 (file)
index 0000000..33eed0d
--- /dev/null
@@ -0,0 +1,4 @@
+"""Package for PartSet plugin for the Parametric Geometry API of the Modeler.
+"""
+
+from part import addPart, duplicatePart, removePart
\ No newline at end of file
diff --git a/src/PythonAPI/model/partset/part.py b/src/PythonAPI/model/partset/part.py
new file mode 100644 (file)
index 0000000..bcbd560
--- /dev/null
@@ -0,0 +1,44 @@
+"""Part Feature Interface
+Author: Daniel Brunier-Coulin
+Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+"""
+
+import ModelAPI
+
+from model.roots import Interface
+
+
+def addPart(partset):
+    """Add a Part feature to the Part and return Part.
+
+    Pass all args to Part __init__ function.
+    """
+    feature = partset.addFeature("Part")
+    return Part(feature)
+
+def duplicatePart(part):
+    """Create a copy of the Part."""
+    feature = part.addFeature("Duplicate")
+    feature.execute()
+    return Part(feature)
+
+def removePart(part):
+    """Remove the Part."""
+    feature = part.addFeature("Remove")
+    feature.execute()
+
+
+class Part(Interface):
+
+    def __init__(self, feature):
+        """Adds a new Part to the given Partset and activates the Part."""
+        Interface.__init__(self, feature)
+        assert(self._feature.getKind() == "Part")
+        pass
+
+    def document(self):
+        """Returns the Part document created by this feature."""
+        result_part = ModelAPI.modelAPI_ResultPart(self._feature.firstResult())
+        return result_part.partDoc()
+
+