@@ -3745,10 +3745,12 @@ def _sweep(
3745
3745
3746
3746
def interpPlate (
3747
3747
self : T ,
3748
- surf_edges : Union [Sequence [VectorLike ], Sequence [Edge ]],
3748
+ surf_edges : Union [
3749
+ Sequence [VectorLike ], Sequence [Union [Edge , Wire ]], "Workplane"
3750
+ ],
3749
3751
surf_pts : Sequence [VectorLike ] = [],
3750
3752
thickness : float = 0 ,
3751
- combine : bool = False ,
3753
+ combine : CombineMode = False ,
3752
3754
clean : bool = True ,
3753
3755
degree : int = 3 ,
3754
3756
nbPtsOnCur : int = 15 ,
@@ -3797,42 +3799,47 @@ def interpPlate(
3797
3799
:type MaxSegments: Integer >= 2 (?)
3798
3800
"""
3799
3801
3800
- # If thickness is 0, only a 2D surface will be returned.
3801
- if thickness == 0 :
3802
- combine = False
3802
+ # convert points to edges if needed
3803
+ edges : List [Union [Edge , Wire ]] = []
3804
+ points = []
3805
+
3806
+ if isinstance (surf_edges , Workplane ):
3807
+ edges .extend (cast (Edge , el ) for el in surf_edges .edges ().objects )
3808
+ else :
3809
+ for el in surf_edges :
3810
+ if isinstance (el , (Edge , Wire )):
3811
+ edges .append (el )
3812
+ else :
3813
+ points .append (el )
3803
3814
3804
3815
# Creates interpolated plate
3805
- p = Solid . interpPlate (
3806
- surf_edges ,
3816
+ f : Face = Face . makeNSidedSurface (
3817
+ edges if not points else [ Wire . makePolygon ( points ). close ()] ,
3807
3818
surf_pts ,
3808
- thickness ,
3809
- degree ,
3810
- nbPtsOnCur ,
3811
- nbIter ,
3812
- anisotropy ,
3813
- tol2d ,
3814
- tol3d ,
3815
- tolAng ,
3816
- tolCurv ,
3817
- maxDeg ,
3818
- maxSegments ,
3819
+ degree = degree ,
3820
+ nbPtsOnCur = nbPtsOnCur ,
3821
+ nbIter = nbIter ,
3822
+ anisotropy = anisotropy ,
3823
+ tol2d = tol2d ,
3824
+ tol3d = tol3d ,
3825
+ tolAng = tolAng ,
3826
+ tolCurv = tolCurv ,
3827
+ maxDeg = maxDeg ,
3828
+ maxSegments = maxSegments ,
3819
3829
)
3820
3830
3821
- plates = self .eachpoint (lambda loc : p .moved (loc ), True )
3831
+ # thicken if needed
3832
+ s = f .thicken (thickness ) if thickness > 0 else f
3822
3833
3823
- # if combination is not desired, just return the created boxes
3824
- if not combine :
3825
- return plates
3826
- else :
3827
- return self .union (plates , clean = clean )
3834
+ return self .eachpoint (lambda loc : s .moved (loc ), True , combine )
3828
3835
3829
3836
def box (
3830
3837
self : T ,
3831
3838
length : float ,
3832
3839
width : float ,
3833
3840
height : float ,
3834
3841
centered : Union [bool , Tuple [bool , bool , bool ]] = True ,
3835
- combine : bool = True ,
3842
+ combine : CombineMode = True ,
3836
3843
clean : bool = True ,
3837
3844
) -> T :
3838
3845
"""
@@ -3894,14 +3901,7 @@ def box(
3894
3901
3895
3902
box = Solid .makeBox (length , width , height , offset )
3896
3903
3897
- boxes = self .eachpoint (lambda loc : box .moved (loc ), True )
3898
-
3899
- # if combination is not desired, just return the created boxes
3900
- if not combine :
3901
- return boxes
3902
- else :
3903
- # combine everything
3904
- return self .union (boxes , clean = clean )
3904
+ return self .eachpoint (lambda loc : box .moved (loc ), True , combine )
3905
3905
3906
3906
def sphere (
3907
3907
self : T ,
@@ -3911,7 +3911,7 @@ def sphere(
3911
3911
angle2 : float = 90 ,
3912
3912
angle3 : float = 360 ,
3913
3913
centered : Union [bool , Tuple [bool , bool , bool ]] = True ,
3914
- combine : bool = True ,
3914
+ combine : CombineMode = True ,
3915
3915
clean : bool = True ,
3916
3916
) -> T :
3917
3917
"""
@@ -3965,13 +3965,7 @@ def sphere(
3965
3965
s = Solid .makeSphere (radius , offset , direct , angle1 , angle2 , angle3 )
3966
3966
3967
3967
# We want a sphere for each point on the workplane
3968
- spheres = self .eachpoint (lambda loc : s .moved (loc ), True )
3969
-
3970
- # If we don't need to combine everything, just return the created spheres
3971
- if not combine :
3972
- return spheres
3973
- else :
3974
- return self .union (spheres , clean = clean )
3968
+ return self .eachpoint (lambda loc : s .moved (loc ), True , combine )
3975
3969
3976
3970
def cylinder (
3977
3971
self : T ,
@@ -3980,7 +3974,7 @@ def cylinder(
3980
3974
direct : Vector = Vector (0 , 0 , 1 ),
3981
3975
angle : float = 360 ,
3982
3976
centered : Union [bool , Tuple [bool , bool , bool ]] = True ,
3983
- combine : bool = True ,
3977
+ combine : CombineMode = True ,
3984
3978
clean : bool = True ,
3985
3979
) -> T :
3986
3980
"""
@@ -4028,13 +4022,7 @@ def cylinder(
4028
4022
s = Solid .makeCylinder (radius , height , offset , direct , angle )
4029
4023
4030
4024
# We want a cylinder for each point on the workplane
4031
- cylinders = self .eachpoint (lambda loc : s .moved (loc ), True )
4032
-
4033
- # If we don't need to combine everything, just return the created cylinders
4034
- if not combine :
4035
- return cylinders
4036
- else :
4037
- return self .union (cylinders , clean = clean )
4025
+ return self .eachpoint (lambda loc : s .moved (loc ), True , combine )
4038
4026
4039
4027
def wedge (
4040
4028
self : T ,
@@ -4048,7 +4036,7 @@ def wedge(
4048
4036
pnt : VectorLike = Vector (0 , 0 , 0 ),
4049
4037
dir : VectorLike = Vector (0 , 0 , 1 ),
4050
4038
centered : Union [bool , Tuple [bool , bool , bool ]] = True ,
4051
- combine : bool = True ,
4039
+ combine : CombineMode = True ,
4052
4040
clean : bool = True ,
4053
4041
) -> T :
4054
4042
"""
@@ -4104,13 +4092,7 @@ def wedge(
4104
4092
w = Solid .makeWedge (dx , dy , dz , xmin , zmin , xmax , zmax , offset , dir )
4105
4093
4106
4094
# We want a wedge for each point on the workplane
4107
- wedges = self .eachpoint (lambda loc : w .moved (loc ), True )
4108
-
4109
- # If we don't need to combine everything, just return the created wedges
4110
- if not combine :
4111
- return wedges
4112
- else :
4113
- return self .union (wedges , clean = clean )
4095
+ return self .eachpoint (lambda loc : w .moved (loc ), True , combine )
4114
4096
4115
4097
def clean (self : T ) -> T :
4116
4098
"""
0 commit comments