Import pressures/temperatures (external data) automatically using scripting

Erik Kostson
Erik Kostson Member, Moderator, Employee Posts: 314
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited February 28 in Structures

Say we have several csv files (for different named selections), with each file containing 3 columns with X, Y, Z coordinates and the remaining columns corresponding to each time step, how can we using mechanical or workbench scripting automate the set up of first the external data, and then the imported loads inside mechanical (SYS / System A say)?

Comments

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 314
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited July 2024

    Below is one way of doing this (wbjn - run via WB/File/Scripting/Run Script File). The file can be easily changed to account for other imported loads. The attached files import Pressures (readexternaldata.wbjn) and Temperatures (readexternaldatatemp)).

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 314
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited February 28

    On a different point, related to adding the source (NewRow[0] below), and analysis time (NewRow[1] below) in the imported load data This can be done say for source and analysis times=1,3,7,9 as follows:

    model=ExtAPI.DataModel.Project.Model # refer to Model
    analysis = model.Analyses[0]
    solution = analysis.Solution
    impLoadGrp = ExtAPI.DataModel.GetObjectsByName('Imported Load (A6) ')[0] # change as needed
    presload=impLoadGrp.AddImportedBodyTemperature()
    ns=ExtAPI.DataModel.GetObjectsByName('Selection')[0]
    presload.Location=ns
    for i in range(0,5):
        table=presload.GetTableByName("") # get the worksheet table
        NewRow = Ansys.ACT.Automation.Mechanical.WorksheetRow()
        table.Add(NewRow)
        NewRow[0]=2*i+1
        NewRow[1]=2*i+1
        NewRow[2]=1
        NewRow[3]=0
    table.RemoveAt(0)
    impLoadGrp.ImportLoad()
    
This discussion has been closed.