Creates a new 2D workplane, located relative to the first face on the stack. :param offset: offset for the workplane in its normal direction . Default :param invert: invert the normal direction from that of the face. :param centerOption: how local origin of workpl
(
self: T,
offset: float = 0.0,
invert: bool = False,
centerOption: Literal[
"CenterOfMass", "ProjectedOrigin", "CenterOfBoundBox"
] = "ProjectedOrigin",
origin: Optional[VectorLike] = None,
)
| 457 | return v._faces if isinstance(v, Sketch) else v.wrapped |
| 458 | |
| 459 | def workplane( |
| 460 | self: T, |
| 461 | offset: float = 0.0, |
| 462 | invert: bool = False, |
| 463 | centerOption: Literal[ |
| 464 | "CenterOfMass", "ProjectedOrigin", "CenterOfBoundBox" |
| 465 | ] = "ProjectedOrigin", |
| 466 | origin: Optional[VectorLike] = None, |
| 467 | ) -> T: |
| 468 | """ |
| 469 | Creates a new 2D workplane, located relative to the first face on the stack. |
| 470 | |
| 471 | :param offset: offset for the workplane in its normal direction . Default |
| 472 | :param invert: invert the normal direction from that of the face. |
| 473 | :param centerOption: how local origin of workplane is determined. |
| 474 | :param origin: origin for plane center, requires 'ProjectedOrigin' centerOption. |
| 475 | :type centerOption: string or None='ProjectedOrigin' |
| 476 | :rtype: Workplane object |
| 477 | |
| 478 | The first element on the stack must be a face, a set of |
| 479 | co-planar faces or a vertex. If a vertex, then the parent |
| 480 | item on the chain immediately before the vertex must be a |
| 481 | face. |
| 482 | |
| 483 | The result will be a 2D working plane |
| 484 | with a new coordinate system set up as follows: |
| 485 | |
| 486 | * The centerOption parameter sets how the center is defined. |
| 487 | Options are 'CenterOfMass', 'CenterOfBoundBox', or 'ProjectedOrigin'. |
| 488 | 'CenterOfMass' and 'CenterOfBoundBox' are in relation to the selected |
| 489 | face(s) or vertex (vertices). 'ProjectedOrigin' uses by default the current origin |
| 490 | or the optional origin parameter (if specified) and projects it onto the plane |
| 491 | defined by the selected face(s). |
| 492 | * The Z direction will be the normal of the face, computed |
| 493 | at the center point. |
| 494 | * The X direction will be parallel to the x-y plane. If the workplane is parallel to |
| 495 | the global x-y plane, the x direction of the workplane will co-incide with the |
| 496 | global x direction. |
| 497 | |
| 498 | Most commonly, the selected face will be planar, and the workplane lies in the same plane |
| 499 | of the face ( IE, offset=0). Occasionally, it is useful to define a face offset from |
| 500 | an existing surface, and even more rarely to define a workplane based on a face that is |
| 501 | not planar. |
| 502 | """ |
| 503 | |
| 504 | def _isCoPlanar(f0, f1): |
| 505 | """Test if two faces are on the same plane.""" |
| 506 | p0 = f0.Center() |
| 507 | p1 = f1.Center() |
| 508 | n0 = f0.normalAt() |
| 509 | n1 = f1.normalAt() |
| 510 | |
| 511 | # test normals (direction of planes) |
| 512 | if not ( |
| 513 | (abs(n0.x - n1.x) < self.ctx.tolerance) |
| 514 | or (abs(n0.y - n1.y) < self.ctx.tolerance) |
| 515 | or (abs(n0.z - n1.z) < self.ctx.tolerance) |
| 516 | ): |