def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True): """ Converts Nastran to STL/Cart3d/Tecplot """ assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid', 'nastran'], 'format2=%s' % fmt2 xref = True if fmt2 == 'ugrid': xref = False model = BDF(debug=debug) model.read_bdf(bdf_filename, xref=xref) if data['--scale'] != 1.0: scale = data['--scale'] data['--scale'] = 1.0 for nid, node in iteritems(model.nodes): xyz = node.get_position() node.xyz *= scale node.cp = 0 del node.cp_ref if fmt2 == 'stl': nastran_to_stl(model, fname2, is_binary=data['--binary']) elif fmt2 == 'cart3d': cart3d = nastran_to_cart3d(model) cart3d.write_cart3d(fname2) elif fmt2 == 'tecplot': tecplot = nastran_to_tecplot(model) tecplot_filename = fname2 tecplot.write_tecplot(tecplot_filename, adjust_nids=False) elif fmt2 == 'ugrid': ugrid = nastran_to_ugrid(model, fname2) elif fmt2 == 'nastran': model.write_bdf(fname2, size=16) else: raise NotImplementedError(fmt2)
def process_nastran(bdf_filename, fmt2, fname2, log, data=None, debug=True, quiet=False): """ Converts Nastran to STL/Cart3d/Tecplot/UGRID3d """ assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid', 'nastran', 'abaqus'], 'format2=%s' % fmt2 from pyNastran.bdf.bdf import BDF xref = True if fmt2 == 'ugrid': xref = False model = BDF(log=log, debug=debug) model.read_bdf(bdf_filename, validate=False, xref=xref) if data['--scale'] != 1.0: scale = data['--scale'] data['--scale'] = 1.0 for node in model.nodes.values(): node.xyz = node.get_position() * scale node.cp = 0 del node.cp_ref if fmt2 == 'stl': from pyNastran.converters.nastran.nastran_to_stl import nastran_to_stl nastran_to_stl(model, fname2, is_binary=data['--binary']) elif fmt2 == 'cart3d': from pyNastran.converters.nastran.nastran_to_cart3d import nastran_to_cart3d cart3d = nastran_to_cart3d(model) cart3d.write_cart3d(fname2) elif fmt2 == 'tecplot': from pyNastran.converters.nastran.nastran_to_tecplot import nastran_to_tecplot tecplot = nastran_to_tecplot(model) tecplot_filename = fname2 tecplot.write_tecplot(tecplot_filename, adjust_nids=False) elif fmt2 == 'ugrid': from pyNastran.converters.nastran.nastran_to_ugrid import nastran_to_ugrid nastran_to_ugrid(model, fname2) elif fmt2 == 'abaqus': from pyNastran.converters.nastran.nastran_to_abaqus import nastran_to_abaqus nastran_to_abaqus(model, fname2) elif fmt2 == 'nastran': model.write_bdf(fname2, size=16) else: raise NotImplementedError( 'fmt2=%s is not supported by process_nastran' % fmt2)
def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True): """ Converts Nastran to STL/Cart3d/Tecplot """ assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid'], 'format2=%s' % fmt2 xref = True if fmt2 == 'ugrid': xref = False model = BDF(debug=debug) model.read_bdf(bdf_filename, xref=xref) if fmt2 == 'stl': nastran_to_stl(model, fname2, is_binary=data['--binary']) elif fmt2 == 'cart3d': cart3d = nastran_to_cart3d(model) cart3d.write_cart3d(fname2) elif fmt2 == 'tecplot': tecplot = nastran_to_tecplot(model) tecplot_filename = fname2 tecplot.write_tecplot(tecplot_filename, adjust_nids=False) elif fmt2 == 'ugrid': ugrid = nastran_to_ugrid(model, fname2) else: raise NotImplementedError(fmt2)
def process_nastran(bdf_filename, fmt2, fname2, data=None, debug=True): """ Converts Nastran to STL/Cart3d/Tecplot/UGRID3d """ assert fmt2 in ['stl', 'cart3d', 'tecplot', 'ugrid', 'nastran'], 'format2=%s' % fmt2 xref = True if fmt2 == 'ugrid': xref = False model = BDF(debug=debug) model.read_bdf(bdf_filename, xref=xref) if data['--scale'] != 1.0: scale = data['--scale'] data['--scale'] = 1.0 for nid, node in iteritems(model.nodes): xyz = node.get_position() node.xyz *= scale node.cp = 0 del node.cp_ref if fmt2 == 'stl': nastran_to_stl(model, fname2, is_binary=data['--binary']) elif fmt2 == 'cart3d': cart3d = nastran_to_cart3d(model) cart3d.write_cart3d(fname2) elif fmt2 == 'tecplot': tecplot = nastran_to_tecplot(model) tecplot_filename = fname2 tecplot.write_tecplot(tecplot_filename, adjust_nids=False) elif fmt2 == 'ugrid': nastran_to_ugrid(model, fname2) elif fmt2 == 'nastran': model.write_bdf(fname2, size=16) else: raise NotImplementedError(fmt2)
def test_nastran_to_stl(self): """tests nastran_to_stl""" bdf_filename = os.path.join(model_path, "plate", "plate.bdf") stl_filename = os.path.join(model_path, "plate", "plate.stl") nastran_to_stl(bdf_filename, stl_filename, is_binary=False)
def test_nastran_to_stl(self): """tests nastran_to_stl""" bdf_filename = os.path.join(model_path, 'plate', 'plate.bdf') stl_filename = os.path.join(model_path, 'plate', 'plate.stl') log = get_logger(log=None, level='warning', encoding='utf-8') nastran_to_stl(bdf_filename, stl_filename, is_binary=False, log=log)
def test_nastran_to_stl(self): """tests nastran_to_stl""" bdf_filename = os.path.join(model_path, 'plate', 'plate.bdf') stl_filename = os.path.join(model_path, 'plate', 'plate.stl') nastran_to_stl(bdf_filename, stl_filename, is_binary=False)
def test_nastran_to_stl(self): """tests nastran_to_stl""" bdf_filename = os.path.join(MODEL_PATH, 'plate', 'plate.bdf') stl_filename = os.path.join(MODEL_PATH, 'plate', 'plate.stl') log = SimpleLogger(level='warning', encoding='utf-8') nastran_to_stl(bdf_filename, stl_filename, is_binary=False, log=log)