-
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gui: - saving animation settings
- Loading branch information
Steve Doyle
committed
Dec 7, 2024
1 parent
e6258d9
commit 3a86a1a
Showing
10 changed files
with
313 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
import sys | ||
from collections import defaultdict | ||
bdf_filename = sys.argv[1] | ||
base, ext = os.path.splitext(bdf_filename) | ||
bdf_filename_out = base + '.dedmap' + ext | ||
|
||
with open(bdf_filename, 'r') as bdf_file: | ||
lines = bdf_file.readlines() | ||
nlines = len(lines) | ||
|
||
blocks = defaultdict(list) | ||
i = 0 | ||
line = lines[i] | ||
while 'N A S T R A N S O U R C E P R O G R A M C O M P I L A T I O N' not in line: | ||
print(i, line.strip()) | ||
i += 1 | ||
line = lines[i] | ||
|
||
while i < nlines and 'N A S T R A N S O U R C E P R O G R A M C O M P I L A T I O N' in line: | ||
line = lines[i] | ||
print('*', i, line) | ||
source, dmap = line.strip().split('SUBDMAP =') | ||
#dmap = dmap.strip() | ||
print(f'dmap = {dmap!r}') | ||
|
||
blocks[dmap].append(line) | ||
i += 1 | ||
line = lines[i] | ||
|
||
blocks[dmap].append(line) | ||
while 'PAGE' not in line: | ||
blocks[dmap].append(line) | ||
i += 1 | ||
line = lines[i] | ||
for j in range(3): | ||
i += 1 | ||
line = lines[i] | ||
print('**', i, line.strip()) | ||
# i += 2 | ||
# line = lines[i] | ||
# print('**', i, line) | ||
print('--------------------------') | ||
|
||
|
||
with open(bdf_filename_out, 'w') as bdf_file_out: | ||
for block_name, block in blocks.items(): | ||
bdf_file_out.write(f'0 N A S T R A N S O U R C E P R O G R A M C O M P I L A T I O N SUBDMAP = {block_name}\n') | ||
bdf_file_out.write(f' OLD NO. NEW NO. ( *I* = INSERTED, *D* = DELETED )\n') | ||
for line in block: | ||
if (line.startswith(' DMAP-DMAP INSTRUCTION') or | ||
'N A S T R A N S O U R C E P R O G R A M C O M P I L A T I O N' in line or | ||
'OLD NO. NEW NO. ( *I* = INSERTED, *D* = DELETED )' in line): | ||
continue | ||
bdf_file_out.write(line) | ||
print(f'finished writing {bdf_filename_out}') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import os | ||
from pathlib import Path | ||
import sys | ||
|
||
import argparse | ||
import pyNastran | ||
|
||
def run_jobs_cmd_line(argv=None, quiet: bool=False): | ||
""" | ||
run_nastran_job dirname | ||
run_nastran_job filename -x C:\bin\nastran.exe | ||
""" | ||
if argv is None: | ||
argv = sys.argv | ||
parser = argparse.ArgumentParser() | ||
|
||
parser.add_argument("bdf_dirname_filename", help='path to Nastran filename') | ||
parser.add_argument('-x', '--exe', help='path to Nastran execuable') | ||
#parent_parser.add_argument('-h', '--help', help='show this help message and exits', action='store_true') | ||
parser.add_argument('-v', '--version', action='version', | ||
version=pyNastran.__version__) | ||
|
||
args = parser.parse_args(args=argv[1:]) | ||
if not quiet: # pragma: no cover | ||
print(args) | ||
|
||
bdf_filename_dirname = Path(args.bdf_dirname_filename) | ||
nastran_exe = args.exe | ||
if nastran_exe is None: | ||
nastran_exe = 'nastran' | ||
elif '.bat' in nastran_exe or '.exe' in nastran_exe: | ||
nastran_exe = Path(nastran_exe) | ||
assert nastran_exe.exists(), nastran_exe | ||
assert nastran_exe.is_file(), nastran_exe | ||
|
||
assert bdf_filename_dirname.exists(), bdf_filename_dirname | ||
|
||
from pyNastran.utils.nastran_utils import run_nastran | ||
if bdf_filename_dirname.is_dir(): | ||
dirname = bdf_filename_dirname | ||
extensions = ['.dat', '.bdf'] | ||
bdf_filenames = [dirname / fname.name for fname in dirname.iterdir() | ||
if fname.suffix in extensions and '.test_bdf.' not in fname.name] | ||
print('bdf_filenames =', bdf_filenames) | ||
assert len(bdf_filenames) > 0, dirname | ||
for bdf_filename in bdf_filenames: | ||
run_nastran(bdf_filename, nastran_cmd=nastran_exe, cleanup=True) | ||
|
||
|
||
elif bdf_filename_dirname.is_file(): | ||
run_nastran(bdf_filename_dirname, nastran_cmd=nastran_exe, cleanup=True) | ||
else: | ||
raise NotImplementedError(bdf_filename_dirname) | ||
|
||
if __name__ == '__main__': | ||
run_jobs_cmd_line() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.