Exemplo n.º 1
0
 def write_card_16(self, is_double=False):
     """
         Writes a GRID card in 16-field format
         """
     xyz = self.xyz
     cp = set_string16_blank_if_default(self.Cp(), 0)
     cd = set_string16_blank_if_default(self.Cd(), 0)
     seid = set_string16_blank_if_default(self.SEid(), 0)
     if is_double:
         msg = ('%-8s%16i%16s%16s%16s\n'
                '%-8s%16s%16s%16s%16s\n' % (
                    'GRID*', self.nid,
                    cp,
                    print_scientific_double(xyz[0]),
                    print_scientific_double(xyz[1]),
                    '*',
                    print_scientific_double(xyz[2]),
                    cd, self.ps, seid))
     else:
         msg = ('%-8s%16i%16s%16s%16s\n'
                '%-8s%16s%16s%16s%16s\n' % (
                    'GRID*', self.nid,
                    cp,
                    print_float_16(xyz[0]),
                    print_float_16(xyz[1]),
                    '*',
                    print_float_16(xyz[2]),
                    cd, self.ps, seid))
     return self.comment + msg.rstrip() + '\n'
Exemplo n.º 2
0
    def write_card_16(self, is_double=False):
        """
        Writes a GRID card in 16-field format
        """
        xyz = self.xyz
        cp = set_string16_blank_if_default(self.Cp(), 0)
        cd = set_string16_blank_if_default(self.Cd(), 0)
        seid = set_string16_blank_if_default(self.SEid(), 0)

        if is_double:
            if [cd, self.ps, self.seid] == [0, '', 0]:
                msg = ('GRID*   %16i%16s%16s%16s\n'
                       '*       %16s\n' %
                       (self.nid, cp, print_scientific_double(
                           xyz[0]), print_scientific_double(
                               xyz[1]), print_scientific_double(xyz[2])))
            else:
                msg = ('GRID*   %16i%16s%16s%16s\n'
                       '*       %16s%16s%16s%16s\n' %
                       (self.nid, cp, print_scientific_double(
                           xyz[0]), print_scientific_double(xyz[1]),
                        print_scientific_double(xyz[2]), cd, self.ps, seid))
        else:
            if [cd, self.ps, self.seid] == [0, '', 0]:
                msg = ('GRID*   %16i%16s%16s%16s\n'
                       '*       %16s\n' %
                       (self.nid, cp, print_float_16(xyz[0]),
                        print_float_16(xyz[1]), print_float_16(xyz[2])))
            else:
                msg = ('GRID*   %16i%16s%16s%16s\n'
                       '*       %16s%16s%16s%16s\n' %
                       (self.nid, cp, print_float_16(xyz[0]),
                        print_float_16(xyz[1]), print_float_16(
                            xyz[2]), cd, self.ps, seid))
        return self.comment + msg
Exemplo n.º 3
0
    def write_card_16(self, is_double=False, bdf_file=None):
        # type: (bool) -> str
        """
        Writes a GRID card in 16-field format
        """
        assert bdf_file is not None
        self.make_current()
        msg = ''
        for nid, xyz, cp, cd, ps, seid in zip(
            self.nid, self.xyz, self.cp, self.cd, self.ps, self.seid):
            cps = set_string8_blank_if_default(cp, 0)
            cp = set_string16_blank_if_default(cp, 0)
            cd = set_string16_blank_if_default(cd, 0)
            seid = set_string16_blank_if_default(seid, 0)

            if is_double:
                if [cd, ps, seid] == [0, '', 0]:
                    msgi = ('GRID*   %16i%16s%16s%16s\n'
                            '*       %16s\n' % (
                                nid,
                                cp,
                                print_scientific_double(xyz[0]),
                                print_scientific_double(xyz[1]),
                                print_scientific_double(xyz[2])))
                else:
                    msgi = ('GRID*   %16i%16s%16s%16s\n'
                            '*       %16s%16s%16s%16s\n' % (
                                nid,
                                cp,
                                print_scientific_double(xyz[0]),
                                print_scientific_double(xyz[1]),
                                print_scientific_double(xyz[2]),
                                cd, ps, seid))
            else:
                if [cd, self.ps, self.seid] == [0, '', 0]:
                    msgi = ('GRID*   %16i%16s%16s%16s\n'
                            '*       %16s\n' % (
                                nid,
                                cp,
                                print_float_16(xyz[0]),
                                print_float_16(xyz[1]),
                                print_float_16(xyz[2])))
                else:
                    msgi = ('GRID*   %16i%16s%16s%16s\n'
                            '*       %16s%16s%16s%16s\n' % (
                                nid,
                                cp,
                                print_float_16(xyz[0]),
                                print_float_16(xyz[1]),
                                print_float_16(xyz[2]),
                                cd, ps, seid))
                msg += self.comment[nid] + msgi
        bdf_file.write(msg)
        return msg