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

时间:2017-01-18 16:42:14

标签: python batch-file abaqus

我编写了一个python脚本(或函数)来获取一些参数并需要由abaqus运行,我想通过批处理文件来完成。我是批处理文件的新手,不知道如何通过abaqus在不同的路径中运行python脚本。例如,假设python代码路径为D:\pythonscript\test.py

4 个答案:

答案 0 :(得分:0)

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

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

答案 1 :(得分:0)

如果要从批处理文件将信息传递给python脚本,则需要sys

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

argv是发送到python脚本的参数列表。 argv[0]是脚本本身的名称和路径,后面的所有内容都以空格分隔。

然后在批处理文件中(例如):

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

这适用于独立脚本。您将不得不为cae脚本稍微修改它,但我不再使用它们(意味着我需要许可证,这些供应商供不应求)所以我不确定如何。

答案 2 :(得分:0)

您可以在.bat文件中使用以下行让Abaqus运行python脚本:

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

我建议在python脚本本身中收集python脚本的参数,使用input()函数或在其他地方读取输入文件。您可以在python脚本中指定在哪里查找包含参数的文件。

答案 3 :(得分:0)

您应该写:

  import { Component, OnInit } from '@angular/core';
  declare var $: any;
  @Component({
    selector: 'app-hospital-manage',
    templateUrl: './hospital-manage.component.html',
    styleUrls: ['./hospital-manage.component.scss']
  })
  export class HospitalManageComponent implements OnInit {
    IsEdit = false;
    HospitalID = null;
    constructor() {}

    ngOnInit() {
      const t = $('#example').DataTable({
        processing: true,
        serverSide: true,
        info: true,
        ajax: {
          url: 'http://localhost:35257/data/searchhospital',
          data: function(data) {
            delete data.columns;
          }
        },
        // scrollY: 300,
        deferRender: true,
        // scroller: true,
        columns: [
          { data: 'HospitalName' },
          {
            render: function(data, type, item, meta) {
              return '<a class="btn btn-warning btn-sm" onclick="MyFunction()"><i class="fa fa-pencil"></i></a>';
            }
          }
        ],
        columnDefs: [{ orderable: false, targets: [0] }], // to disable columns order, may cause error if not put correctly
        order: [[1, 'asc']],
        select: true,
        dom: 'lfrtip',
        //  responsive: true,
        buttons: true,
        language: {
          emptyTable:
            '<div class="text-warning text-center">No Carton found.</div>'
        }
      });
    }

    public MyFunction() {
      alert();
    }
  }

如果要查看模拟,请将“ noGUI”替换为“脚本”