1 """General purpose Interface
2 Author: Daniel Brunier-Coulin
3 Copyright (C) 2014-20xx CEA/DEN, EDF R&D
9 import geom # To be removed when gp_Ax3 will be Pythonized
12 def moduleDocument ():
13 """Return the main document (the Partset) created or open from the Modeler.
15 This document is unique in the application session.
17 return ModelAPI.ModelAPI_Session.get().moduleDocument()
20 def activeDocument ():
21 """Return the active document.
23 This document can be either the main application document (i.e. the Partset) or one of documents
24 referred to by the main document (a Part).
26 return ModelAPI.ModelAPI_Session.get().activeDocument()
29 def defaultPlane (name):
30 """Return one of the three planes defined by the global coordinate system.
32 These planes are respectively referred to by name "XOY" (Z=0), "XOZ" (Y=0) or "YOZ" (X=0).
34 # Temporary implementation before the availability of default planes.
35 o = GeomAPI.GeomAPI_Pnt(0, 0, 0)
37 n = GeomAPI.GeomAPI_Dir(0, 0, 1)
38 x = GeomAPI.GeomAPI_Dir(1, 0, 0)
40 n = GeomAPI.GeomAPI_Dir(0, -1, 0)
41 x = GeomAPI.GeomAPI_Dir(1, 0, 0)
43 n = GeomAPI.GeomAPI_Dir(1, 0, 0)
44 x = GeomAPI.GeomAPI_Dir(0, 1, 0)
46 return geom.Ax3(o, n, x)
50 """Start a data structure transaction.
52 Make a control point for being able to discard or undo
53 all operations done during this transaction.
55 ModelAPI.ModelAPI_Session.get().startOperation()
59 """Commit the data structure transaction.
61 Make all operations done since the last control point undo-able.
63 ModelAPI.ModelAPI_Session.get().finishOperation()
67 """Commit the data structure transaction and start the new one.
69 Make all operations done since the last control point undo-able
70 and continue with the new transaction.
72 session = ModelAPI.ModelAPI_Session.get()
73 session.finishOperation()
74 session.startOperation()
78 """Roll-back the data structure to the previous control point."""
79 ModelAPI.ModelAPI_Session.get().undo()
83 """Restore the data structure rolled-back by the last undo."""
84 ModelAPI.ModelAPI_Session.get().redo()
88 """Reset the data structure to initial state."""
89 ModelAPI.ModelAPI_Session.get().closeAll()