1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 # Author : Julia DOROVSKIKH, Open CASCADE S.A.S.
26 \brief 3D Sketcher interface
29 # This method is used by 3D Sketcher functionality
31 if isinstance(var, str):
36 ## An interface to build a 3D Sketcher step-by-step.
37 # Use geompy.Sketcher3D() method to obtain an instance of this class.
39 # @ref tui_3dsketcher_page "Example"
42 3D sketcher interface.
45 sk = geompy.Sketcher3D()
46 sk.addPointsAbsolute(0,0,0, 70,0,0)
47 sk.addPointsRelative(0, 0, 130)
48 sk.addPointAnglesLength("OXY", 50, 0, 100)
49 sk.addPointAnglesLength("OXZ", 30, 80, 130)
51 a3D_Sketcher_1 = sk.wire()
54 def __init__(self, geompyD):
55 self.geompyD = geompyD
56 self.myCommand = "3DSketcher"
59 ## Add one or more points, sequentially connected with straight segments.
60 # Coordinates are considered as absolute.
61 # If the first point of sketcher is not yet defined, the first point
62 # from the listCoords will become the first sketcher point.
63 # @param X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points
64 def addPointsAbsolute (self, *listCoords):
66 Add one or more points, sequentially connected with straight segments.
67 Coordinates are considered as absolute.
68 If the first point of sketcher is not yet defined, the first point
69 from the listCoords will become the first sketcher point.
72 X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points
75 sk = geompy.Sketcher3D()
76 sk.addPointsAbsolute(0,0,0, 70,0,0)
77 a3D_Sketcher_1 = sk.wire()
82 self.myCommand = self.myCommand + ":TT"
83 self.myCommand = self.myCommand + " %s"%printVar(cc)
90 ## Add one or more points, sequentially connected with straight segments.
91 # Coordinates are considered relative to the previous point.
92 # If the first point of sketcher is not yet defined, the
93 # origin (0, 0, 0) will become the first sketcher point.
94 # @param X1, Y1, Z1, X2, Y2, Z2, ... Coordinates of points
95 def addPointsRelative (self, *listCoords):
97 Add one or more points, sequentially connected with straight segments.
98 Coordinates are considered relative to the previous point.
99 If the first point of sketcher is not yet defined, the
100 origin (0, 0, 0) will become the first sketcher point.
103 X1, Y1, Z1, X2, Y2, Z2, ... Relative coordinates of points
106 sk = geompy.Sketcher3D()
107 sk.addPointsRelative(0,0,130, 70,0,-130)
108 a3D_Sketcher_1 = sk.wire()
111 for cc in listCoords:
113 self.myCommand = self.myCommand + ":T"
114 self.myCommand = self.myCommand + " %s"%printVar(cc)
121 ## Add one straight segment, defined by two angles and length.
122 # If the first point of sketcher is not yet defined, the
123 # origin (0, 0, 0) will become the first sketcher point.
124 # @param axes can be: "OXY", "OYZ" or "OXZ"
125 # @param angle1 angle in a plane, defined by the \a axes
126 # @param angle2 angle from the plane, defined by the \a axes
127 # @param length length of the segment
128 def addPointAnglesLength (self, axes, angle1, angle2, length):
130 Add one straight segment, defined by two angles and length.
131 If the first point of sketcher is not yet defined, the
132 origin (0, 0, 0) will become the first sketcher point.
135 axes can be: "OXY", "OYZ" or "OXZ"
136 angle1 angle in a plane, defined by the \a axes
137 angle2 angle from the plane, defined by the \a axes
138 length length of the segment
141 sk = geompy.Sketcher3D()
142 sk.addPointAnglesLength("OXY", 50, 0, 100)
143 a3D_Sketcher_1 = sk.wire()
145 self.myCommand = self.myCommand + ":%s %s %s %s" % (axes, printVar(angle1), printVar(angle2), printVar(length))
148 ## Set to close the wire
151 Set to close the wire
154 sk = geompy.Sketcher3D()
155 sk.addPointsRelative(0,0,130, 70,0,-130)
157 a3D_Sketcher_1 = sk.wire()
159 self.myCommand = self.myCommand + ":WW"
162 ## Obtain the sketcher result.
163 # @return New GEOM_Object, containing the created wire
166 Obtain the sketcher result.
169 New GEOM_Object, containing the created wire.
172 sk = geompy.Sketcher3D()
173 sk.addPointsRelative(0,0,130, 70,0,-130)
174 a3D_Sketcher_1 = sk.wire()
176 from geompyDC import ParseSketcherCommand, RaiseIfFailed
177 Command,Parameters = ParseSketcherCommand(self.myCommand)
178 wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command)
179 self.myCommand = "3DSketcher"
180 RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp)
181 wire.SetParameters(Parameters)