def _get_compressed_spoints(self): """ Gets the spoints in sorted, short form. uncompresed: SPOINT,1,3,5 compressed: SPOINT,1,3,5 uncompresed: SPOINT,1,2,3,4,5 compressed: SPOINT,1,THRU,5 uncompresed: SPOINT,1,2,3,4,5,7 compressed: SPOINT,7 SPOINT,1,THRU,5 """ spoints = list(self.spoints) spoints.sort() singles, doubles = collapse_thru_packs(spoints) lists_fields = [] if singles: list_fields = ['SPOINT'] + singles lists_fields.append(list_fields) if doubles: for spoint_double in doubles: list_fields = ['SPOINT'] + spoint_double lists_fields.append(list_fields) return lists_fields
def _get_compressed_xpoints(Type, xpoints): """ Gets the spoints in sorted, short form. uncompresed: SPOINT,1,3,5 compressed: SPOINT,1,3,5 uncompresed: SPOINT,1,2,3,4,5 compressed: SPOINT,1,THRU,5 uncompresed: SPOINT,1,2,3,4,5,7 compressed: SPOINT,7 SPOINT,1,THRU,5 Type = 'SPOINT' spoints = [1, 2, 3, 4, 5] fields = _get_compressed_xpoints(Type, spoints) >>> fields ['SPOINT', 1, 'THRU', 5] """ spoints = list(xpoints) spoints.sort() singles, doubles = collapse_thru_packs(spoints) lists_fields = [] if singles: list_fields = [Type] + singles lists_fields.append(list_fields) if doubles: for spoint_double in doubles: list_fields = [Type] + spoint_double lists_fields.append(list_fields) return lists_fields
def write_bdf(self, size, card_writer): skin = [] if self.isSkin: skin = ['SKIN'] #return self.comment() + print_card_8(['SET1', self.sid] + skin + self.IDs) field_packs = [] singles, doubles = collapse_thru_packs(self.IDs) if singles: field_packs.append(['SET1', self.sid] + skin + singles) if doubles: for pack in doubles: field_packs.append(['SET1', self.sid] + skin + pack) msg = [] for field_pack in field_packs: msg.append(print_card_8(field_pack)) return ''.join(msg)
def write_bdf(self, size, card_writer): skin = [] if self.isSkin: skin = ['SKIN'] return self.comment() + print_card_8(['SET1', self.sid] + skin + self.IDs) field_packs = [] singles, doubles = collapse_thru_packs(self.IDs) if singles: field_packs.append(['SET1', self.sid] + skin + singles) if doubles: for pack in doubles: field_packs.append(['SET1', self.sid] + skin + pack) msg = [] for field_pack in field_packs: msg.append(print_card_8(field_pack)) return ''.join(msg)
def write_set(value, options, spaces=''): """ writes SET 80 = 3926, 3927, 3928, 4141, 4142, 4143, 4356, 4357, 4358, 4571, 4572, 4573, 3323 THRU 3462, 3464 THRU 3603, 3605 THRU 3683, 3910 THRU 3921, 4125 THRU 4136, 4340 THRU 4351 """ value.sort() starter = 'SET %s = ' % (options) msg2 = spaces + starter msg = '' nchars = len(msg2) is_valid = True for valuei in value: if not isinstance(valuei, integer_types): is_valid = False break if is_valid: singles, doubles = collapse_thru_packs(value) out_value = singles for double in doubles: assert len(double) == 3, double sdouble = '%i THRU %i' % (double[0], double[2]) out_value.append(sdouble) else: out_value = value for i, out_valuei in enumerate(out_value): new_string = '%s, ' % out_valuei if len(msg2 + new_string) > 70: msg += msg2 + '\n' msg2 = ' ' * nchars + new_string else: msg2 += new_string return msg + msg2.rstrip(' \n,') + '\n'
def write_card(self, size=8, is_double=False): skin = [] if self.isSkin: skin = ['SKIN'] # checked in NX 2014 / MSC 2005.1 return self.comment + print_card_8(['SET1', self.sid] + skin + self.get_IDs()) # I thought this worked in the new MSC Nastran... # Doesn't work in NX 2014 / MSC 2005.1 (multiple duplicate sids). # It may work with one sid, with singles and doubles on one card. field_packs = [] singles, doubles = collapse_thru_packs(self.get_IDs()) if singles: field_packs.append(['SET1', self.sid] + skin + singles) if doubles: for pack in doubles: field_packs.append(['SET1', self.sid] + skin + pack) msg = [] for field_pack in field_packs: msg.append(print_card_8(field_pack)) return ''.join(msg)
def raw_fields(self): """ Gets the fields in their unmodified form :param self: the SPOINT object pointer :returns fields: the fields that define the card :type fields: LIST """ lists_fields = [] if isinstance(self.nid, int): list_fields = ['SPOINT', self.nid] lists_fields.append(list_fields) else: singles, doubles = collapse_thru_packs(self.nid) if singles: list_fields = ['SPOINT'] + singles if doubles: for spoint_double in doubles: list_fields = ['SPOINT'] + spoint_double lists_fields.append(list_fields) return lists_fields
def raw_fields(self): """ Gets the fields in their unmodified form :param self: the EPOINT/SPOINT object pointer :returns fields: the fields that define the card :type fields: LIST """ lists_fields = [] if isinstance(self.nid, integer_types): list_fields = [self.type, self.nid] lists_fields.append(list_fields) else: singles, doubles = collapse_thru_packs(self.nid) if singles: list_fields = [self.type] + singles if doubles: for spoint_double in doubles: list_fields = [self.type] + spoint_double lists_fields.append(list_fields) return lists_fields