简体   繁体   English

通过批处理文件运行 abaqus python 脚本?

[英]Running an abaqus python script via batch file?

I have written a python script(or function) that get some argument and need to run by abaqus and I want to do this by a batch file.我编写了一个 python 脚本(或函数),它得到一些参数并需要由 abaqus 运行,我想通过批处理文件来执行此操作。 I am new in batch file and do not know how i can run a python script in different path by abaqus.我是批处理文件的新手,不知道如何通过 abaqus 在不同路径中运行 python 脚本。 For example, assume that the python code path is D:\\pythonscript\\test.py .例如,假设 python 代码路径是D:\\pythonscript\\test.py

这应该有效,您必须更新您的 Abaqus 路径,因为我猜您的版本是更新的。

"C:\Abaqus\6.10-EF2\exec\abq610ef2.exe" cae script=D:\pythonscript\test.py %*

If you want to pass infromation to your python script from a batch file, you need sys如果要将信息从批处理文件传递给 python 脚本,则需要sys

import sys
inodb = openOdb(path=str(sys.argv[1])) #for example

argv is a list of arguments sent to the python script. argv是发送到 python 脚本的参数列表。 argv[0] is the name and path of the script itself, and every thing after is separated by spaces. argv[0]是脚本本身的名称和路径,后面的所有内容都用空格分隔。

Then in your batch file (for example):然后在您的批处理文件中(例如):

for %%f in (.\*.odb) do (
    abaqus python D:\pythonscript\test.py %%f
)

This is for stand alone scripts.这是用于独立脚本。 You'll have to modify it a bit for cae scripts, but I don't use them anymore (means I need a license, which are in short supply) so I'm not sure how.对于cae脚本,您必须对其进行一些修改,但我不再使用它们(意味着我需要许可证,但供应不足)所以我不确定如何使用。

You can use the following line in the .bat file to have Abaqus run a python script:您可以在 .bat 文件中使用以下行让 Abaqus 运行 python 脚本:

start abaqus cae script="C:<location_of_.py_script>\<scriptname>.py"

I would recommend to have the arguments for the python script collected in the python script itself, either using the input() function or by reading an input file somewhere else.我建议在 python 脚本本身中收集 python 脚本的参数,要么使用 input() 函数,要么通过读取其他地方的输入文件。 You can specify within the python script where to find the file containing the arguments.您可以在 python 脚本中指定在哪里可以找到包含参数的文件。

You should write:你应该写:

abaqus cae noGUI="Full path to your code"

If you want to see the simulation, replace "noGUI" with "script"如果要查看模拟,请将“noGUI”替换为“script”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM