def makeWedge(cls, xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max, pnt=None, dir=None):
     """
     Make a wedge located in pnt
     By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
     """
     return Shape.cast(
         FreeCADPart.makeWedge(xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max, pnt, dir))
Example #2
0
 def makeWedge(cls, xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max, pnt=None, dir=None):
     """
     Make a wedge located in pnt
     By default pnt=Vector(0,0,0) and dir=Vector(0,0,1)
     """
     return Shape.cast(
         FreeCADPart.makeWedge(xmin, ymin, zmin, z2min, x2min, xmax, ymax, zmax, z2max, x2max, pnt, dir))
Example #3
0
def prism3(length, offset, width, height):
    b = Part.makeWedge(-length * 0.5, -height * 0.5, -width * 0.5,
                       -width * 0.5, -(length * 0.5 - offset), length * 0.5,
                       height * 0.5, width * 0.5, width * 0.5,
                       -(length * 0.5 - offset))
    return (center_object(b))
Example #4
0
    def get_default_shape(self, obj):
        """
        The wall default base shape is defined as 2 Part Wedge solids, fused together;
        splays are controlled by obj.FirstCoreOuterAngle, obj.LastCoreOuterAngle
                                 obj.FirstCoreInnerAngle, obj.LastCoreInnerAngle

        TODO: Adding support for default multi-layer walls.

                 <--> first_splay                <--> last_splay
                 ---------------------------------  outer surface
                  \         Part Wedge 1          \ 
                   \           core axis           \ 
        first_point o-------------------------------o  last_point
                     \                               \ 
                      \       Part Wedge 2            \ 
                       ---------------------------------  inner surface
                    <--> first_splay                <--> last_splay
        """
        import Part

        if not hasattr(obj,"AxisFirstPointX") or not hasattr(obj,"AxisLastPointX") \
            or not hasattr(obj,"Width") or not hasattr(obj,"Height"):
            return

        length = obj.Length

        if obj.AxisFirstPointX == obj.AxisLastPointX or length < Draft.tolerance():
            return

        if hasattr(obj, "Material") and obj.Material and utils.get_type(obj.Material) == 'MultiMaterial':
            # if MultiMaterial assigned, ignore Width property.
            thickness = App.Units.Quantity(str(sum(obj.Material.Thicknesses))+"mm") # TODO: Multimaterial should have a readonly Thickness Property
            # self.onChanged(obj, "Material") # to update the Width property
        else:
            thickness = obj.Width

        # swap first point and last point to have them in the right order
        # TODO: Swap the points phisically and change end constraints!
        if obj.AxisFirstPointX < obj.AxisLastPointX:
            first_point = obj.AxisFirstPointX
        elif obj.AxisFirstPointX > obj.AxisLastPointX:
            first_point = obj.AxisLastPointX
        
        first_splay = thickness/2 * math.tan(math.pi/2-math.radians(obj.FirstCoreInnerAngle))
        last_splay = thickness/2 * math.tan(math.pi/2-math.radians(obj.LastCoreInnerAngle))
        
        Xmin = -obj.FirstCoreOffset
        Ymin = 0
        Zmin = 0
        Z2min = 0
        X2min = first_splay - obj.FirstCoreOffset
        Xmax = length + obj.LastCoreOffset
        Ymax = thickness/2
        Zmax = obj.Height
        Z2max = obj.Height
        X2max = length - last_splay + obj.LastCoreOffset

        # checking conditions that will break Part.makeWedge()
        if first_splay >= length:
            print("Wall is too short compared to the first splay: removing angles of outer core layer\n")
            X2min = 0
        if last_splay >= length:
            print("Wall is too short compared to the last splay: removing angles of outer core layer\n")
            X2max = length
        if ( first_splay + last_splay ) >= length:
            print("Wall is too short compared to the splays: removing angles of inner core layer\n")
            X2min = 0
            X2max = length

        inner_half = Part.makeWedge( Xmin, Ymin, Zmin, Z2min, X2min,
                                        Xmax, Ymax, Zmax, Z2max, X2max)#, obj.AxisFirstPointX, obj.AxisLastPointX )
        inner_half.Placement.Base.x = first_point

        first_splay = thickness/2 * math.tan(math.pi/2-math.radians(obj.FirstCoreOuterAngle))
        last_splay = thickness/2 * math.tan(math.pi/2-math.radians(obj.LastCoreOuterAngle))          
        
        Xmin = first_splay - obj.FirstCoreOffset
        Ymin = 0
        Zmin = 0
        Z2min = 0
        X2min = -obj.FirstCoreOffset
        Xmax = length - last_splay + obj.LastCoreOffset
        Ymax = thickness/2
        Zmax = obj.Height
        Z2max = obj.Height
        X2max = length + obj.LastCoreOffset

        # checking conditions that will break Part.makeWedge()
        if first_splay >= length:
            print("Wall is too short compared to the first splay: removing angles of outer core layer\n")
            Xmin = 0
        if last_splay >= length:
            print("Wall is too short compared to the last splay: removing angles of outer core layer\n")
            Xmax = length
        if ( first_splay + last_splay ) >= length:
            print("Wall is too short compared to the splays: removing angles of outer core layer\n")
            Xmin = 0
            Xmax = length

        outer_half = Part.makeWedge( Xmin, Ymin, Zmin, Z2min, X2min,
                                        Xmax, Ymax, Zmax, Z2max, X2max)#, obj.Start, obj.End)
                
        outer_half.Placement.Base = App.Vector(first_point, - thickness/2)
        
        mono_layer = inner_half.fuse(outer_half)

        mono_layer = mono_layer.removeSplitter()
        
        # split according to material layers

        if hasattr(obj, "Material") and obj.Material and utils.get_type(obj.Material) == 'MultiMaterial':
            pass
        else:
            return mono_layer

        layer_thicknesses = obj.Material.Thicknesses

        slicing_plane = Part.makePlane(500000.0, 500000.0, App.Vector(-250000.0, -250000.0, 0.0))
        slicing_plane.rotate(App.Vector(0 ,0 , 0), App.Vector(1, 0, 0), 90.0)

        slicing_planes = []
        offset = 0.0
        for lt in layer_thicknesses[:-1]:
            offset += lt
            plane = slicing_plane.copy()
            plane.translate(App.Vector(0, offset-thickness.Value/2, 0))
            slicing_planes.append(plane)

        compound = mono_layer.generalFuse(slicing_planes)[0] # generalFuse output also a list of list of shape (map)

        for shape in compound.SubShapes:
            if shape.ShapeType == "Compound":
                return shape
