can I treat two different postfeko instances in a lua script?

Israel Lopez
Israel Lopez Altair Community Member
edited January 2021 in Community Q&A

I'm writing a LUA script to process a big number of near fields in a model. 

I'm reading the whole dataset. According to the type of near field (internal decision) I have to plot the results in different postfeko sessions (.pfs)

What I’m doing now is read the near fields twice. I decide what to plot in the first .pfs file, then read the near fields again and decide what to plot in the second .pfs file.

Could I read the near fields only once, and send the results to one view in one file, and another set of results?

In other words, can I have two views open at the same time that corresponds to two different .pfs files?

Thanks

Tagged:

Answers

  • Derek Campbell_20514
    Derek Campbell_20514 New Altair Community Member
    edited January 2021

    Hi Israel:

    I wrote the following script that creates a PFS session, adds a Cartesian graph, and plots data on the graph. Next, I add another Cartesian graph, add a different plot and save the session as a separate PFS session. According to the API documentation, POSTFEKO only allows CartesianGraphs to be added and not deleted. The second PFS session would have all the data and you may have to manually delete Graphs that were associated with the first session.

    Please note that although I used this particular type of graph, users could also use other graphs and / or 3D Views.

    app = pf.GetApplication()
    app:NewProject()
    app:OpenFile([[<Custom path to be replaced by user>\test.fek]])

    c1 = app.Models["test"].Configurations[1]

    cg1 = app.CartesianGraphs:Add()

    cg1.Traces:Add(c1.NearFields[1])

    app:SaveAs([[<Custom path to be replaced by user>\test1.pfs]])

    cg2 = app.CartesianGraphs:Add()

    cg2.Traces:Add(c1.NearFields[2])

    app:SaveAs([[<Custom path to be replaced by user>\test2.pfs]])