예제 #1
0
파일: beam.py 프로젝트: flysafely/planbar
    def shape_keyslot(self,
                      length,
                      width,
                      height,
                      edge,
                      mirror=False,
                      rX=0,
                      rY=0,
                      rZ=0,
                      sX=0,
                      sY=0,
                      sZ=0):
        #bevel_edge = math.sqrt(self.KeyslotEdge^2 + self.KeyslotThick^2) #斜边

        if mirror:
            base_pol1 = AllplanGeo.Polygon3D()
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + edge,
                                            rZ + sZ + edge)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + width - edge,
                                            rZ + sZ + edge)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + width - edge,
                                            rZ + sZ + height - edge)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + edge,
                                            rZ + sZ + height - edge)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + edge,
                                            rZ + sZ + edge)

            base_pol2 = AllplanGeo.Polygon3D()
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY, rZ + sZ)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY + width,
                                            rZ + sZ)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY + width,
                                            rZ + sZ + height)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY,
                                            rZ + sZ + height)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY, rZ + sZ)

        else:
            base_pol1 = AllplanGeo.Polygon3D()
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY, rZ + sZ)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + width, rZ + sZ)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY + width,
                                            rZ + sZ + height)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY, rZ + sZ + height)
            base_pol1 += AllplanGeo.Point3D(rX + sX, rY + sY, rZ + sZ)

            #----------------------------------

            base_pol2 = AllplanGeo.Polygon3D()
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY + edge,
                                            rZ + sZ + edge)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length,
                                            rY + sY + width - edge,
                                            rZ + sZ + edge)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length,
                                            rY + sY + width - edge,
                                            rZ + sZ + height - edge)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY + edge,
                                            rZ + sZ + height - edge)
            base_pol2 += AllplanGeo.Point3D(rX + sX + length, rY + sY + edge,
                                            rZ + sZ + edge)

        if not GeometryValidate.is_valid(base_pol1):
            return
        if not GeometryValidate.is_valid(base_pol2):
            return

        err, shape = AllplanGeo.CreatePolyhedron(base_pol1, base_pol2)
        err, shape = AllplanGeo.CreateBRep3D(shape)
        return shape
예제 #2
0
    def add_joins_right(self, build_ele, com_prop_stroke, type=1):
        wall_length = build_ele.Length1_1.value
        wall_width = build_ele.Width1_1.value
        wall_thickness = build_ele.Thickness1_1.value

        j_a = build_ele.type2_a.value
        j_c = build_ele.type2_c.value
        j_d = build_ele.type2_d.value

        join2_point = AllplanGeo.Polygon2D()

        path2 = AllplanGeo.Polyline3D()

        ref_pnt = AllplanGeo.Point2D(0, 0)

        if (type == 1):
            j_b = wall_thickness / 2

            join2_point += AllplanGeo.Point2D(0, -j_a / 2)
            join2_point += AllplanGeo.Point2D(-j_c, -j_d / 2)
            join2_point += AllplanGeo.Point2D(-j_c, j_d / 2)
            join2_point += AllplanGeo.Point2D(0, j_a / 2)
            join2_point += AllplanGeo.Point2D(0, -j_a / 2)

            if not GeometryValidate.is_valid(join2_point):
                return

            path2 += AllplanGeo.Point3D(wall_length, j_b, 0)
            path2 += AllplanGeo.Point3D(wall_length, j_b, wall_width)

        if (type == 2):
            j_b = build_ele.type2_b.value
            join2_point += AllplanGeo.Point2D(-j_a / 2, 0)
            join2_point += AllplanGeo.Point2D(-j_d / 2, j_c)
            join2_point += AllplanGeo.Point2D(j_d / 2, j_c)
            join2_point += AllplanGeo.Point2D(j_a / 2, 0)
            join2_point += AllplanGeo.Point2D(-j_a / 2, 0)

            if not GeometryValidate.is_valid(join2_point):
                return

            path2 += AllplanGeo.Point3D(wall_length - j_b, 0, 0)
            path2 += AllplanGeo.Point3D(wall_length - j_b, 0, wall_width)

            handle_b2 = HandleProperties(
                "Moveb2", AllplanGeo.Point3D(wall_length - j_b, 0, 0),
                AllplanGeo.Point3D(wall_length, 0,
                                   0), [("type2_b", HandleDirection.x_dir)],
                HandleDirection.x_dir, True)
            self.handle_list.append(handle_b2)

        if (type == 3):

            join2_point += AllplanGeo.Point2D(0, 0)
            join2_point += AllplanGeo.Point2D(-j_c, 0)
            join2_point += AllplanGeo.Point2D(-j_c, j_d)
            join2_point += AllplanGeo.Point2D(0, j_a)
            join2_point += AllplanGeo.Point2D(0, 0)

            if not GeometryValidate.is_valid(join2_point):
                return

            path2 += AllplanGeo.Point3D(wall_length, 0, 0)
            path2 += AllplanGeo.Point3D(wall_length, 0, wall_width)

        err, join2 = AllplanGeo.CreatePolyhedron(join2_point, ref_pnt, path2)
        if not GeometryValidate.polyhedron(err):
            return

        self.model_ele_list.append(
            AllplanBasisElements.ModelElement3D(com_prop_stroke, join2))
        return join2
