How to call functions / journaling commands from a compiled ACT wbex project?

Nick Ramseyer
Nick Ramseyer Member Posts: 25
10 Comments Name Dropper
**

I recently compiled my ACT wbex and noticed that some functionality in my scripts no longer works. Specifically, I am sending a command to Mechanical from the workbench project page using the wbjn.ExecuteCommand function to call in a function once Mechanical has been opened using model.SendCommand(Language="Python", Command={}).

The issue appears to be that when the wbex compiles it no longer is able to understand an import command of a function in mechanical. This is a good thing as the end user can't see or use the commands from the wbex, but is causing problems as it breaks the code that I am calling to automate workflows between spaceclaim/mechanical.

As an example I have a function that exists within the projects folder structure like this:

The goal is to call the "example function.py" after opening mechanical during journaling.
Currently I did this using an import and then called the function after:
`model.Edit()

model.SendCommand(Language="Python", Command="from folder_of_functions.example_function import example_function"

model.SendCommand(Language="Python", Command="example_function()`

The issue being that example_function cannot be imported and therefore cannot be run.

Is there a recommended workflow or way to call functions using the journal once the project has been compiled to a .wbex? I saw there is a way to call a function instead of using SendCommand, but it's unclear where that function would need to be to be called within the project.

Answers