I am in a situation where i need to create and solve a large number of models (static structural) and I would like to automate that process. Currently I'm using Workbench scripting to create a batch file that i can run from command line. This script creates a model, imports geometry, sets up analysis settings, support conditions and loads. The main script uses Python code to control Workbench, but also sends commands to execute Jscript macros in Workbench. This gets me 90% of the way to my goal.


However, there are a few actions that I am not able to do with Jscript macros. For those actions I have ACT snippets that do the job very well (they assign plate thicknesses by reading a CSV file and assigning the values to bodies based on their names and then add several mesh controls). The problem is that I don't know if it's possible to send an ACT command to mechanical from Workbench, because ExtAPI does not seem to be accessible through Workbench journaling. 


I can execute my Workbench journal script that creates the models first and then open each model and run the ACT snippets, but they take a few minutes to execute and doing it manually for many models adds up to a long time. So I would like to call them programatically for each model from the main code that i use to create the models.


For reference, here's part of the ACT code that I want to either call from journal or rewrite using Jscript (then I could call it as a macro and avoid the problem altogether).

import csv 

import os


# Specify data file directory



# Read csv file into a dictionary

with open("Data.csv") as f:

    reader = csv.DictReader(f)

    data = [r for r in reader]


# Dictionary size

n1 = len(data)


# Prealocate lists

Part_name = []

Thickness_list = []

Unit = []

Alignment = []


# Populate the lists from dictionary

for i in range(n1):







# Select geometry

A = ExtAPI.DataModel.Project.Model.Geometry.Children[0]

n = A.Children.Count # Number of parts


for i in range(n):

B = A.Children[i]


# Identify the name of the plate

D = [s for s in Part_name if s in B.Name]


# Index the number of that plate in the list of plate thicknesses

Num1 = Part_name.index(D[0])


# Assign thickness

B.Thickness = Quantity(Thickness_list[Num1]+" ["+Unit[Num1]+"]") # Change thickness


# Assign offset

if Alignment[Num1] == 'Bottom':

B.ShellOffsetType =ShellOffsetType.Bottom

elif Alignment[Num1] == 'Middle':

B.ShellOffsetType =ShellOffsetType.Middle

elif Alignment[Num1] == 'Top':

B.ShellOffsetType =ShellOffsetType.Top