From 37803a6d670bdbdb10763c9b000f6d1f30645068 Mon Sep 17 00:00:00 2001 From: Roger Maitland Date: Fri, 4 Nov 2022 17:54:46 -0400 Subject: [PATCH] Minor pylint changes direct_api @ 9.88 --- docs/direct_api_classes.svg | 446 ++++++++++++++++++------------------ src/build123d/direct_api.py | 30 +-- 2 files changed, 235 insertions(+), 241 deletions(-) diff --git a/docs/direct_api_classes.svg b/docs/direct_api_classes.svg index 0950e12..0def1ee 100644 --- a/docs/direct_api_classes.svg +++ b/docs/direct_api_classes.svg @@ -4,34 +4,34 @@ - - + + classes - + build123d.direct_api.Axis - -Axis - -X -Y -Z -direction -position -wrapped - -angle_between(other: Axis): float -copy(): Axis -from_occt(cls: gp_Ax1, axis): Axis -is_coaxial(other: Axis, angular_tolerance: float, linear_tolerance: float): bool -is_normal(other: Axis, angular_tolerance: float): bool -is_opposite(other: Axis, angular_tolerance: float): bool -is_parallel(other: Axis, angular_tolerance: float): bool -reversed(): Axis -to_location(): Location -to_plane(): Plane + +Axis + +X +Y +Z +direction +position +wrapped + +angle_between(other: Axis): float +copy(): Axis +from_occt(cls: gp_Ax1, axis): Axis +is_coaxial(other: Axis, angular_tolerance: float, linear_tolerance: float): bool +is_normal(other: Axis, angular_tolerance: float): bool +is_opposite(other: Axis, angular_tolerance: float): bool +is_parallel(other: Axis, angular_tolerance: float): bool +reversed(): Axis +to_location(): Location +to_plane(): Plane @@ -59,52 +59,52 @@ build123d.direct_api.Plane - -Plane - -XY -XZ -YX -YZ -ZX -ZY -back -bottom -forward_transform -front -left -local_coord_system -origin -origin -reverse_transform -right -top -wrapped -x_dir : NoneType -y_dir -z_dir - -contains(obj: Union[VectorLike, Axis], tolerance: float): bool -from_local_coords(obj: Union[tuple, Vector, Shape, BoundBox]) -rotated(rotate: VectorLike): Plane -set_origin2d(x, y) -to_gp_ax2(): gp_Ax2 -to_local_coords(obj: Union[VectorLike, Shape, BoundBox]) -to_location(): Location + +Plane + +XY +XZ +YX +YZ +ZX +ZY +back +bottom +forward_transform : Optional[Matrix] +front +left +local_coord_system : Optional[gp_Ax3] +origin +origin +reverse_transform : Optional[Matrix] +right +top +wrapped +x_dir : NoneType +y_dir +z_dir + +contains(obj: Union[VectorLike, Axis], tolerance: float): bool +from_local_coords(obj: Union[tuple, Vector, Shape, BoundBox]) +rotated(rotate: VectorLike): Plane +set_origin2d(x, y) +to_gp_ax2(): gp_Ax2 +to_local_coords(obj: Union[VectorLike, Shape, BoundBox]) +to_location(): Location build123d.direct_api.BoundBox->build123d.direct_api.Plane - - -_origin + + +_origin build123d.direct_api.BoundBox->build123d.direct_api.Plane - - -origin + + +origin @@ -125,7 +125,7 @@ build123d.direct_api.Mixin3D - + Mixin3D @@ -133,59 +133,59 @@ dprism(basis: Optional[Face], bounds: list[Union[Face, Wire]], depth: float, taper: float, up_to_face: Face, thru_all: bool, additive: bool): Solid fillet(radius: float, edge_list: Iterable[Edge]) is_inside(point: VectorLike, tolerance: float): bool -shell(face_list: Optional[Iterable[Face]], thickness: float, tolerance: float, kind: Kind): Solid +max_fillet(edge_list: Iterable[Edge], tolerance, max_iterations: int): float +shell(faces: Optional[Iterable[Face]], thickness: float, tolerance: float, kind: Kind): Solid build123d.direct_api.Compound->build123d.direct_api.Mixin3D - - + + build123d.direct_api.Shape - -Shape - -area -for_construction : bool -label : str -location -orientation -position -volume -wrapped - -bounding_box(tolerance: float): BoundBox -cast(cls: TopoDS_Shape, obj: bool, for_construction): Shape -clean(): Shape -combined_center(objects: CenterOf, center_of): Vector -compounds(): ShapeList['Compound'] -compute_mass(obj): float -copy(): Shape -cut(): Shape -distance(other: Shape): float -distances(): Iterator[float] -edges(): ShapeList['Edge'] -export_brep(f: Union[str, BytesIO]): bool -export_step(file_name: str): IFSelect_ReturnStatus -export_stl(file_name: str, tolerance: float, angular_tolerance: float, ascii_format: bool): bool -faces(): ShapeList['Face'] -faces_intersected_by_line(point: VectorLike, axis: VectorLike, tol: float, direction: Direction): ShapeList[Face] -find_intersection(point: VectorLike, direction: VectorLike): list[tuple[Vector, Vector]] -fix(): Shape -fuse(): Shape -geom_type(): Geoms -hash_code(): int -import_brep(cls: Union[str, BytesIO], f): Shape -intersect(): Shape -is_equal(other: Shape): bool -is_null(): bool -is_same(other: Shape): bool -is_valid(): bool -locate(loc: Location): Shape -located(loc: Location): Shape -max_fillet(edge_list: Iterable[Edge], tolerance, max_iterations: int): float + +Shape + +area +for_construction : bool +label : str +location +orientation +position +volume +wrapped + +bounding_box(tolerance: float): BoundBox +cast(cls: TopoDS_Shape, obj: bool, for_construction): Shape +clean(): Shape +combined_center(objects: CenterOf, center_of): Vector +compounds(): ShapeList['Compound'] +compute_mass(obj): float +copy(): Shape +cut(): Shape +distance(other: Shape): float +distances(): Iterator[float] +edges(): ShapeList['Edge'] +export_brep(file: Union[str, BytesIO]): bool +export_step(file_name: str): IFSelect_ReturnStatus +export_stl(file_name: str, tolerance: float, angular_tolerance: float, ascii_format: bool): bool +faces(): ShapeList['Face'] +faces_intersected_by_line(point: VectorLike, axis: VectorLike, tol: float, direction: Direction): ShapeList[Face] +find_intersection(point: VectorLike, direction: VectorLike): list[tuple[Vector, Vector]] +fix(): Shape +fuse(): Shape +geom_type(): Geoms +hash_code(): int +import_brep(cls: Union[str, BytesIO], file): Shape +intersect(): Shape +is_equal(other: Shape): bool +is_null(): bool +is_same(other: Shape): bool +is_valid(): bool +locate(loc: Location): Shape +located(loc: Location): Shape mesh(tolerance: float, angular_tolerance: float) mirror(mirror_plane: Plane): Shape move(loc: Location): Shape @@ -209,8 +209,8 @@ build123d.direct_api.Compound->build123d.direct_api.Shape - - + + @@ -224,47 +224,47 @@ distribute_locations(count: int, start: float, stop: float, positions_only: bool): list[Location] make_circle(cls: float, radius: Plane, plane: float, start_angle: float, end_angle: AngularDirection, angular_direction): Edge make_ellipse(cls: float, x_radius: float, y_radius: Plane, plane: float, start_angle: float, end_angle: AngularDirection, angular_direction): Edge -make_line(cls: VectorLike, v1: VectorLike, v2): Edge +make_line(cls: VectorLike, point1: VectorLike, point2): Edge make_spline(cls: list[VectorLike], points: list[VectorLike], tangents: bool, periodic: list[float], parameters: bool, scale: float, tol): Edge make_spline_approx(cls: list[VectorLike], points: float, tol: Tuple[float, float, float], smoothing: int, min_deg: int, max_deg): Edge make_tangent_arc(cls: VectorLike, start: VectorLike, tangent: VectorLike, end): Edge -make_three_point_arc(cls: VectorLike, v1: VectorLike, v2: VectorLike, v3): Edge +make_three_point_arc(cls: VectorLike, point1: VectorLike, point2: VectorLike, point3): Edge project_to_shape(target_object: Shape, direction: VectorLike, center: VectorLike): list[Edge] to_wire(): Wire build123d.direct_api.Mixin1D - -Mixin1D - -length -radius - -center(center_of: CenterOf): Vector -end_point(): Vector -is_closed(): bool -location_at(distance: float, position_mode: PositionMode, frame_method: FrameMethod, planar: bool): Location -locations(ds: Iterable[float], position_mode: PositionMode, frame_method: FrameMethod, planar: bool): list[Location] -normal(): Vector -param_at(distance: float): float -position_at(d: float, position_mode: PositionMode): Vector -positions(ds: Iterable[float], position_mode: PositionMode): list[Vector] -project(face: Face, d: VectorLike, closest: bool): Union[Mixin1D, list[Mixin1D]] -start_point(): Vector -tangent_at(location_param: float, position_mode: PositionMode): Vector + +Mixin1D + +length +radius + +center(center_of: CenterOf): Vector +end_point(): Vector +is_closed(): bool +location_at(distance: float, position_mode: PositionMode, frame_method: FrameMethod, planar: bool): Location +locations(distances: Iterable[float], position_mode: PositionMode, frame_method: FrameMethod, planar: bool): list[Location] +normal(): Vector +param_at(distance: float): float +position_at(distance: float, position_mode: PositionMode): Vector +positions(distances: Iterable[float], position_mode: PositionMode): list[Vector] +project(face: Face, direction: VectorLike, closest: bool): Union[Mixin1D, list[Mixin1D]] +start_point(): Vector +tangent_at(location_param: float, position_mode: PositionMode): Vector build123d.direct_api.Edge->build123d.direct_api.Mixin1D - - + + build123d.direct_api.Edge->build123d.direct_api.Shape - - + + @@ -274,8 +274,8 @@ center(center_of) -chamfer_2d(d: float, vertices: Iterable[Vertex]): Face -construct_on(cls: Face, f: Wire, outer): Face +chamfer_2d(distance: float, vertices: Iterable[Vertex]): Face +construct_on(cls: Face, face: Wire, outer): Face fillet_2d(radius: float, vertices: Iterable[Vertex]): Face inner_wires(): list[Wire] is_inside(point: VectorLike, tolerance: float): bool @@ -285,11 +285,11 @@ make_rect(cls: float, width: float, height: VectorLike, pnt: VectorLike, normal): Face make_ruled_surface(cls: Edge, edge1: Edge, edge2): Face make_surface(cls: Union[Wire, list[Edge]], exterior: list[VectorLike], surface_points: list[Wire], interior_wires): Face -make_surface_from_curves(cls, curve1, curve2): Face +make_surface_from_curves(cls: Union[Edge, Wire], curve1: Union[Edge, Wire], curve2): Face make_surface_from_points(cls: list[list[VectorLike]], points: float, tol: Tuple[float, float, float], smoothing: int, min_deg: int, max_deg): Face normal_at(surface_point: VectorLike): Vector outer_wire(): Wire -project(other: Face, d: VectorLike): Face +project(other: Face, direction: VectorLike): Face project_to_shape(target_object: Shape, direction: VectorLike, center: VectorLike, internal_face_points: list[Vector]): list[Face] thicken(depth: float, direction: VectorLike): Solid to_pln(): gp_Pln @@ -297,21 +297,21 @@ build123d.direct_api.Face->build123d.direct_api.Shape - - + + build123d.direct_api.Location - -Location - -orientation -position -wrapped - -inverse(): Location -to_tuple(): tuple[tuple[float, float, float], tuple[float, float, float]] + +Location + +orientation +position +wrapped + +inverse(): Location +to_tuple(): tuple[tuple[float, float, float], tuple[float, float, float]] @@ -331,46 +331,46 @@ build123d.direct_api.Matrix->build123d.direct_api.Plane - - + + reverse_transform build123d.direct_api.Matrix->build123d.direct_api.Plane - - + + forward_transform build123d.direct_api.Rotation - -Rotation - -about_x : float -about_y : float -about_z : float - - + +Rotation + +about_x : float +about_y : float +about_z : float + + build123d.direct_api.Rotation->build123d.direct_api.Location - - + + build123d.direct_api.ShapeList - -ShapeList - - -filter_by(filter_by: Union[Axis, GeomType], reverse: bool, tolerance: float): ShapeList -filter_by_position(axis: Axis, minimum: float, maximum: float, inclusive: tuple[bool, bool]) -group_by(group_by: Union[Axis, SortBy], reverse, tol_digits) -sort_by(sort_by: Union[Axis, SortBy], reverse: bool) + +ShapeList + + +filter_by(filter_by: Union[Axis, GeomType], reverse: bool, tolerance: float): ShapeList +filter_by_position(axis: Axis, minimum: float, maximum: float, inclusive: tuple[bool, bool]) +group_by(group_by: Union[Axis, SortBy], reverse, tol_digits) +sort_by(sort_by: Union[Axis, SortBy], reverse: bool) @@ -384,8 +384,8 @@ build123d.direct_api.Shell->build123d.direct_api.Shape - - + + @@ -405,7 +405,7 @@ make_solid(cls: Shell, shell): Solid make_sphere(cls: float, radius: Plane, plane: float, angle1: float, angle2: float, angle3): Shape make_torus(cls: float, major_radius: float, minor_radius: Plane, plane: float, start_angle: float, end_angle): Solid -make_wedge(cls: float, dx: float, dy: float, dz: float, xmin: float, zmin: float, xmax: float, zmax: Plane, plane): Solid +make_wedge(cls: float, delta_x: float, delta_y: float, delta_z: float, min_x: float, min_z: float, max_x: float, max_z: Plane, plane): Solid revolve(cls: Union[Face, Wire], section: float, angle: Axis, axis: list[Wire], inner_wires): Solid sweep(cls: Union[Face, Wire], section: Union[Wire, Edge], path: list[Wire], inner_wires: bool, make_solid: bool, is_frenet: Union[Vector, Wire, Edge, None], mode: Transition, transition): Solid sweep_multi(cls: Iterable[Union[Wire, Face]], profiles: Union[Wire, Edge], path: bool, make_solid: bool, is_frenet: Union[Vector, Wire, Edge, None], mode): Solid @@ -413,14 +413,14 @@ build123d.direct_api.Solid->build123d.direct_api.Mixin3D - - + + build123d.direct_api.Solid->build123d.direct_api.Shape - - + + @@ -461,121 +461,121 @@ build123d.direct_api.Vector->build123d.direct_api.Axis - - + + position build123d.direct_api.Vector->build123d.direct_api.Axis - - + + direction build123d.direct_api.Vector->build123d.direct_api.Plane - - + + _origin build123d.direct_api.Vector->build123d.direct_api.Plane - - + + _origin build123d.direct_api.Vector->build123d.direct_api.Plane - - + + _origin build123d.direct_api.Vector->build123d.direct_api.Plane - - + + _origin build123d.direct_api.Vector->build123d.direct_api.Plane - - + + _origin build123d.direct_api.Vector->build123d.direct_api.Plane - - + + x_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + x_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + x_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + z_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + z_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + z_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + z_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - + + y_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - -y_dir + + +y_dir build123d.direct_api.Vector->build123d.direct_api.Plane - - -origin + + +origin @@ -595,8 +595,8 @@ build123d.direct_api.Vertex->build123d.direct_api.Shape - - + + @@ -605,9 +605,9 @@ Wire -chamfer_2d(d: float, vertices: Iterable[Vertex]): Wire +chamfer_2d(distance: float, vertices: Iterable[Vertex]): Wire close(): Wire -combine(cls: Iterable[Union[Wire, Edge]], list_of_wires: float, tol): list[Wire] +combine(cls: Iterable[Union[Wire, Edge]], wires: float, tol): list[Wire] fillet_2d(radius: float, vertices: Iterable[Vertex]): Wire make_circle(cls: float, radius: Plane, plane): Wire make_ellipse(cls: float, x_radius: float, y_radius: Plane, plane: float, start_angle: float, end_angle: AngularDirection, angular_direction: bool, closed): Wire @@ -615,7 +615,7 @@ make_polygon(cls: Iterable[VectorLike], vertices: bool, close): Wire make_rect(cls: float, width: float, height: VectorLike, pnt: VectorLike, normal): Wire make_wire(cls: Iterable[Edge], edges: bool, sequenced): Wire -offset_2d(d: float, kind: Kind): list[Wire] +offset_2d(distance: float, kind: Kind): list[Wire] project_to_shape(target_object: Shape, direction: VectorLike, center: VectorLike): list[Wire] stitch(other: Wire): Wire to_wire(): Wire @@ -623,14 +623,14 @@ build123d.direct_api.Wire->build123d.direct_api.Mixin1D - - + + build123d.direct_api.Wire->build123d.direct_api.Shape - - + + diff --git a/src/build123d/direct_api.py b/src/build123d/direct_api.py index 46a2fe1..fdfaef6 100644 --- a/src/build123d/direct_api.py +++ b/src/build123d/direct_api.py @@ -587,7 +587,7 @@ class Vector: Returns: """ - base = plane._origin + base = plane.origin normal = plane.z_dir return self - normal * (((self - base).dot(normal)) / normal.length**2) @@ -2071,8 +2071,8 @@ class Shape: starting point for a range of cases. Defaults to 1e-3. angular_tolerance (float, optional): Angular deflection setting which limits the angle between subsequent segments in a polyline. Defaults to 0.1. - ascii_format (bool, optional): Export the file as ASCII (True) or binary (False) STL format. - Defaults to False (binary). + ascii_format (bool, optional): Export the file as ASCII (True) or binary (False) + STL format. Defaults to False (binary). Returns: bool: Success @@ -3788,7 +3788,7 @@ class Plane: return axis def _to_from_local_coords( - self, obj: Union[VectorLike, Shape, BoundBox], to: bool = True + self, obj: Union[VectorLike, Shape, BoundBox], to_from: bool = True ): """_to_from_local_coords @@ -3796,7 +3796,7 @@ class Plane: Args: obj (Union[VectorLike, Shape, BoundBox]): an object to reposition - to (bool, optional): direction of transformation. Defaults to True. + to_from (bool, optional): direction of transformation. Defaults to True (to). Raises: ValueError: Unsupported object type @@ -3805,7 +3805,7 @@ class Plane: an object of the same type, but repositioned to local coordinates """ - transform_matrix = self.forward_transform if to else self.reverse_transform + transform_matrix = self.forward_transform if to_from else self.reverse_transform if isinstance(obj, (tuple, Vector)): return_value = Vector(obj).transform(transform_matrix) @@ -4358,7 +4358,7 @@ class Edge(Shape, Mixin1D): """ points = [Vector(point) for point in points] if tangents: - tangents = tuple([Vector(v) for v in tangents]) + tangents = tuple(Vector(v) for v in tangents) pnts = TColgp_HArray1OfPnt(1, len(points)) for i, point in enumerate(points): pnts.SetValue(i + 1, point.to_pnt()) @@ -5155,7 +5155,6 @@ class Face(Shape): # Phase 1 - outer wire planar_outer_wire = self.outer_wire() - planar_outer_wire_orientation = planar_outer_wire.wrapped.Orientation() projected_outer_wires = planar_outer_wire.project_to_shape( target_object, direction_vector, center_point ) @@ -5165,7 +5164,7 @@ class Face(Shape): # Phase 2 - inner wires planar_inner_wire_list = [ w - if w.wrapped.Orientation() != planar_outer_wire_orientation + if w.wrapped.Orientation() != planar_outer_wire.wrapped.Orientation() else Wire(w.wrapped.Reversed()) for w in self.inner_wires() ] @@ -5711,9 +5710,8 @@ class Solid(Shape, Mixin3D): # make an auxiliary spine pitch = 360.0 / angle * normal.length - radius = 1 aux_spine_w = Wire.make_helix( - pitch, normal.length, radius, center=center, normal=normal + pitch, normal.length, 1, center=center, normal=normal ).wrapped # extrude the outer wire @@ -5826,8 +5824,6 @@ class Solid(Shape, Mixin3D): Returns: Solid: the swept cross section """ - path_as_wire = path.to_wire() - if isinstance(section, Face): outer_wire = section.outer_wire() inner_wires = section.inner_wires() @@ -5837,9 +5833,8 @@ class Solid(Shape, Mixin3D): shapes = [] for wire in [outer_wire] + inner_wires: - builder = BRepOffsetAPI_MakePipeShell(path_as_wire.wrapped) + builder = BRepOffsetAPI_MakePipeShell(path.to_wire().wrapped) - translate = False rotate = False # handle sweep mode @@ -5850,7 +5845,7 @@ class Solid(Shape, Mixin3D): builder.SetTransitionMode(Solid._transModeDict[transition]) - builder.Add(wire.wrapped, translate, rotate) + builder.Add(wire.wrapped, False, rotate) builder.Build() if make_solid: @@ -6284,9 +6279,8 @@ class Wire(Shape, Mixin1D): geom_line = Geom2d_Line(gp_Pnt2d(0.0, 0.0), gp_Dir2d(2 * pi, pitch)) # 3. put it together into a wire - n_turns = height / pitch u_start = geom_line.Value(0.0) - u_stop = geom_line.Value(n_turns * sqrt((2 * pi) ** 2 + pitch**2)) + u_stop = geom_line.Value((height / pitch) * sqrt((2 * pi) ** 2 + pitch**2)) geom_seg = GCE2d_MakeSegment(u_start, u_stop).Value() topo_edge = BRepBuilderAPI_MakeEdge(geom_seg, geom_surf).Edge()