예제 #3
0
파일: beam.py 프로젝트: flysafely/planbar
    def create_geometry(self):
        '''
        Create the element geometries
        构建元素几何图形函数
        return 图形list
        '''

        #point
        rectangle = self.shape_cuboid(self.Length, self.Width, self.Height)

        cutter = self.shape_cuboid(self.CutLength,
                                   self.Width,
                                   self.Height,
                                   sX=self.CutPosition)

        slot_head = self.shape_cuboid(self.SlotLength,
                                      self.Width - 2 * self.SlotSide,
                                      self.Height - self.SlotBottom,
                                      sY=self.SlotSide,
                                      sZ=self.SlotBottom)

        slot_tail = self.shape_cuboid(self.SlotLength,
                                      self.Width - 2 * self.SlotSide,
                                      self.Height - self.SlotBottom,
                                      sX=self.Length - self.SlotLength,
                                      sY=self.SlotSide,
                                      sZ=self.SlotBottom)

        key_slot_1 = self.shape_keyslot(self.KeyslotThick,
                                        self.Width - 2 * self.KeyslotSide,
                                        self.KeyslotHeight, self.KeyslotEdge,
                                        False, self.SlotLength,
                                        self.KeyslotSide, self.KeyslotBottom)

        key_slot_2 = self.shape_keyslot(self.KeyslotThick,
                                        self.Width - 2 * self.KeyslotSide,
                                        self.KeyslotHeight, self.KeyslotEdge,
                                        True,
                                        self.CutPosition - self.KeyslotThick,
                                        self.KeyslotSide, self.KeyslotBottom)

        key_slot_3 = self.shape_keyslot(self.KeyslotThick,
                                        self.Width - 2 * self.KeyslotSide,
                                        self.KeyslotHeight, self.KeyslotEdge,
                                        False,
                                        self.CutPosition + self.CutLength,
                                        self.KeyslotSide, self.KeyslotBottom)

        key_slot_4 = self.shape_keyslot(
            self.KeyslotThick, self.Width - 2 * self.KeyslotSide,
            self.KeyslotHeight, self.KeyslotEdge, True,
            self.Length - self.SlotLength - self.KeyslotThick,
            self.KeyslotSide, self.KeyslotBottom)

        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, cutter)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, slot_head)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, slot_tail)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, key_slot_1)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, key_slot_2)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, key_slot_3)
        err, rectangle = AllplanGeo.MakeSubtraction(rectangle, key_slot_4)

        approximation = AllplanGeo.ApproximationSettings(
            AllplanGeo.eApproximationSettingsType.ASET_BREP_TESSELATION, 1)
        err, rectangle = AllplanGeo.CreatePolyhedron(rectangle, approximation)

        return [
            AllplanBasisElements.ModelElement3D(self.com_prop, self.texturedef,
                                                rectangle)
        ]
예제 #4
0
    def add_joins_left(self, build_ele, com_prop_stroke, type=1):
        wall_length = build_ele.Length1_1.value
        wall_width = build_ele.Width1_1.value
        wall_thickness = build_ele.Thickness1_1.value

        j_a = build_ele.type1_a.value
        j_c = build_ele.type1_c.value
        j_d = build_ele.type1_d.value

        join1_point = AllplanGeo.Polygon2D()

        path1 = AllplanGeo.Polyline3D()

        ref_pnt = AllplanGeo.Point2D(0, 0)

        if (type == 1):
            j_b = wall_thickness / 2

            join1_point += AllplanGeo.Point2D(0, -j_a / 2)
            join1_point += AllplanGeo.Point2D(j_c, -j_d / 2)
            join1_point += AllplanGeo.Point2D(j_c, j_d / 2)
            join1_point += AllplanGeo.Point2D(0, j_a / 2)
            join1_point += AllplanGeo.Point2D(0, -j_a / 2)

            if not GeometryValidate.is_valid(join1_point):
                return

            path1 += AllplanGeo.Point3D(0, j_b, 0)
            path1 += AllplanGeo.Point3D(0, j_b, wall_width)

        if (type == 2):
            j_b = build_ele.type1_b.value
            join1_point += AllplanGeo.Point2D(-j_a / 2, 0)
            join1_point += AllplanGeo.Point2D(-j_d / 2, j_c)
            join1_point += AllplanGeo.Point2D(j_d / 2, j_c)
            join1_point += AllplanGeo.Point2D(j_a / 2, 0)
            join1_point += AllplanGeo.Point2D(-j_a / 2, 0)

            if not GeometryValidate.is_valid(join1_point):
                return

            path1 += AllplanGeo.Point3D(j_b, 0, 0)
            path1 += AllplanGeo.Point3D(j_b, 0, wall_width)

            handle_b1 = HandleProperties("Moveb1",
                                         AllplanGeo.Point3D(j_b, 0, 0),
                                         AllplanGeo.Point3D(0, 0, 0),
                                         [("type1_b", HandleDirection.x_dir)],
                                         HandleDirection.x_dir, False)
            self.handle_list.append(handle_b1)

        if (type == 3):

            join1_point += AllplanGeo.Point2D(0, 0)
            join1_point += AllplanGeo.Point2D(j_c, 0)
            join1_point += AllplanGeo.Point2D(j_c, j_d)
            join1_point += AllplanGeo.Point2D(0, j_a)
            join1_point += AllplanGeo.Point2D(0, 0)

            if not GeometryValidate.is_valid(join1_point):
                return

            path1 += AllplanGeo.Point3D(0, 0, 0)
            path1 += AllplanGeo.Point3D(0, 0, wall_width)

        err, join1 = AllplanGeo.CreatePolyhedron(join1_point, ref_pnt, path1)
        if not GeometryValidate.polyhedron(err):
            #NemAll_Python_Utility.ShowMessageBox("error",1)
            return

        #NemAll_Python_Utility.ShowMessageBox("pass2",1)
        self.model_ele_list.append(
            AllplanBasisElements.ModelElement3D(com_prop_stroke, join1))
        return join1