Jump to content

Scripting error: attempt to index global 'pf' (a nil value)

Recommended Posts



I am trying to run a POSTFEKO script from my CADFEKO script. But when I want to run a function from my POSTFEKO script in my CADFEKO script it gives the following error: "attempt to index global 'pf' (a nil value)"

The code looks still messy, but I want to know why I cannot do a pf.GetApplication() when running from a CADFEKO project.




Share this post

Link to post
Share on other sites

Hi Meerten


As far as I know, you cannot call a function that uses POSTFEKO commands directly from within a CADFEKO script like in your example. The commands will be executed in CADFEKO at that point and "pf", the POSTFEKO namespace would not be available (see the User Manual chapter "Scripts and Application Programming Interface (API)" or Example Guide I1 "Introduction to Application Automation" for more information). You would have to use a command in the CADFEKO script that opens POSTFEKO with the post-processing script that you wish to execute. You could try something like the following:


cf.Launcher.Run("postfeko", {"modelname.fek", "--run-script", "createAndExportGraph.lua", "--non-interactive"})


You can run POSTFEKO in non-interactive mode, or you can leave out the last command if you wish to see the execution of commands or interact with POSTFEKO as the commands are being executed. You can close POSTFEKO in the post-processing script by using app:Close().


Here is a very simple example where CADFEKO is only used to run POSTFEKO to export a graph image:

As to sending parameters from CADFEKO to POSTFEKO, I'm not sure about the most elegant way to do this. One option would be to write/read the parameters to/from a (text) file using standard Lua commands.


Hope this helps.


Kind regards


Sasha1296 likes this

Share this post

Link to post
Share on other sites

  • Create New...