Example #5
0
    def get_default_shape(self, obj):
        """
        The wall default base shape is defined as 2 Part Wedge solids, fused together;
        splays are controlled by obj.FirstCoreOuterAngle, obj.LastCoreOuterAngle
                                 obj.FirstCoreInnerAngle, obj.LastCoreInnerAngle

        TODO: Adding support for default multi-layer walls.

                 <--> first_splay                <--> last_splay
                 ---------------------------------  outer surface
                  \         Part Wedge 1          \ 
                   \           core axis           \ 
        first_point o-------------------------------o  last_point
                     \                               \ 
                      \       Part Wedge 2            \ 
                       ---------------------------------  inner surface
                    <--> first_splay                <--> last_splay
        """
        import Part

        if not hasattr(obj,"AxisFirstPointX") or not hasattr(obj,"AxisLastPointX") \
            or not hasattr(obj,"Width") or not hasattr(obj,"Height"):
            return

        length = obj.Length

        if obj.AxisFirstPointX == obj.AxisLastPointX or length < Draft.tolerance(
        ):
            return

        # swap first point and last point to have them in the right order
        # TODO: Swap the points phisically and change end constraints!
        if obj.AxisFirstPointX < obj.AxisLastPointX:
            first_point = obj.AxisFirstPointX
        elif obj.AxisFirstPointX > obj.AxisLastPointX:
            first_point = obj.AxisLastPointX

        first_splay = obj.Width / 2 * math.tan(
            math.pi / 2 - math.radians(obj.FirstCoreInnerAngle))
        last_splay = obj.Width / 2 * math.tan(
            math.pi / 2 - math.radians(obj.LastCoreInnerAngle))

        Xmin = -obj.FirstCoreOffset
        Ymin = 0
        Zmin = 0
        Z2min = 0
        X2min = first_splay - obj.FirstCoreOffset
        Xmax = length + obj.LastCoreOffset
        Ymax = obj.Width / 2
        Zmax = obj.Height
        Z2max = obj.Height
        X2max = length - last_splay + obj.LastCoreOffset

        # checking conditions that will break Part.makeWedge()
        if first_splay >= length:
            print(
                "Wall is too short compared to the first splay: removing angles of outer core layer\n"
            )
            X2min = 0
        if last_splay >= length:
            print(
                "Wall is too short compared to the last splay: removing angles of outer core layer\n"
            )
            X2max = length
        if (first_splay + last_splay) >= length:
            print(
                "Wall is too short compared to the splays: removing angles of inner core layer\n"
            )
            X2min = 0
            X2max = length

        inner_core = Part.makeWedge(
            Xmin, Ymin, Zmin, Z2min, X2min, Xmax, Ymax, Zmax, Z2max,
            X2max)  #, obj.AxisFirstPointX, obj.AxisLastPointX )
        inner_core.Placement.Base.x = first_point

        first_splay = obj.Width / 2 * math.tan(
            math.pi / 2 - math.radians(obj.FirstCoreOuterAngle))
        last_splay = obj.Width / 2 * math.tan(
            math.pi / 2 - math.radians(obj.LastCoreOuterAngle))

        Xmin = first_splay - obj.FirstCoreOffset
        Ymin = 0
        Zmin = 0
        Z2min = 0
        X2min = -obj.FirstCoreOffset
        Xmax = length - last_splay + obj.LastCoreOffset
        Ymax = obj.Width / 2
        Zmax = obj.Height
        Z2max = obj.Height
        X2max = length + obj.LastCoreOffset

        # checking conditions that will break Part.makeWedge()
        if first_splay >= length:
            print(
                "Wall is too short compared to the first splay: removing angles of outer core layer\n"
            )
            Xmin = 0
        if last_splay >= length:
            print(
                "Wall is too short compared to the last splay: removing angles of outer core layer\n"
            )
            Xmax = length
        if (first_splay + last_splay) >= length:
            print(
                "Wall is too short compared to the splays: removing angles of outer core layer\n"
            )
            Xmin = 0
            Xmax = length

        outer_core = Part.makeWedge(Xmin, Ymin, Zmin, Z2min, X2min, Xmax, Ymax,
                                    Zmax, Z2max, X2max)  #, obj.Start, obj.End)

        outer_core.Placement.Base = App.Vector(first_point, -obj.Width / 2)

        core_layer = inner_core.fuse(outer_core)

        # TODO: Add support for multiple wall layers.
        #       I was thinking to just 3 layers in the representation, cause it's usually enough

        return core_layer