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 # The radius and angles coordinates are defined
125 # in a local coordinate system which origin is the last point of the sketch
127 # @param length length of the segment
128 # @param angle1 angle in a plane, defined by the \a axes
129 # @param angle2 angle from the plane, defined by the \a axes
130 # @param axes can be: "OXY", "OYZ" or "OXZ"
131 def addPointRadiusAnglesRelative (self, length, angle1, angle2, axes="OXY"):
133 Add one straight segment, defined by two angles and length.
134 If the first point of sketcher is not yet defined, the
135 origin (0, 0, 0) will become the first sketcher point.
138 length length of the segment
139 angle1 angle in a plane, defined by the \a axes
140 angle2 angle from the plane, defined by the \a axes
141 axes can be: "OXY", "OYZ" or "OXZ"
144 sk = geompy.Sketcher3D()
145 sk.addPointRadiusAnglesRelative(100, 50, 0, "OXY")
146 a3D_Sketcher_1 = sk.wire()
148 self.myCommand = self.myCommand + ":%s"%axes+"SR"+" %s %s %s" % (printVar(angle1), printVar(angle2), printVar(length))
151 ## Add one straight segment, defined by two angles and radius.
152 # If the first point of sketcher is not yet defined, the
153 # origin (0, 0, 0) will become the first sketcher point.
154 # The radius and angles coordinates are defined
155 # in a coordinate system which origin is the global coordinate system origin
157 # @param radius distance to the coordinate system origin
158 # @param angle1 angle in a plane, defined by the \a axes
159 # @param angle2 angle from the plane, defined by the \a axes
160 # @param axes can be: "OXY", "OYZ" or "OXZ"
161 def addPointRadiusAnglesAbsolute (self, radius, angle1, angle2, axes="OXY"):
163 Add one straight segment, defined by two angles and length.
164 If the first point of sketcher is not yet defined, the
165 origin (0, 0, 0) will become the first sketcher point.
168 radius distance to the coordinate system origin
169 angle1 angle in a plane, defined by the \a axes
170 angle2 angle from the plane, defined by the \a axes
171 axes can be: "OXY", "OYZ" or "OXZ"
174 sk = geompy.Sketcher3D()
175 sk.addPointRadiusAnglesAbsolute(100, 50, 0, "OXY")
176 a3D_Sketcher_1 = sk.wire()
178 self.myCommand = self.myCommand + ":%s"%axes+"SA"+" %s %s %s" % (printVar(angle1), printVar(angle2), printVar(radius))
181 ## Add one straight segment, defined by an angle, a height and a radius.
182 # If the first point of sketcher is not yet defined, the
183 # origin (0, 0, 0) will become the first sketcher point.
184 # The radius height and angle coordinates are defined
185 # in a local coordinate system which origin is the last point of the sketch
187 # @param axes can be: "OXY", "OYZ" or "OXZ"
188 # @param angle angle in a plane, defined by the \a axes
189 # @param height height from the plane, defined by the \a axes
190 # @param radius distance to the coordinate system origin
191 def addPointRadiusAngleHRelative (self, length, angle, height, axes="OXY"):
193 Add one straight segment, defined by two angles and length.
194 If the first point of sketcher is not yet defined, the
195 origin (0, 0, 0) will become the first sketcher point.
198 radius distance to the coordinate system origin
199 angle angle in a plane, defined by the \a axes
200 height height from the plane, defined by the \a axes
201 axes can be: "OXY", "OYZ" or "OXZ"
204 sk = geompy.Sketcher3D()
205 sk.addPointRadiusAngleHRelative(100, 50, 40, "OXY")
206 a3D_Sketcher_1 = sk.wire()
208 self.myCommand = self.myCommand + ":%s"%axes+"CR"+" %s %s %s" % (printVar(angle), printVar(height), printVar(length))
211 ## Add one straight segment, defined by an angle, a height and a radius.
212 # If the first point of sketcher is not yet defined, the
213 # origin (0, 0, 0) will become the first sketcher point.
214 # The radius height and angle coordinates are defined
215 # in a coordinate system which origin is the global coordinate system origin
217 # @param radius distance to the coordinate system origin
218 # @param angle angle in a plane, defined by the \a axes
219 # @param height height from the plane, defined by the \a axes
220 # @param axes can be: "OXY", "OYZ" or "OXZ"
221 def addPointRadiusAngleHAbsolute (self, radius, angle, height, axes="OXY"):
223 Add one straight segment, defined by two angles and length.
224 If the first point of sketcher is not yet defined, the
225 origin (0, 0, 0) will become the first sketcher point.
228 axes can be: "OXY", "OYZ" or "OXZ"
229 angle1 angle in a plane, defined by the \a axes
230 height height from the plane, defined by the \a axes
231 radius distance to the coordinate system origin
234 sk = geompy.Sketcher3D()
235 sk.addPointRadiusAngleHAbsolute( 100, 50, 40, "OXY")
236 a3D_Sketcher_1 = sk.wire()
238 self.myCommand = self.myCommand + ":%s"%axes+"CA"+" %s %s %s" % (printVar(angle), printVar(height), printVar(radius))
241 ## Set to close the wire
244 Set to close the wire
247 sk = geompy.Sketcher3D()
248 sk.addPointsRelative(0,0,130, 70,0,-130)
250 a3D_Sketcher_1 = sk.wire()
252 self.myCommand = self.myCommand + ":WW"
255 ## Obtain the sketcher result.
256 # @return New GEOM_Object, containing the created wire
259 Obtain the sketcher result.
262 New GEOM_Object, containing the created wire.
265 sk = geompy.Sketcher3D()
266 sk.addPointsRelative(0,0,130, 70,0,-130)
267 a3D_Sketcher_1 = sk.wire()
269 from geompyDC import ParseSketcherCommand, RaiseIfFailed
270 Command,Parameters = ParseSketcherCommand(self.myCommand)
271 wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command)
272 self.myCommand = "3DSketcher"
273 RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp)
274 wire.SetParameters(Parameters)