def load_surfaces(self):
     try:
         surface_list = read_lifting_surface_objects()
         if len(surface_list) == 0:
             self.new_surfaces()
         else:
             for l in surface_list:
                 design_type_, surface_type_ = get_surface_object_data(l)
                 if design_type_ == unconventional_design:
                     self.surfaca_tab_ = lifting_surface_pane(
                         l, surface_type_, design_type_)
                     self.surfaces.append(self.surfaca_tab_)
                     self.inputArea.addTab(self.surfaca_tab_, l)
                     self.indexes.append(l)
                 elif design_type_ == conventional_design:
                     if surface_type_ == fin:
                         self.surfaca_tab_ = v_stab_tab(
                             l, surface_type_, design_type_)
                         self.surfaces.append(self.surfaca_tab_)
                         self.inputArea.addTab(self.surfaca_tab_, l)
                         self.indexes.append(l)
                     elif surface_type_ == tailplane:
                         self.surfaca_tab_ = h_stab_tab(
                             l, surface_type_, design_type_)
                         self.surfaces.append(self.surfaca_tab_)
                         self.inputArea.addTab(self.surfaca_tab_, l)
                         self.indexes.append(l)
                     else:
                         self.surfaca_tab_ = wing_tab(
                             l, surface_type_, design_type_)
                         self.surfaces.append(self.surfaca_tab_)
                         self.inputArea.addTab(self.surfaca_tab_, l)
                         self.indexes.append(l)
     except:
         self.new_surfaces()
def update_surface_lower_3d(config=None):
    surface_list = read_lifting_surface_objects()
    lofts = {}
    for l in surface_list:
        design_type_, surface_type_ = get_surface_object_data(l)
        lofts.update({
            l:
            generate_wing_lower_3D(config, l, surface_type_, design_type_)
        })
    return lofts
def get_surface_for_vlm():
    from aerosandbox_legacy_v0 import WingXSec, Wing, Airfoil
    from Utils.data_objects.lifting_surface_placeholder import wing
    wings = []
    surface_list = read_lifting_surface_objects()
    for l in surface_list:
        design_type_, surface_type_ = get_surface_object_data(l)
        if design_type_ == unconventional_design:
            from aerosandbox_legacy_v0 import Wing
            x, y, z, chords, twist_, profile_, root_location_x, root_location_y, root_location_z, xz_mirror_ = get_parameters_for_unconventional(
                l)
            xsecs = []
            for x_, y_, z_, chord_, t in zip(x, y, z, chords, twist_):
                xsecs.append(
                    WingXSec(  # Root
                        xyz_le=[x_, y_, z_],
                        chord=chord_,
                        twist=t,
                        airfoil=Airfoil(name=profile_)))
            wings.append(
                Wing(
                    name=l,
                    xyz_le=[root_location_x, root_location_y, root_location_z],
                    # Coordinates of the wing's leading edge
                    symmetric=xz_mirror_,
                    xsecs=xsecs))
        elif design_type_ == conventional_design:
            x, y, z, chords, twist, profile_, root_location_x, root_location_y, root_location_z = get_parameters_for_conventional(
                l, surface_type_)
            xsecs = []
            for x_, y_, z_, chord_ in zip(x, y, z, chords):
                if surface_type_ == wing or surface_type_ == tailplane:
                    xsecs.append(
                        WingXSec(  # Root
                            xyz_le=[x_, y_, z_],
                            chord=chord_,
                            twist=twist,
                            airfoil=Airfoil(name=profile_)))
                elif surface_type_ == fin:
                    print(fin)
                    xsecs.append(
                        WingXSec(  # Root
                            xyz_le=[x_, z_, y_],
                            chord=chord_,
                            twist=twist,
                            airfoil=Airfoil(name=profile_)))

            wings.append(
                Wing(
                    name=l,
                    xyz_le=[root_location_x, root_location_y, root_location_z],
                    symmetric=True if surface_type_ == wing
                    or surface_type_ == tailplane else False,
                    xsecs=xsecs))
    return wings
def build_datcom_input():

    surface_list = read_lifting_surface_objects()
    ls_statements = []
    boom_statements = []
    synths={}
    for l in surface_list:
        design_type_, surface_type_ = get_surface_object_data(l)
        span_, tip_chord, root_chord, dihedral_, sweep_ = 0, 0, 0, 0, 0
        profile_="0012"
        if design_type_ == unconventional_design:
            span_, tip_chord, root_chord, dihedral_, sweep_,profile_ = get_parameters_from_sections_lifting_surface(l)
        elif design_type_ == conventional_design:
            print(l)
            span_, tip_chord, root_chord, dihedral_, sweep_,profile_ = get_parameters_from_conventional_wing(l)
        print(profile_.split("naca"))
        if surface_type_ == wing:
            synths.update({"wing": span_ / 2})
            ls_statements.append(set_planform_parameters(
                type_1="W,G", tip_chord=tip_chord,
                root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_,
                dihedral_=1.2,
                profile=profile_.split("naca")[1]
            ))
        elif surface_type_ == fin:
            synths.update({"vtp":span_ / 2})
            ls_statements.append(set_planform_parameters(
                type_1="V,T", tip_chord=tip_chord,
                root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_,
                dihedral_=1.3,
                profile=profile_.split("naca")[1]
            ))
        else:
            synths.update({"vtp": span_ / 2})
            ls_statements.append(set_planform_parameters(
                type_1="H,T", tip_chord=tip_chord,
                root_chord=root_chord, semi_span=(span_ / 2), sweep_angle=sweep_,
                dihedral_=1.3,
                profile=profile_.split("naca")[1]
            ))

    try:
        boom_list = read_boom_objects()
        for l in boom_list:
            design_type_, surface_type_ = get_boom_object_data(l)
            if design_type_ == unconventional_design:
                pass
            elif design_type_ == conventional_design:
                radii, x, z = get_parameters_from_conventional_boom(l)
                boom_statements.append(set_body_parameters_radius(section_positions=x, radius_of_sections=radii,
                                                                  iter_=(boom_list.index(l) + 1)))
    except:
        pass

    mesh = get_center_of_mass()
    try:
        value=synths["vtp"]
    except:
        synths.update({"vtp":0})
    try:
        value=synths["htp"]
    except:
        synths.update({"htp":0})

    input_ = "".join([set_flight_conditions(mach_numbers=get_mach_number(), angle_of_attack=get_aoa_range(), altitude=get_altitude()),
                      set_synths_parameters(center_of_gravity_x=round(mesh["x"],2),center_of_gravity_z=round(mesh["z"],2),
                                            vtp_tip_position_x=round(synths.get("vtp"),2),
                                            htp_tip_position_x=round(synths.get("htp"),2)),

                      "".join(ls_statements),
                      "".join(boom_statements),
                      create_footer()])
    database.write_datcom_input(input=input_)
def update_surface_3D(workflow=None):
    surface_list = read_lifting_surface_objects()
    for l in surface_list:
        design_type_, surface_type_ = get_surface_object_data(l)
        generate_wing_3D(workflow, l, surface_type_, design_type_)