1 # -*- coding: iso-8859-1 -*-
2 # Copyright (C) 2007-2013 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 2D and 3D Sketcher interfaces
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.addPointRadiusAnglesRelative(50, 0, 100, 'OXY')
49 sk.addPointRadiusAnglesRelative(30, 80, 130, 'OXZ')
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 # @param theName Object name; when specified, this parameter is used
257 # for result publication in the study. Otherwise, if automatic
258 # publication is switched on, default value is used for result name.
260 # @return New GEOM_Object, containing the created wire
261 def wire (self, theName=None):
263 Obtain the sketcher result.
266 theName Object name; when specified, this parameter is used
267 for result publication in the study. Otherwise, if automatic
268 publication is switched on, default value is used for result name.
271 New GEOM_Object, containing the created wire.
274 sk = geompy.Sketcher3D()
275 sk.addPointsRelative(0,0,130, 70,0,-130)
276 a3D_Sketcher_1 = sk.wire()
278 from salome.geom.geomBuilder import ParseSketcherCommand, RaiseIfFailed
279 Command,Parameters = ParseSketcherCommand(self.myCommand)
280 wire = self.geompyD.CurvesOp.Make3DSketcherCommand(Command)
281 self.myCommand = "3DSketcher"
282 RaiseIfFailed("Sketcher3D", self.geompyD.CurvesOp)
283 wire.SetParameters(Parameters)
284 self.geompyD._autoPublish(wire, theName, "wire")
287 # An interface to build a 2D Sketcher step-by-step.
288 # Use geompy.Sketcher2D() method to obtain an instance of this class.
292 2D sketcher interface.
295 sk = geompy.Sketcher2D()
297 sk.addSegmentRelative(15, 70)
298 sk.addSegmentPerpY(50)
299 sk.addArcRadiusRelative(25, 15, 14.5, 0)
300 sk.addArcCenterAbsolute(1, 1, 50, 50, 0, 0)
301 sk.addArcDirectionRadiusLength(20, 20, 101, 162.13)
303 Sketch_1 = sk.wire(geomObj_1)
305 def __init__(self, geompyD):
306 self.geompyD = geompyD
307 self.myCommand = "Sketcher"
312 # Used to set the starting point
314 # @param x, y - Coordinates of point
315 def addPoint (self, x, y):
318 Used to set the starting point
321 x, y - Coordinates of point
324 sk = geompy.Sketcher2D()
326 Sketcher_1 = sk.wire(geomObj_1)
328 self.myCommand = self.myCommand + ":F %s %s" % (printVar(x), printVar(y))
332 # Used to set the angle for further building
334 # @param angle - angle in a plane
335 def addAngle (self, angle):
338 Used to set the angle for further building
341 angle - angle in a plane
344 sk = geompy.Sketcher2D()
346 Sketcher_1 = sk.wire(geomObj_1)
348 self.myCommand = self.myCommand + ":RR %s" % (printVar(angle))
351 # Commands for creation of segment
353 ## Add segment, which sequentially connects the previous point
354 # with a point lying on a line parallel to the axis Ox and the value x = param x.
355 # The current point will be the previous value to the coordinate y and
356 # new value to the coordinate x.
357 # Coordinate is considered relative to the previous point.
359 # @param x - Coordinate of point on axis Ox
360 def addSegmentParalX(self, x):
362 Add segment, which sequentially connects the previous point
363 with a point lying on a line parallel to the axis Ox and the value x = param x.
364 The current point will be the previous value to the coordinate y and
365 new value to the coordinate x.
366 Coordinate is considered relative to the previous point.
369 x - Coordinate of point on axis Ox
372 sk = geompy.Sketcher2D()
373 sk.addSegmentParalX(40)
374 Sketcher_1 = sk.wire(geomObj_1)
376 self.myCommand = self.myCommand + ":X %s" % (printVar(x))
379 ## Add segment, which sequentially connects the previous point
380 # with a point lying on a line parallel to the axis Ox and the value x = 0
381 # The current point will be the previous value to the coordinate y.
382 def addSegmentParalXToZero(self):
384 Add segment, which sequentially connects the previous point
385 with a point lying on a line parallel to the axis Ox and the value x = 0
386 The current point will be the previous value to the coordinate y.
389 sk = geompy.Sketcher2D()
390 sk.addSegmentParalXToZero()
391 Sketcher_1 = sk.wire(geomObj_1)
393 self.myCommand = self.myCommand + ":XX"
396 ## Add segment, which sequentially connects the previous point
397 # with a point lying on a line parallel to the axis Oy and the value y = param y.
398 # The current point will be the previous value to the coordinate x and
399 # new value to the coordinate y.
400 # Coordinate is considered relative to the previous point.
402 # @param y - Coordinate of point on axis Oy
403 def addSegmentParalY(self, y):
405 Add segment, which sequentially connects the previous point
406 with a point lying on a line parallel to the axis Oy and the value y = param y.
407 The current point will be the previous value to the coordinate x and
408 new value to the coordinate y.
409 Coordinate is considered relative to the previous point.
412 y - Coordinate of point on axis Oy
415 sk = geompy.Sketcher2D()
416 sk.addSegmentParalY(80)
417 Sketcher_1 = sk.wire(geomObj_1)
419 self.myCommand = self.myCommand + ":Y %s" % (printVar(y))
422 ## Add segment, which sequentially connects the previous point
423 # with a point lying on a line parallel to the axis Ox and the value x = 0
424 # The current point will be the previous value to the coordinate y.
425 def addSegmentParalYToZero(self):
427 Add segment, which sequentially connects the previous point
428 with a point lying on a line parallel to the axis Oy and the value y = 0
429 The current point will be the previous value to the coordinate x.
432 sk = geompy.Sketcher2D()
433 sk.addSegmentParalYToZero()
434 Sketcher_1 = sk.wire(geomObj_1)
436 self.myCommand = self.myCommand + ":YY"
439 ## Add segment, which sequentially connects the given point with previous point
441 # Coordinates are considered as absolute.
442 # @param x, y - Coordinates of point
443 def addSegmentAbsolute (self, x, y):
445 Add segment, which sequentially connects the starting point with the given point
446 Coordinates are considered as absolute.
449 x, y - Coordinates of point
452 sk = geompy.Sketcher2D()
453 sk.addSegmentAbsolute(30, 50)
454 Sketcher_1 = sk.wire(geomObj_1)
456 self.myCommand = self.myCommand + ":TT %s %s" % (printVar(x), printVar(y))
459 ## Add segment, which sequentially connects the given point with previous point
460 # Coordinates are considered relative to the previous point.
461 # If the first point of sketcher is not yet defined, the
462 # origin (0, 0) will become the first sketcher point.
464 # @param dx, dy - Coordinates of point relative a previous point
465 def addSegmentRelative (self, dx, dy):
467 Add segment, which sequentially connects the given point with previous point
468 Coordinates are considered relative to the previous point.
469 If the first point of sketcher is not yet defined, the
470 origin (0, 0) will become the first sketcher point.
473 dx, dy - Coordinates of point relative a previous point
476 sk = geompy.Sketcher2D()
477 sk.addSegmentRelative(60, 10)
478 Sketcher_1 = sk.wire(geomObj_1)
480 self.myCommand = self.myCommand + ":T %s %s" % (printVar(dx), printVar(dy))
483 ## Add one straight segment, defined by angle and length.
484 # If the first point of sketcher is not yet defined, the
485 # origin (0, 0) will become the first sketcher point.
486 # The angle and length coordinates are defined
487 # in a local coordinate system which origin is the last point of the sketch
489 # @param angle - angle in a plane
490 # @param length - length of the segment
491 def addSegmentAngleLength (self, angle, length ):
493 Add one straight segment, defined by angle and length.
494 If the first point of sketcher is not yet defined, the
495 origin (0, 0) will become the first sketcher point.
496 The radius and angles coordinates are defined
497 in a local coordinate system which origin is the last point of the sketch
500 angle - angle in a plane
501 length - length of the segment
504 sk = geompy.Sketcher2D()
505 sk.addSegmentAngleLength(10, 30)
506 Sketcher_1 = sk.wire(geomObj_1)
508 self.myCommand = self.myCommand + ":R %s:L %s" % (printVar(angle), printVar(length))
511 ## Add one straight segment, defined by angle and intersect straight x= param x.
512 # If the first point of sketcher is not yet defined, the
513 # origin (0, 0) will become the first sketcher point.
514 # The angle and point's coordinates are defined
515 # in a local coordinate system which origin is the last point of the sketch
517 # @param angle - angle in a plane
518 # @param x - value on the axis Ox
519 def addSegmentAngleX (self, angle, x ):
521 Add one straight segment, defined by angle and intersect straight x= param x.
522 If the first point of sketcher is not yet defined, the
523 origin (0, 0) will become the first sketcher point.
524 The angle and point's coordinates are defined
525 in a local coordinate system which origin is the last point of the sketch
528 angle - angle in a plane
529 x - value on the axis Ox
532 sk = geompy.Sketcher2D()
533 sk.addSegmentAngleX(25, 90)
534 Sketcher_1 = sk.wire(geomObj_1)
536 self.myCommand = self.myCommand + ":R %s:IX %s" % (printVar(angle), printVar(x))
539 ## Add one straight segment, defined by angle and intersect straight y= param y.
540 # If the first point of sketcher is not yet defined, the
541 # origin (0, 0) will become the first sketcher point.
542 # The angle and point's coordinates are defined
543 # in a local coordinate system which origin is the last point of the sketch
545 # @param angle - angle in a plane
546 # @param y - value on the axis Oy
547 def addSegmentAngleY (self, angle, y ):
549 Add one straight segment, defined by angle and intersect straight y= param y.
550 If the first point of sketcher is not yet defined, the
551 origin (0, 0) will become the first sketcher point.
552 The angle and point's coordinates are defined
553 in a local coordinate system which origin is the last point of the sketch
556 angle - angle in a plane
557 y - value on the axis Oy
560 sk = geompy.Sketcher2D()
561 sk.addSegmentAngleY(40, 0)
562 Sketcher_1 = sk.wire(geomObj_1)
564 self.myCommand = self.myCommand + ":R %s:IY %s" % (printVar(angle), printVar(y))
568 ## Add one straight segment, defined by perpendicular(angle=90) and length.
569 # If the first point of sketcher is not yet defined, the
570 # origin (0, 0) will become the first sketcher point.
571 # The length coordinates are defined
572 # in a local coordinate system which origin is the last point of the sketch
574 # @param length - length of the segment
575 def addSegmentPerpLength (self, length ):
577 Add one straight segment, defined by perpendicular and length.
578 If the first point of sketcher is not yet defined, the
579 origin (0, 0) will become the first sketcher point.
580 The length coordinates are defined
581 in a local coordinate system which origin is the last point of the sketch
584 length - length of the segment
587 sk = geompy.Sketcher2D()
588 sk.addSegmentPerpLength(100)
589 Sketcher_1 = sk.wire(geomObj_1)
591 self.myCommand = self.myCommand + ":R 90:L %s" % (printVar(length))
594 ## Add one straight segment, defined by perpendicular(angle=90) and intersect straight x= param x.
595 # If the first point of sketcher is not yet defined, the
596 # origin (0, 0) will become the first sketcher point.
597 # The point's coordinates are defined
598 # in a local coordinate system which origin is the last point of the sketch
600 # @param x - value on the axis Ox
601 def addSegmentPerpX (self, x ):
603 Add one straight segment, defined by perpendicular(angle=90) and intersect straight x= param x.
604 If the first point of sketcher is not yet defined, the
605 origin (0, 0) will become the first sketcher point.
606 The point's coordinates are defined
607 in a local coordinate system which origin is the last point of the sketch
610 x - value on the axis Ox
613 sk = geompy.Sketcher2D()
614 sk.addSegmentPerpX(30)
615 Sketcher_1 = sk.wire(geomObj_1)
617 self.myCommand = self.myCommand + ":R 90:IX %s" % (printVar(x))
620 ## Add one straight segment, defined by perpendicular(angle=90) and intersect straight y= param y.
621 # If the first point of sketcher is not yet defined, the
622 # origin (0, 0) will become the first sketcher point.
623 # The point's coordinates are defined
624 # in a local coordinate system which origin is the last point of the sketch
626 # @param y - value on the axis Oy
627 def addSegmentPerpY (self, y ):
629 Add one straight segment, defined by perpendicular(angle=90) and intersect straight y= param y.
630 If the first point of sketcher is not yet defined, the
631 origin (0, 0) will become the first sketcher point.
632 The point's coordinates are defined
633 in a local coordinate system which origin is the last point of the sketch
636 y - value on the axis Oy
639 sk = geompy.Sketcher2D()
640 sk.addSegmentPerpY(10)
641 Sketcher_1 = sk.wire(geomObj_1)
643 self.myCommand = self.myCommand + ":R 90:IY %s" % (printVar(y))
647 ## Add one straight segment, defined by previous direction and length.
648 # If the first point of sketcher is not yet defined, the
649 # origin (0, 0) will become the first sketcher point.
650 # The length coordinates are defined
651 # in a local coordinate system which origin is the last point of the sketch
653 # @param length - length of the segment
654 def addSegmentLength (self, length ):
656 Add one straight segment, defined by previous direction and length.
657 If the first point of sketcher is not yet defined, the
658 origin (0, 0) will become the first sketcher point.
659 The length coordinates are defined
660 in a local coordinate system which origin is the last point of the sketch
663 length - length of the segment
666 sk = geompy.Sketcher2D()
667 sk.addSegmentLength(100)
668 Sketcher_1 = sk.wire(geomObj_1)
670 self.myCommand = self.myCommand + ":L %s" % (printVar(length))
673 ## Add one straight segment, defined by previous direction and intersect straight x= param x.
674 # If the first point of sketcher is not yet defined, the
675 # origin (0, 0) will become the first sketcher point.
676 # The point's coordinates are defined
677 # in a local coordinate system which origin is the last point of the sketch
679 # @param x - value on the axis Ox
680 def addSegmentX (self, x ):
682 Add one straight segment, defined by previous direction and intersect straight x= param x.
683 If the first point of sketcher is not yet defined, the
684 origin (0, 0) will become the first sketcher point.
685 The point's coordinates are defined
686 in a local coordinate system which origin is the last point of the sketch
689 x - value on the axis Ox
692 sk = geompy.Sketcher2D()
694 Sketcher_1 = sk.wire(geomObj_1)
696 self.myCommand = self.myCommand + ":IX %s" % (printVar(x))
699 ## Add one straight segment, defined by previous direction and intersect straight y= param y.
700 # If the first point of sketcher is not yet defined, the
701 # origin (0, 0) will become the first sketcher point.
702 # The point's coordinates are defined
703 # in a local coordinate system which origin is the last point of the sketch
705 # @param y - value on the axis Oy
706 def addSegmentY (self, y ):
708 Add one straight segment, defined by previous direction and intersect straight y= param y.
709 If the first point of sketcher is not yet defined, the
710 origin (0, 0) will become the first sketcher point.
711 The point's coordinates are defined
712 in a local coordinate system which origin is the last point of the sketch
715 y - value on the axis Oy
718 sk = geompy.Sketcher2D()
720 Sketcher_1 = sk.wire(geomObj_1)
722 self.myCommand = self.myCommand + ":IY %s" % (printVar(y))
726 ## Add one straight segment, defined by direction and length.
727 # If the first point of sketcher is not yet defined, the
728 # origin (0, 0) will become the first sketcher point.
729 # The direction and length coordinates are defined
730 # in a local coordinate system which origin is the last point of the sketch
732 # @param dx, dy - direction of the segment
733 # @param length - length of the segment
734 def addSegmentDirectionLength (self, dx, dy, length ):
736 Add one straight segment, defined by direction and length.
737 If the first point of sketcher is not yet defined, the
738 origin (0, 0) will become the first sketcher point.
739 The direction and length coordinates are defined
740 in a local coordinate system which origin is the last point of the sketch
743 dx, dy - direction of the segment
744 length - length of the segment
747 sk = geompy.Sketcher2D()
748 sk.addSegmentDirectionLength(20, 40, 30)
749 Sketcher_1 = sk.wire(geomObj_1)
751 self.myCommand = self.myCommand + ":D %s %s:L %s" % (printVar(dx), printVar(dy), printVar(length))
754 ## Add one straight segment, defined by direction and intersect straight x= param x.
755 # If the first point of sketcher is not yet defined, the
756 # origin (0, 0) will become the first sketcher point.
757 # The direction and point's coordinates are defined
758 # in a local coordinate system which origin is the last point of the sketch
760 # @param dx, dy - direction of the segment
761 # @param x - value on the axis Ox
762 def addSegmentDirectionX (self, dx, dy, x ):
764 Add one straight segment, defined by direction and intersect straight x= param x.
765 If the first point of sketcher is not yet defined, the
766 origin (0, 0) will become the first sketcher point.
767 The direction and point's coordinates are defined
768 in a local coordinate system which origin is the last point of the sketch
771 dx, dy - direction of the segment
772 x - value on the axis Ox
775 sk = geompy.Sketcher2D()
776 sk.addSegmentDirectionX(10, -40, 20)
777 Sketcher_1 = sk.wire(geomObj_1)
779 self.myCommand = self.myCommand + ":D %s %s:IX %s" % (printVar(dx), printVar(dy), printVar(x))
782 ## Add one straight segment, defined by direction and intersect straight y= param y.
783 # If the first point of sketcher is not yet defined, the
784 # origin (0, 0) will become the first sketcher point.
785 # The direction and point's coordinates are defined
786 # in a local coordinate system which origin is the last point of the sketch
788 # @param dx, dy - direction of the segment
789 # @param y - value on the axis Oy
790 def addSegmentDirectionY (self, dx, dy, y ):
792 Add one straight segment, defined by direction and intersect straight y= param y.
793 If the first point of sketcher is not yet defined, the
794 origin (0, 0) will become the first sketcher point.
795 The direction and point's coordinates are defined
796 in a local coordinate system which origin is the last point of the sketch
799 dx, dy - direction of the segment
800 y - value on the axis Oy
803 sk = geompy.Sketcher2D()
804 sk.addSegmentDirectionY(-10, -50, 20)
805 Sketcher_1 = sk.wire(geomObj_1)
807 self.myCommand = self.myCommand + ":D %s %s:IY %s" % (printVar(dx), printVar(dy), printVar(y))
810 # Commands for creation of arc
812 ## Add arc, which connects the given point with previous point
813 # Coordinates are considered as absolute.
814 # If the first point of sketcher is not yet defined, the
815 # origin (0, 0) will become the first sketcher point.
817 # @param x, y - Coordinates of second point of arc
818 def addArcAbsolute (self, x, y ):
820 Add arc, which connects the given point with previous point
821 Coordinates are considered as absolute.
822 If the first point of sketcher is not yet defined, the
823 origin (0, 0) will become the first sketcher point.
826 param x, y - Coordinates of second point of arc
829 sk = geompy.Sketcher2D()
830 sk.addArcAbsolute(50, 10)
831 Sketcher_1 = sk.wire(geomObj_1)
833 self.myCommand = self.myCommand + ":AA %s %s" % (printVar(x), printVar(y))
836 ## Add arc, which connects the given point with previous point
837 # Coordinates are considered relative to the previous point.
839 # @param dx, dy - Coordinates of second point of arc relative to the previous point
840 def addArcRelative (self, dx, dy ):
842 Add arc, which connects the given point with previous point
843 Coordinates are considered relative to the previous point.
846 param dx, dy - Coordinates of second point of arc
849 sk = geompy.Sketcher2D()
850 sk.addArcRelative(50, 10)
851 Sketcher_1 = sk.wire(geomObj_1)
853 self.myCommand = self.myCommand + ":A %s %s" % (printVar(dx), printVar(dy))
856 ## Add arc, defined by radius and coordinates of next point.
857 # Coordinates are considered as absolute.
858 # If the first point of sketcher is not yet defined, the
859 # origin (0, 0) will become the first sketcher point.
861 # @param x, y - Coordinates of second point of arc
862 # @param radius - radius of arc
863 # @param flag - is 0 or 2
864 # if 0 the drawn arc is the one of lower angle (<Pi)
865 # if 2 the drawn arc is the one of greater angle (>Pi)
866 def addArcRadiusAbsolute (self, x, y, radius, flag ):
868 Add arc, defined by radius and coordinates of next point.
869 Coordinates are considered as absolute.
870 If the first point of sketcher is not yet defined, the
871 origin (0, 0) will become the first sketcher point.
874 param x, y - Coordinates of second point of arc
875 param radius - radius of arc
876 param flag - is 0 or 2
877 if 0 the drawn arc is the one of lower angle (<Pi)
878 if 2 the drawn arc is the one of greater angle (>Pi)
881 sk = geompy.Sketcher2D()
882 sk.addArcRadiusAbsolute(50, 10, 20, 0)
883 Sketcher_1 = sk.wire(geomObj_1)
885 self.myCommand = self.myCommand + ":UU %s %s %s %s" % (printVar(x), printVar(y), printVar(radius), printVar(flag))
888 ## Add arc, defined by radius and coordinates of next point.
889 # Coordinates are considered relative to the previous point.
891 # @param dx, dy - Coordinates of second point of arc
892 # @param radius - radius of arc
893 # @param flag - is 0 or 2
894 # if 0 the drawn arc is the one of lower angle (<Pi)
895 # if 2 the drawn arc is the one of greater angle (>Pi)
896 def addArcRadiusRelative (self, dx, dy, radius, flag ):
898 Add arc, defined by radius and coordinates of next point.
899 Coordinates are considered relative to the previous point.
902 param dx, dy - Coordinates of second point of arc
903 param radius - radius of arc
904 param flag - is 0 or 2
905 if 0 the drawn arc is the one of lower angle (<Pi)
906 if 2 the drawn arc is the one of greater angle (>Pi)
909 sk = geompy.Sketcher2D()
910 sk.addArcRadiusRelative(-30, -15, 20, 2)
911 Sketcher_1 = sk.wire(geomObj_1)
913 self.myCommand = self.myCommand + ":U %s %s %s %s" % (printVar(dx), printVar(dy), printVar(radius), printVar(flag))
916 ## Add arc, defined by coordinates of next point and coordinates of center.
917 # Coordinates are considered as absolute.
918 # If the first point of sketcher is not yet defined, the
919 # origin (0, 0) will become the first sketcher point.
921 # @param x, y - Coordinates of second point of arc
922 # @param xc, yc - Coordinates of center
923 # @param flag1 - (reverse) is 0 or 2
924 # if 0 the drawn arc is the one of lower angle (<Pi)
925 # if 2 the drawn arc is the one of greater angle (>Pi)
926 # @param flag2 - (control tolerance) is 0 or 1
927 # if 0 the specified end point can be at a distance of the arc
928 def addArcCenterAbsolute (self, x, y, xc, yc, flag1, flag2 ):
930 Add arc, defined by coordinates of next point and coordinates of center.
931 Coordinates are considered as absolute.
932 If the first point of sketcher is not yet defined, the
933 origin (0, 0) will become the first sketcher point.
936 param x, y - Coordinates of second point of arc
937 param xc, yc - Coordinates of center
938 param flag1 - is 0 or 2
939 if 0 the drawn arc is the one of lower angle (<Pi)
940 if 2 the drawn arc is the one of greater angle (>Pi)
941 param flag2 - (control tolerance) is 0 or 1
942 if 0 the specified end point can be at a distance of the arc
945 sk = geompy.Sketcher2D()
946 sk.addArcCenterAbsolute(-30, -15, 20, 10, 0, 0)
947 Sketcher_1 = sk.wire(geomObj_1)
949 self.myCommand = self.myCommand + ":EE %s %s %s %s %s %s" % (printVar(xc), printVar(yc), printVar(x), printVar(y),
950 printVar(flag1), printVar(flag2))
953 ## Add arc, defined by coordinates of next point and coordinates of center.
954 # Coordinates are considered relative to the previous point.
956 # @param dx, dy - Coordinates of second point of arc
957 # @param xc, yc - Coordinates of center
958 # @param flag1 - (reverse) is 0 or 2
959 # if 0 the drawn arc is the one of lower angle (<Pi)
960 # if 2 the drawn arc is the one of greater angle (>Pi)
961 # @param flag2 - (control tolerance) is 0 or 1
962 # if 0 the specified end point can be at a distance of the arc
963 def addArcCenterRelative (self, dx, dy, xc, yc, flag1, flag2 ):
965 Add arc, defined by coordinates of next point and coordinates of center.
966 Coordinates are considered relative to the previous point.
969 param dx, dy - Coordinates of second point of arc
970 param xc, yc - Coordinates of center
971 param flag1 - is 0 or 2
972 if 0 the drawn arc is the one of lower angle (<Pi)
973 if 2 the drawn arc is the one of greater angle (>Pi)
974 param flag2 - (control tolerance) is 0 or 1
975 if 0 the specified end point can be at a distance of the arc
978 sk = geompy.Sketcher2D()
979 sk.addArcCenterRelative(-30, -15, 20, 10, 2, 1)
980 Sketcher_1 = sk.wire(geomObj_1)
982 self.myCommand = self.myCommand + ":E %s %s %s %s %s %s" % (printVar(xc), printVar(yc), printVar(dx), printVar(dy),
983 printVar(flag1), printVar(flag2))
986 ## Add arc, defined by angle, radius and length.
987 # If the first point of sketcher is not yet defined, the
988 # origin (0, 0) will become the first sketcher point.
990 # @param angle - angle in a plane
991 # @param radius - radius of the arc
992 # @param length - length of the arc
993 def addArcAngleRadiusLength (self, angle, radius, length ):
995 Add arc, defined by angle, radius and length.
996 If the first point of sketcher is not yet defined, the
997 origin (0, 0) will become the first sketcher point.
1000 param angle - angle in a plane
1001 param radius - radius of the arc
1002 param length - length of the arc
1005 sk = geompy.Sketcher2D()
1006 sk.addArcAngleRadiusLength(30, 15, 40)
1007 Sketcher_1 = sk.wire(geomObj_1)
1009 self.myCommand = self.myCommand + ":R %s:C %s %s" % (printVar(angle), printVar(radius), printVar(length))
1012 ## Add arc, defined by perpendicular(angle=90), radius and length.
1013 # If the first point of sketcher is not yet defined, the
1014 # origin (0, 0) will become the first sketcher point.
1016 # @param radius - radius of the arc
1017 # @param length - length of the arc
1018 def addArcPerpRadiusLength (self, radius, length ):
1020 Add arc, defined by perpendicular(angle=90), radius and length.
1021 If the first point of sketcher is not yet defined, the
1022 origin (0, 0) will become the first sketcher point.
1025 param radius - radius of the arc
1026 param length - length of the arc
1029 sk = geompy.Sketcher2D()
1030 sk.addArcPerpRadiusLength(15, 40)
1031 Sketcher_1 = sk.wire(geomObj_1)
1033 self.myCommand = self.myCommand + ":R 90:C %s %s" % (printVar(radius), printVar(length))
1036 ## Add arc, defined by previous direction, radius and length.
1037 # If the first point of sketcher is not yet defined, the
1038 # origin (0, 0) will become the first sketcher point.
1040 # @param radius - radius of the arc
1041 # @param length - length of the arc
1042 def addArcRadiusLength (self, radius, length ):
1044 Add arc, defined by previous direction, radius and length.
1045 If the first point of sketcher is not yet defined, the
1046 origin (0, 0) will become the first sketcher point.
1049 param radius - radius of the arc
1050 param length - length of the arc
1053 sk = geompy.Sketcher2D()
1054 sk.addArcRadiusLength(15, 40)
1055 Sketcher_1 = sk.wire(geomObj_1)
1057 self.myCommand = self.myCommand + ":C %s %s" % (printVar(radius), printVar(length))
1060 ## Add arc, defined by direction, radius and length.
1061 # If the first point of sketcher is not yet defined, the
1062 # origin (0, 0) will become the first sketcher point.
1064 # @param dx, dy - direction of the arc
1065 # @param radius - radius of the arc
1066 # @param length - length of the arc
1067 def addArcDirectionRadiusLength (self, dx, dy, radius, length ):
1069 Add arc, defined by direction, radius and length.
1070 If the first point of sketcher is not yet defined, the
1071 origin (0, 0) will become the first sketcher point.
1074 param dx, dy - direction of the arc
1075 param radius - radius of the arc
1076 param length - length of the arc
1079 sk = geompy.Sketcher2D()
1080 sk.addArcDirectionRadiusLength(-50, 40, 20, 3.5)
1081 Sketcher_1 = sk.wire(geomObj_1)
1083 self.myCommand = self.myCommand + ":D %s %s:C %s %s" % (printVar(dx), printVar(dy), printVar(radius), printVar(length))
1086 ## Set to close the wire
1089 Set to close the wire
1092 sk = geompy.Sketcher2D()
1093 sk.addPoint(15, 85.6)
1095 Sketcher_1 = sk.wire(geomObj_1)
1100 ## Obtain the sketcher result as a wire.
1102 # @param WorkingPlane - current Working Plane used for this 2DSketcher
1103 # @param theName Object name; when specified, this parameter is used
1104 # for result publication in the study. Otherwise, if automatic
1105 # publication is switched on, default value is used for result name.
1107 # @return New GEOM_Object, containing the created wire
1108 def wire (self, WorkingPlane=[0, 0, 0, 0, 0, 1, 1, 0, 0], theName=None):
1110 Obtain the sketcher result as a wire.
1113 theName Object name; when specified, this parameter is used
1114 for result publication in the study. Otherwise, if automatic
1115 publication is switched on, default value is used for result name
1116 param WorkingPlane - current Working Plane used for this 2DSketcher
1119 New GEOM_Object, containing the created wire.
1122 sk = geompy.Sketcher2D()
1124 a3D_Sketcher_1 = sk.wire(geomObj_1)
1128 self.myCommand = self.myCommand + ":WW"
1131 if isinstance(WorkingPlane, list): wire = self.geompyD.CurvesOp.MakeSketcher(self.myCommand, WorkingPlane)
1132 if isinstance(WorkingPlane, GEOM._objref_GEOM_Object): wire = self.geompyD.CurvesOp.MakeSketcherOnPlane(self.myCommand, WorkingPlane)
1134 self.myCommand = "Sketcher"
1135 self.geompyD._autoPublish(wire, theName, "wire")
1138 ## Obtain the sketcher result as a face.
1140 # @param WorkingPlane - current Working Plane used for this 2DSketcher
1141 # @param theName Object name; when specified, this parameter is used
1142 # for result publication in the study. Otherwise, if automatic
1143 # publication is switched on, default value is used for result name.
1145 # @return New GEOM_Object, containing the created face
1146 def face (self, WorkingPlane=[0, 0, 0, 0, 0, 1, 1, 0, 0], theName=None):
1148 Obtain the sketcher result as a face.
1151 theName Object name; when specified, this parameter is used
1152 for result publication in the study. Otherwise, if automatic
1153 publication is switched on, default value is used for result name
1154 param WorkingPlane - current Working Plane used for this 2DSketcher
1157 New GEOM_Object, containing the created face.
1160 sk = geompy.Sketcher2D()
1162 sk.addSegment(100, 0)
1163 sk.addSegment(100, 100)
1164 sk.addSegment(0, 100)
1166 a3D_Sketcher_1 = sk.face(geomObj_1)
1170 self.myCommand = self.myCommand + ":WF"
1172 raise RuntimeError, "Sketcher2D.close() : can't build face on unclosed wire"
1175 if isinstance(WorkingPlane, list): face = self.geompyD.CurvesOp.MakeSketcher(self.myCommand, WorkingPlane)
1176 if isinstance(WorkingPlane, GEOM._objref_GEOM_Object): face = self.geompyD.CurvesOp.MakeSketcherOnPlane(self.myCommand, WorkingPlane)
1178 self.myCommand = "Sketcher"
1179 self.geompyD._autoPublish(face, theName, "face")