Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

FEMAP python script - Error occurs if model is processed from a different directory

Creator
Creator

Hello,

 

I just finished and debugged a FEMAP Python script to perform the following tasks:

  1. Given a directory --> Open and load the corresponding .nas/FNO files
  2. For each .nas/NFO file, set the appropriate postprocessing settings
  3. Change the model’s orientation.  Take a pic and save it to a directory (do this 4 times)
  4. Repeat steps 2-3 until all .nas/FNO files are processed 

During the debugging process an error dialog pops up (see attached pic), but not sure what “Errors have occurred.”

 

Here’s a workflow that generates a “clean” run, then the error, back to a clean run.

 

  1. Open a  new FEMAP session
  2. Run the script on directory 1.  File1.nas/NFO exist in this directory along with one other shell and solid models.  This results in a “clean” run.
  3. On the same FEMAP session, run the script on directory 2.  File1.nas/NFO also exist in this directory, to include other solid models.  This is where I run into the error message for all the files including File1.
  4. Still using the original FEMAP session, I run the script again on directory 1, which is technically repeating step 2.  No errors.  

After each model, I perform a fApp.feFileClose(False) and then fApp.feFileNew() to prepare for the next file.  Other than opening a new FEMAP session to avoid this error, is there a “cleanup” I should perform ifI run my script on different directories during the same FEMAP session?

 

Thank you.

3 REPLIES 3

Re: FEMAP python script - Error occurs if model is processed from a different directory

Siemens Valued Contributor Siemens Valued Contributor
Siemens Valued Contributor

Do any red error messages occur further up in the message window?

It is possible that an error is called earlier in the process for an unrelated reason, then if the error flag has not been reset it will cause the general “Errors have Occurred” message at the end of the next translation. Typically this flag is reset after every command when using the GUI. The API however can run commands directly without ever resetting the flag.

Try resetting the flag programmatically using App.ErrorHasBeenCalled = False and if you track down what causes the error in the first place then let us know so we can investigate and see if any fixes are needed. 

You may be also experiencing issues due to the Windows current directory not being set appropriately. This sometimes can occur when reading or writing files from Femap if the model file has never been saved. Try using app.feFileCurrentDirectory() method when saving files in different directories to assist with this.

 

Dan

Re: FEMAP python script - Error occurs if model is processed from a different directory

Creator
Creator

Hello Dan,

 

The python script runs without any errors, so there are no red errors in the message area.  I perform a fApp.feFileNew() before I load the model and results.  Perform some PostProcessing setting to include rotating the model.  I don't want to save any changes, so I use the fApp.fefileClose(False) after processing the current file. Repeat until I process all the files .nas files. Clean run.

 

I run the script again using the same FEMAP session, but pointing to a different dictory.  That's when I get the "red error message"  when it processes the first .nas file.  In turn, I have to manually hit OK to dismiss the dialog.  Then it will go through the same process of PostProcessing, Rotate, take pic and fApp.fefileClose(False).  I'll get the red error message whenever I process the next .nas file.

 

Let me check out the App.ErrorHasBeenCalled = False and I'll report my findings.

 

Thank you.

Re: FEMAP python script - Error occurs if model is processed from a different directory

Creator
Creator
Hello Dan,

I added App.ErrorHasBeenCalled = False right after the While loop. The "Errors have Occurred" dialog no longer pops up. I can now run my script several times using the same FEMAP session. This is helpful so I don't need to manually close FEMAP whenever I need to run my script against a different directory for testing/debugging purposes.

Thank you!