Поиск по документации
Введите не менее 2 символов
Введите не менее 2 символов
![]() |
CAE Fidesys 9.0 Руководство пользователя |
Пользователи Python могут импортировать Fidesys в Python и выполнять вызовы в Fidesys через Fidesys, Cubit и другие классы Python, описанные в этом разделе. Ниже приведен простой скрипт Python. Ключевыми моментами являются обеспечение библиотеки Fidesys находятся на пути и обеспечивают вызов Cubit.init() делается первым.
import sys
# add Preprocessor Libraries to your path
fidesys_path = r'C:\Program Files\Fidesys\CAE-Fidesys-7.1'
prep_path = os.path.join(fidesys_path, 'preprocessor', 'bin')
os.environ['PATH'] += prep_path
sys.path.append(prep_path)
import cubit
import fidesys
# start cubit - this step is key. Note that:
# cubit.init does not require any arguments.
# If you do want to provide arguments, you must
# provide 2 or more, where the first must
# be "cubit", and user args start
# as the 2nd argument.
# If only one argument is used, it will be ignored.
cubit.init([""])
fc = fidesys.FidesysComponent()
fc.init_application(prep_path)
fc.start_up_no_args()
height = 1.2
blockHexRadius = 0.1732628
#create hexagon
fidesys.cmd(f"create prism height {height} sides 6 radius {blockHexRadius}")
#etc . . .
Скрипты Python, которые запускаются внутри Fidesys, имеют специальное имя модуля. Это имя модуля может использоваться для различения кода, который запускается внутри и вне Fidesys:
if __name__ == "__main__: . . . # Do this if running from # an external process elif __name__ == "__coreformcubit__": . . . # Do this if running from # inside Fidesys.