From 11e47526db58271c8695d816c5f9e2fe5addddda Mon Sep 17 00:00:00 2001 From: spo Date: Tue, 27 Oct 2015 14:43:03 +0300 Subject: [PATCH] Add partset plugin without tests. --- src/PythonAPI/model/__init__.py | 2 +- src/PythonAPI/model/part.py | 19 ----------- src/PythonAPI/model/partset/__init__.py | 4 +++ src/PythonAPI/model/partset/part.py | 44 +++++++++++++++++++++++++ 4 files changed, 49 insertions(+), 20 deletions(-) delete mode 100644 src/PythonAPI/model/part.py create mode 100644 src/PythonAPI/model/partset/__init__.py create mode 100644 src/PythonAPI/model/partset/part.py diff --git a/src/PythonAPI/model/__init__.py b/src/PythonAPI/model/__init__.py index 1e158cca8..a73f32e79 100644 --- a/src/PythonAPI/model/__init__.py +++ b/src/PythonAPI/model/__init__.py @@ -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 index d69265dde..000000000 --- a/src/PythonAPI/model/part.py +++ /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 index 000000000..33eed0d4b --- /dev/null +++ b/src/PythonAPI/model/partset/__init__.py @@ -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 index 000000000..bcbd56087 --- /dev/null +++ b/src/PythonAPI/model/partset/part.py @@ -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() + + -- 2.39.2